/* Music Class Management System - Modern CSS */
:root {
    --primary-color: #4a6fa5;
    --secondary-color: #166088;
    --accent-color: #f39c12;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --light-bg: #f8f9fa;
    --dark-bg: #343a40;
    --text-color: #333;
    --light-text: #6c757d;
    --border-color: #dee2e6;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.auth-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 12px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.auth-bar strong {
    color: var(--primary-color);
}

.auth-bar .btn {
    padding: 8px 20px;
    text-transform: none;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    text-align: center;
}

header h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    color: var(--light-text);
    font-size: 1.1rem;
}

/* Navigation */
nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
}

nav a {
    text-decoration: none;
    color: var(--primary-color);
    padding: 10px 20px;
    border-radius: 25px;
    transition: var(--transition);
    font-weight: 500;
    border: 2px solid transparent;
}

nav a:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(74, 111, 165, 0.3);
}

body.role-teacher .action-bar,
body.role-teacher .form-container,
body.role-teacher .boss-only,
body.role-teacher .teacher-sensitive,
body.role-teacher .modal-actions,
body.role-teacher .form-section {
    display: none !important;
}

/* Main Content */
.main-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    color: var(--text-color);
}

/* Section Headers */
.section-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--primary-color);
}

.section-header h2 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.section-header p {
    color: var(--light-text);
    font-size: 1rem;
}

/* Forms */
.form-container {
    background: var(--light-bg);
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
}

body.role-teacher .form-container.teacher-visible {
    display: block !important;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: var(--transition);
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.btn {
    display: inline-block;
    padding: 12px 30px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 111, 165, 0.4);
}

.btn-secondary {
    background: var(--light-text);
}

.btn-secondary:hover {
    background: var(--dark-bg);
}

.btn-success {
    background: var(--success-color);
}

.btn-success:hover {
    background: #229954;
}

.btn-danger {
    background: var(--danger-color);
}

.btn-danger:hover {
    background: #c0392b;
}

.quick-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.quick-filter-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--light-text);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.quick-filter-chip:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.quick-filter-chip.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 4px 12px rgba(74, 111, 165, 0.25);
}

.table-container.is-loading {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* Tables */
.table-container {
    overflow-x: auto;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

thead {
    background: var(--primary-color);
    color: white;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    line-height: 1.35;
}

tbody td {
    color: var(--text-color);
    font-size: 0.9rem;
}

tbody td strong {
    color: var(--text-color);
}

th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.82rem;
    letter-spacing: 0.3px;
}

tbody tr:hover {
    background: var(--light-bg);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Attendance Section */
.attendance-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 30px;
    text-align: center;
}

.attendance-section h3 {
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.attendance-input-group {
    max-width: 400px;
    margin: 0 auto;
}

.attendance-input-group .form-group {
    margin-bottom: 15px;
}

.attendance-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
}

.attendance-message.success {
    background: var(--success-color);
    color: white;
}

.attendance-message.error {
    background: var(--danger-color);
    color: white;
}

/* Cards for Dashboard */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
}

.card h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.card p {
    color: var(--light-text);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    display: block;
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(39, 19, 46, 0.15);
}

.stat-card:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 4px;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.stat-label {
    color: var(--light-text);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Nav toggle button (mobile only) */
.nav-toggle {
    display: none;
    width: 100%;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    cursor: pointer;
    text-align: left;
    gap: 8px;
    align-items: center;
    margin-bottom: 0;
}
.nav-toggle i { margin-right: 6px; }

/* Pagination tabs (shared) */
.tbl-pag-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.sched-tab-btn { padding: 4px 12px; border: 1px solid var(--border-color, #ddd); border-radius: 4px; background: #fff; cursor: pointer; font-size: 0.85rem; }
.sched-tab-btn.active { background: var(--primary-color, #4CAF50); color: #fff; border-color: var(--primary-color, #4CAF50); }

/* FullCalendar list view inline detail (all screen sizes) */
.fc .fc-list-event-title a {
    display: block !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: unset !important;
    color: inherit;
    text-decoration: none;
}
.fc-list-inline-detail {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 4px 0;
}
.fc-list-inline-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
}
.fc-list-inline-meta {
    font-size: 0.88rem;
    color: #333;
    line-height: 1.5;
}

/* Responsive card-style table (mobile) */
@media (max-width: 768px) {
    /* FullCalendar list view mobile tweaks */
    .fc-list-event-title { font-size: 0.9rem; }
    .fc-list-day-cushion { font-size: 0.85rem; padding: 6px 10px; }
    .fc-list-event td { padding: 6px 10px; }
    /* Compact day header */
    .fc .fc-list-day-cushion {
        padding: 5px 8px;
        display: flex;
        justify-content: flex-start;
        gap: 6px;
    }
    .fc .fc-list-day-text,
    .fc .fc-list-day-side-text {
        font-size: 0.82rem;
    }
    /* Constrain FullCalendar to viewport on mobile */
    .fc {
        max-width: 100%;
        overflow: hidden;
    }
    .fc .fc-list-table {
        width: 100% !important;
        table-layout: fixed;
    }
    .fc .fc-list-day > td {
        max-width: 100vw;
        overflow: hidden;
    }
    /* List event time column */
    .fc .fc-list-event-time {
        white-space: nowrap;
        font-size: 0.9rem;
        font-weight: 600;
        width: 70px !important;
        min-width: 70px !important;
        max-width: 70px !important;
        padding: 8px 4px !important;
        vertical-align: top;
    }
    /* Title column — let inline detail expand */
    .fc .fc-list-event-title {
        font-size: 0.88rem;
        padding: 6px 4px !important;
        vertical-align: top;
    }
    /* Shrink the color dot column */
    .fc .fc-list-event-graphic {
        width: 14px !important;
        min-width: 14px !important;
        padding: 8px 2px !important;
        vertical-align: top;
    }
    .fc .fc-list-event-dot {
        width: 8px;
        height: 8px;
    }
    /* Custom event info in graphic column (replaces dot) */
    .fc-list-event-info {
        font-size: 0.75rem;
        font-weight: 600;
        color: #333;
        line-height: 1.2;
        white-space: normal;
        overflow: visible;
        word-wrap: break-word;
        max-width: 100px;
    }
    /* Give each list event row more breathing room */
    .fc .fc-list-event td {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }
    .responsive-card-table {
        min-width: unset !important;
    }
    .responsive-card-table thead {
        display: none;
    }
    .responsive-card-table tbody tr {
        display: block;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin-bottom: 6px;
        padding: 1px 0;
        background: white;
    }
    .responsive-card-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 6px;
        padding: 5px 8px;
        border-bottom: 1px solid var(--border-color);
        font-size: 0.8rem;
        min-width: unset !important;
        line-height: 1.3;
        word-break: break-word;
    }
    .responsive-card-table tbody td:last-child {
        border-bottom: none;
    }
    .responsive-card-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--light-text);
        font-size: 0.66rem;
        text-transform: uppercase;
        white-space: nowrap;
        flex-shrink: 0;
        padding-top: 2px;
    }
    .responsive-card-table .btn {
        padding: 5px 9px;
        font-size: 0.74rem;
    }
    .responsive-card-table tbody td > * {
        max-width: 100%;
    }
    .responsive-card-table tbody td[colspan] {
        justify-content: center;
    }
    .responsive-card-table tbody td[colspan]::before {
        display: none;
    }
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        display: flex;
        flex-direction: column;
        padding: 10px;
    }

    .container > .auth-bar {
        order: 1;
    }

    .container > nav {
        order: 2;
    }

    .container > header {
        order: 3;
    }

    .container > :not(.auth-bar):not(nav):not(header) {
        order: 4;
    }

    /* Header */
    header {
        padding: 15px;
        margin-bottom: 15px;
    }
    header h1 {
        font-size: 1.5rem;
    }
    header p {
        font-size: 0.9rem;
    }

    /* Auth bar */
    .auth-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 10px 14px;
        margin-bottom: 10px;
    }
    .auth-bar .btn {
        width: 100%;
        text-align: center;
    }

    /* Nav: collapsible hamburger */
    nav {
        padding: 10px;
        margin-bottom: 15px;
        position: relative;
    }
    nav ul {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        display: none;
    }
    nav ul.nav-open {
        display: flex;
    }
    nav a {
        display: block;
        width: 100%;
        text-align: center;
        padding: 12px 16px;
        border-radius: 8px;
        border: 1px solid var(--border-color);
    }
    .nav-toggle {
        display: flex !important;
        position: relative;
        top: -8px;
        margin-bottom: 2px;
    }

    /* Main content */
    .main-content {
        padding: 16px;
        margin-bottom: 15px;
    }
    .section-header {
        margin-bottom: 16px;
        padding-bottom: 10px;
    }
    .section-header h2 {
        font-size: 1.3rem;
    }

    /* Form containers */
    .form-container {
        padding: 14px;
        margin-bottom: 15px;
    }
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 1rem; /* prevent iOS zoom */
        padding: 10px 12px;
    }

    /* Buttons */
    .btn {
        padding: 12px 20px;
        font-size: 0.95rem;
    }
    .btn + .btn {
        margin-top: 6px;
    }

    /* Filter rows: stack vertically */
    .filter-row,
    .form-inline,
    .action-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }
    .filter-row .btn,
    .form-inline .btn,
    .action-bar .btn {
        width: 100%;
        text-align: center;
    }

    /* Quick filter chips: wrap nicely */
    .quick-filter-chips {
        gap: 6px;
    }
    .quick-filter-chip {
        padding: 7px 12px;
        font-size: 0.85rem;
    }

    /* Cards */
    .card-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .stat-number {
        font-size: 1.8rem;
    }

    /* Tables: horizontal scroll + compact cells */
    .table-container {
        border-radius: 6px;
    }
    table {
        min-width: 600px; /* force horizontal scroll rather than wrapping */
    }
    th, td {
        padding: 9px 10px;
        font-size: 0.82rem;
    }

    /* Pagination tabs */
    .tbl-pag-btns {
        gap: 4px;
        padding: 4px 0;
    }
    .sched-tab-btn {
        padding: 6px 12px;
        font-size: 0.82rem;
    }

    /* Attendance form */
    .attendance-section {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .container {
        padding: 8px;
    }
    header h1 {
        font-size: 1.25rem;
    }
    th, td {
        padding: 7px 8px;
        font-size: 0.78rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Utility classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }