/* Modern CSS with Custom Properties */
:root {
    --m50-primary: #ff473b;
    --m50-primary-hover: #ff6b5b;
    --m50-bg-dark: #121212;
    --m50-bg-light: #f8f9fa;
    --m50-text-light: #ffffff;
    --m50-text-dark: #333333;
    --m50-border-alpha: rgba(255, 255, 255, 0.1);
    --m50-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --m50-radius: 8px;
    --m50-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Spacing scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
}

/* Modern container with CSS Grid */
.m50-schedule-container {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--m50-bg-dark);
    color: var(--m50-text-light);
    padding: var(--space-lg);
    border-radius: var(--m50-radius);
    margin: var(--space-lg) 0;
    box-shadow: var(--m50-shadow);
    container-type: inline-size;
}

/* Modern filters with CSS Grid */
.schedule-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    padding: var(--space-lg);
    background: var(--m50-border-alpha);
    border-radius: var(--m50-radius);
    backdrop-filter: blur(10px);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-size: 14px;
    font-weight: 500;
    color: #ccc;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 14px;
    min-width: 150px;
}

.filter-select:focus {
    outline: none;
    border-color: #ff473b;
    box-shadow: 0 0 0 2px rgba(255, 71, 59, 0.2);
}

.reset-btn {
    padding: 8px 16px;
    background: #ff473b;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    align-self: flex-end;
}

.reset-btn:hover {
    background: #ff6b5b;
    transform: translateY(-1px);
}

/* Schedule Header */
.schedule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.schedule-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: #ff473b;
    border-color: #ff473b;
    transform: scale(1.1);
}

.current-week {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

.view-toggle {
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px;
    border-radius: 8px;
}

.view-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: #ccc;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.view-btn.active,
.view-btn:hover {
    background: #ff473b;
    color: #fff;
}

/* Modern week view with subgrid support */
.week-view {
    display: grid;
    grid-template-columns: 80px repeat(7, 1fr);
    gap: 1px;
    background: var(--m50-border-alpha);
    border-radius: var(--m50-radius);
    overflow: hidden;
    container-type: inline-size;
}

.time-column {
    background: rgba(255, 255, 255, 0.05);
}

.time-header {
    height: 60px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.time-slot {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #ccc;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.day-column {
    background: rgba(255, 255, 255, 0.02);
    position: relative;
}

.day-header {
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.day-name {
    font-weight: 600;
    font-size: 14px;
}

.day-date {
    font-size: 12px;
    color: #ccc;
    margin-top: 2px;
}

.day-schedule {
    position: relative;
    min-height: 780px; /* 13 time slots * 60px */
}

/* Đảm bảo time-slot-container có kích thước cố định */
.time-slot-container {
    height: 60px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: visible;
    box-sizing: border-box;
}

/* Enhanced class items with modern animations */
.class-item {
    position: absolute;
    inset-inline: var(--space-xs);
    top: 2px;
    background: linear-gradient(135deg, var(--m50-primary), var(--m50-primary-hover));
    border-radius: var(--m50-radius);
    padding: var(--space-sm);
    cursor: pointer;
    transition: var(--m50-transition);
    box-shadow: var(--m50-shadow);
    z-index: 1;
    min-height: 54px;
    height: auto !important;
    overflow: visible !important;
    box-sizing: border-box;
    
    /* Modern backdrop filter */
    backdrop-filter: blur(10px);
}

.class-item:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    z-index: 100 !important;
    overflow: visible !important;
}

/* Focus styles for accessibility */
.class-item:focus-visible {
    outline: 2px solid var(--m50-primary);
    outline-offset: 2px;
}

/* Đảm bảo day-schedule container đúng */
.day-schedule {
    position: relative;
    min-height: 840px;
    overflow: visible !important;
    box-sizing: border-box;
}

/* Fix cho class kéo dài nhiều slot */
.class-item.multi-slot {
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 5;
    overflow: visible !important;
}

/* Đảm bảo content hiển thị đúng trong mọi trường hợp */
.class-content {
    height: auto;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    box-sizing: border-box;
    overflow: visible !important;
}

/* Cải thiện hiển thị class-title và class-instructor */
.class-title {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.2;
    margin-bottom: 4px;
    overflow: visible !important;
    text-overflow: unset !important;
    white-space: normal !important;
    word-wrap: break-word;
    max-height: none !important;
    flex-shrink: 0;
    display: block;
}

.class-instructor {
    font-size: 11px;
    opacity: 0.9;
    margin-bottom: 4px;
    overflow: visible !important;
    text-overflow: unset !important;
    white-space: normal !important;
    word-wrap: break-word;
    max-height: none !important;
    flex-shrink: 0;
}

.class-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    opacity: 0.8;
    margin-top: auto;
    flex-shrink: 0;
}

.class-level {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* Styling riêng cho các cấp độ */
.level-beginner {
    border-radius: 12px;
    background: rgba(76, 175, 80, 0.8) !important;
    border: 1px solid rgba(76, 175, 80, 0.9);
}

.level-advanced,
.level-advance {
    border-radius: 12px;
    background: rgba(244, 67, 54, 0.8) !important;
    border: 1px solid rgba(244, 67, 54, 0.9);
}

.level-intermediate,
.level-inter {
    border-radius: 8px;
    background: rgba(255, 193, 7, 0.8) !important;
    border: 1px solid rgba(255, 193, 7, 0.9);
}

.level-pre-beginner {
    border-radius: 6px;
    background: rgba(156, 39, 176, 0.8) !important;
    border: 1px solid rgba(156, 39, 176, 0.9);
}

.level-kids {
    border-radius: 15px;
    background: rgba(233, 30, 99, 0.8) !important;
    border: 1px solid rgba(233, 30, 99, 0.9);
}

/* Different class styles */
.class-item[data-style="hip-hop"] {
    background: linear-gradient(135deg, #e91e63, #ad1457);
}

.class-item[data-style="jazz-funk"] {
    background: linear-gradient(135deg, #9c27b0, #6a1b9a);
}

.class-item[data-style="contemporary"] {
    background: linear-gradient(135deg, #3f51b5, #283593);
}

.class-item[data-style="kpop"] {
    background: linear-gradient(135deg, #ff5722, #d84315);
}

.class-item[data-style="house"] {
    background: linear-gradient(135deg, #607d8b, #37474f);
}

/* Modern toast notifications */
.m50-toast {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    background: var(--m50-bg-dark);
    color: var(--m50-text-light);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--m50-radius);
    box-shadow: var(--m50-shadow);
    backdrop-filter: blur(10px);
    transform: translateX(100%);
    transition: var(--m50-transition);
    z-index: 1000;
}

.m50-toast--visible {
    transform: translateX(0);
}

.m50-toast--success {
    border-left: 4px solid #4caf50;
}

.m50-toast--error {
    border-left: 4px solid #f44336;
}

/* Loading states */
.schedule-content.loading {
    position: relative;
    pointer-events: none;
}

.schedule-content.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--m50-radius);
}

/* Responsive Design */
/* Tablet responsive */
@media (max-width: 1200px) {
    .week-view {
        grid-template-columns: 60px repeat(7, 1fr);
    }
    
    .class-title {
        font-size: 12px;
    }
    
    .class-instructor {
        font-size: 10px;
    }
}

/* Mobile responsive - Tablet */
@media (max-width: 768px) {
    .m50-schedule-container {
        padding: var(--space-md);
        margin: var(--space-md) 0;
    }
    
    .schedule-filters {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
        padding: var(--space-md);
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-select {
        min-width: 100%;
        padding: 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .schedule-header {
        flex-direction: column;
        gap: var(--space-md);
        text-align: center;
    }
    
    .current-week {
        font-size: 20px;
    }
    
    .schedule-nav {
        justify-content: center;
    }
    
    /* Chuyển sang mobile view - hiển thị theo ngày */
    .week-view {
        display: none; /* Ẩn week view trên mobile */
    }
    
    /* Mobile day view */
    .mobile-day-view {
        display: block;
    }
    
    .day-schedule {
        background: rgba(255, 255, 255, 0.05);
        border-radius: var(--m50-radius);
        margin-bottom: var(--space-md);
        overflow: hidden;
    }
    
    .day-header-mobile {
        background: rgba(255, 71, 59, 0.2);
        padding: var(--space-md);
        text-align: center;
        font-weight: 600;
        font-size: 16px;
    }
    
    .day-classes {
        padding: var(--space-sm);
    }
    
    .class-item-mobile {
        background: rgba(255, 255, 255, 0.1);
        border-radius: var(--m50-radius);
        padding: var(--space-md);
        margin-bottom: var(--space-sm);
        border-left: 4px solid var(--m50-primary);
    }
    
    .class-item-mobile:last-child {
        margin-bottom: 0;
    }
    
    .class-time-mobile {
        font-size: 14px;
        font-weight: 600;
        color: var(--m50-primary);
        margin-bottom: var(--space-xs);
    }
    
    .class-title-mobile {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: var(--space-xs);
        line-height: 1.3;
    }
    
    .class-instructor-mobile {
        font-size: 14px;
        color: #ccc;
        margin-bottom: var(--space-xs);
    }
    
    .class-meta-mobile {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-sm);
        font-size: 12px;
    }
    
    .class-level-mobile,
    .class-duration-mobile {
        background: rgba(255, 71, 59, 0.2);
        padding: 4px 8px;
        border-radius: 12px;
        font-size: 11px;
    }
}

/* Mobile responsive - Phone */
@media (max-width: 480px) {
    .m50-schedule-container {
        padding: var(--space-sm);
        margin: var(--space-sm) 0;
        border-radius: var(--space-sm);
    }
    
    .schedule-filters {
        padding: var(--space-sm);
    }
    
    .current-week {
        font-size: 18px;
    }
    
    .nav-btn {
        width: 36px;
        height: 36px;
    }
    
    .class-item-mobile {
        padding: var(--space-sm);
    }
    
    .class-title-mobile {
        font-size: 15px;
    }
    
    .class-instructor-mobile {
        font-size: 13px;
    }
    
    .class-time-mobile {
        font-size: 13px;
    }
}

/* Container queries for modern browsers */
@container (max-width: 768px) {
    .schedule-filters {
        grid-template-columns: 1fr;
    }
}

@container (max-width: 480px) {
    .class-item {
        padding: var(--space-xs);
        min-height: 46px;
    }
}

/* Ẩn mobile view trên desktop */
@media (min-width: 769px) {
    .mobile-day-view {
        display: none;
    }
}

/* Current time indicator cho mobile */
@media (max-width: 768px) {
    .current-time-indicator {
        display: none; /* Ẩn trên mobile vì không cần thiết */
    }
}

/* Toast notifications responsive */
@media (max-width: 480px) {
    .m50-toast {
        left: var(--space-sm) !important;
        right: var(--space-sm) !important;
        width: auto !important;
        max-width: none !important;
    }
}

/* Dark/Light theme support */
.m50-schedule-container[data-theme="light"] {
    --m50-bg-dark: var(--m50-bg-light);
    --m50-text-light: var(--m50-text-dark);
    --m50-border-alpha: rgba(0, 0, 0, 0.1);
    background-color: #f8f9fa;
    color: #333;
}

.m50-schedule-container[data-theme="light"] .schedule-filters {
    background: rgba(0, 0, 0, 0.05);
}

.m50-schedule-container[data-theme="light"] .filter-select {
    background: #fff;
    border-color: #ddd;
    color: #333;
}

.m50-schedule-container[data-theme="light"] .week-view {
    background: #e9ecef;
}

.m50-schedule-container[data-theme="light"] .time-column,
.m50-schedule-container[data-theme="light"] .day-header {
    background: #fff;
}

.m50-schedule-container[data-theme="light"] .day-column {
    background: #f8f9fa;
}

/* Loading animation */
.schedule-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 71, 59, 0.3);
    border-top: 4px solid #ff473b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Fix cho text bị cắt */
.class-item .class-title,
.class-item .class-instructor {
    text-overflow: unset !important;
    overflow: visible !important;
    white-space: normal !important;
    max-height: none !important;
    height: auto !important;
}

/* Đảm bảo container có đủ không gian */
.time-slot-container {
    overflow: visible !important;
    z-index: auto;
    height: 60px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    box-sizing: border-box;
}

/* Đảm bảo không có element nào bị cắt */
.class-item,
.class-item *,
.class-content,
.class-content * {
    overflow: visible !important;
    max-height: none !important;
    text-overflow: unset !important;
    white-space: normal !important;
}

/* Tooltip hiện đại */
.hightech-tooltip {
    position: absolute;
    z-index: 1000;
    background: rgba(15, 15, 20, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(255, 71, 59, 0.3);
    padding: 0;
    width: 280px;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    border-left: 3px solid #ff473b;
    overflow: hidden;
}

.hightech-tooltip.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.tooltip-header {
    background: linear-gradient(135deg, rgba(255, 71, 59, 0.8), rgba(255, 107, 91, 0.8));
    padding: 12px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip-title {
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    margin: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.tooltip-content {
    padding: 15px;
}

.tooltip-instructor {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.instructor-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 71, 59, 0.7);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    margin-right: 12px;
}

.instructor-info {
    flex: 1;
}

.instructor-name {
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    margin: 0 0 4px 0;
}

.tooltip-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.detail-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 10px;
    border-radius: 6px;
}

.detail-label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 10px;
    margin-bottom: 2px;
}

.detail-value {
    color: #fff;
    font-size: 12px;
    font-weight: 500;
}

.tooltip-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
}

.tooltip-link {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 71, 59, 0.2);
    color: #ff473b;
    padding: 6px 12px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
}

.tooltip-link:hover {
    background: rgba(255, 71, 59, 0.3);
    transform: translateY(-2px);
}

.tooltip-link svg {
    width: 14px;
    height: 14px;
    margin-right: 5px;
}

/* Hiệu ứng đóng mở */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 71, 59, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 71, 59, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 71, 59, 0); }
}

.tooltip-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.tooltip-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Hiệu ứng nền */
.tooltip-bg-effect {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    z-index: -1;
}

.tooltip-bg-effect::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 71, 59, 0.1) 0%, rgba(15, 15, 20, 0) 70%);
    animation: rotate 15s linear infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Hiệu ứng đường viền */
.tooltip-border-effect {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 10px;
    z-index: -1;
    overflow: hidden;
}

.tooltip-border-effect::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, 
        rgba(255, 71, 59, 0) 0%, 
        rgba(255, 71, 59, 0.3) 50%, 
        rgba(255, 71, 59, 0) 100%);
    animation: rotate-border 4s linear infinite;
}

@keyframes rotate-border {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Current Time Indicator */
.current-time-indicator {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: #ff473b;
    z-index: 10;
    box-shadow: 0 0 4px rgba(255, 71, 59, 0.6);
    pointer-events: none;
}

.current-time-indicator::before {
    content: '';
    position: absolute;
    left: -4px;
    top: -2px;
    width: 8px;
    height: 6px;
    background: #ff473b;
    border-radius: 50%;
}

/* Styling cho tooltip ảnh giáo viên */
#instructor-image-tooltip {
    width: 280px;
    border-left: 3px solid #4CAF50; /* Màu xanh lá để phân biệt với tooltip chính */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(76, 175, 80, 0.3);
}

.instructor-header {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.8), rgba(56, 142, 60, 0.8));
}

.instructor-image-container {
    text-align: center;
    margin-bottom: 15px;
    overflow: hidden;
    border-radius: 10px;
}

.instructor-image-container img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid rgba(76, 175, 80, 0.7);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s;
}

.instructor-image-container img:hover {
    transform: scale(1.05);
}

.instructor-profile-link {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
    width: 100%;
    justify-content: center;
    font-weight: 600;
    padding: 8px 16px;
}

.instructor-profile-link:hover {
    background: rgba(76, 175, 80, 0.3);
}

/* Thêm hiệu ứng hover cho tooltip */
#instructor-image-tooltip.visible {
    animation: fadeInScale 0.3s forwards;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}