/* ========== Dashboard-Specific Variables ========== */
:root {
    /* Classroom Colors */
    --mountain-laurel: #8BC34A;
    --mountain-laurel-light: #c8e6c9;
    --mountain-laurel-morning: #e8f5e9;
    --mountain-laurel-extended: #c8e6c9;
    --magnolia: #2196F3;
    --magnolia-light: #bbdefb;
    --magnolia-morning: #e3f2fd;
    --magnolia-extended: #bbdefb;
    --elementary: #F5A623;
    --elementary-light: #fff3c8;
    --elementary-bg: #fff8e1;
    --after-school-red: #ee5555;
    --after-school-bg: #fce4ec;

    /* Student Card Colors */
    --male-blue: #64B5F6;
    --female-pink: #F48FB1;
    --locked-grey: #e0e0e0;

    /* Payment Plan Colors */
    --discounted-purple: #8e44ad;
    --installments-orange: #e67e22;
}

/* ========== Dashboard-Specific Overrides ========== */
html,
body {
    height: 100vh;
    overflow: hidden;
}

/* ========== Dashboard-Specific Buttons ========== */
.btn-save {
    background: #bbdefb;
    color: var(--primary-blue);
}

.btn-save:hover {
    background: #86c9ff;
}

.btn-small {
    height: 36px;
    padding: 0 12px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* btn-sign-contract moved to end of file */

.btn-auto-assign {
    background: var(--success-green);
    color: white;
    width: 100%;
    margin-bottom: 10px;
    border: none;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.btn-auto-assign:hover {
    background: #218838;
}

/* ========== Toolbar ========== */
.toolbar {
    background: white;
    padding: 15px 25px;
    display: flex;
    gap: 15px;
    align-items: center;
    border-bottom: 1px solid var(--border-grey);
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    max-width: 300px;
    padding: 10px 15px;
    border: 1px solid var(--border-grey);
    border-radius: 4px;
    font-size: 14px;
}

.search-box:focus {
    outline: none;
    border-color: var(--primary-blue);
}

.filter-select,
.data-source-select {
    padding: 10px 15px;
    border: 1px solid var(--border-grey);
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.data-source-select {
    min-width: 200px;
}

.loading-indicator {
    display: none;
    color: var(--text-medium);
    font-size: 14px;
}

.loading-indicator.show {
    display: block;
}

/* ========== Main Dashboard ========== */
.dashboard {
    display: flex;
    gap: 15px;
    padding: 20px;
    overflow: auto;
    height: calc(100vh - 140px);
}

/* ========== Columns ========== */
.column {
    flex: 1;
    min-width: 280px;
    max-width: 350px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
}


.column-header {
    padding: 15px;
    border-radius: 8px 8px 0 0;
    color: white;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.column-header .title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.column-header .capacity {
    font-size: 12px;
    opacity: 0.9;
}

.column.unassigned .column-header {
    background: var(--text-medium);
}

.column.mountain-laurel .column-header {
    background: var(--mountain-laurel);
}

.column.magnolia .column-header {
    background: var(--magnolia);
}

.column.elementary .column-header {
    background: var(--elementary);
    color: var(--text-dark);
}

.column.after-school .column-header {
    background: var(--after-school-red);
}

/* Dynamic height for unassigned and after-school columns */
.column.unassigned,
.column.after-school {
    align-self: flex-start;
    max-height: calc(100vh - 180px);
}

.column.unassigned .column-content,
.column.after-school .column-content {
    flex: none;
    min-height: auto;
}

.column-content {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    min-height: 200px;
}

.column-content.drag-over {
    background: #e3f2fd;
}

.empty-state {
    text-align: center;
    padding: 30px 15px;
    color: var(--text-medium);
    font-size: 14px;
}

/* ========== Schedule Groups ========== */
.schedule-group {
    margin-bottom: 15px;
    border-radius: 6px;
    padding: 10px;
    min-height: 80px;
    transition: background 0.2s;
}

.schedule-group.drag-over {
    outline: 2px dashed var(--primary-blue);
    outline-offset: -2px;
}

.schedule-group.morning {
    background: var(--mountain-laurel-morning);
}

.schedule-group.extended {
    background: var(--mountain-laurel-extended);
}

.schedule-group.elementary-group {
    background: var(--elementary-bg);
}

.schedule-group.afterschool-group {
    background: var(--after-school-bg);
}

.column.magnolia .schedule-group.morning {
    background: var(--magnolia-morning);
}

.column.magnolia .schedule-group.extended {
    background: var(--magnolia-extended);
}

.schedule-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-medium);
}

.schedule-group-header .bar {
    width: 60px;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    overflow: hidden;
}

.schedule-group-header .bar-fill {
    height: 100%;
    background: var(--success-green);
    transition: width 0.3s;
}

.schedule-group-header .bar-fill.warning {
    background: #ffc107;
}

.schedule-group-header .bar-fill.full {
    background: var(--error-red);
}

/* ========== Student Cards ========== */
.student-card {
    background: white;
    border: 1px solid var(--border-grey);
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all 0.2s;
    overflow: hidden;
}

.student-card:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.student-card.locked {
    background: var(--locked-grey);
    cursor: default;
}

.student-card.dragging {
    opacity: 0.5;
    transform: rotate(3deg);
}

.student-card.expanded {
    border-color: var(--primary-blue);
}

.card-simple {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lock-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 2px;
}

.student-name {
    font-weight: 500;
    flex: 1;
}

.student-age {
    font-size: 12px;
    color: var(--text-medium);
}

/* ========== Icon Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.badge.non-interactive {
    cursor: default;
}

.badge-sex.male {
    background: var(--male-blue);
    color: white;
}

.badge-sex.female {
    background: var(--female-pink);
    color: white;
}

.badge-schedule {
    font-size: 14px;
    background: #fff3e0;
    width: auto;
    padding: 0 6px;
}

.badge-schedule:hover {
    background: #ffe0b2;
}

.badge-schedule.non-interactive:hover {
    background: #fff3e0;
}

.badge-afterschool {
    background: white;
    color: var(--after-school-red);
    border: 2px solid var(--after-school-red);
}

.badge-afterschool.selected {
    background: var(--after-school-red);
    color: white;
}

/* ========== Card Details (Expanded) ========== */
.card-details {
    display: none;
    padding: 12px;
    background: #fafafa;
    border-top: 1px solid var(--border-grey);
    font-size: 13px;
}

.student-card.expanded .card-details {
    display: block;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.detail-label {
    color: var(--text-medium);
}

.detail-value {
    font-weight: 500;
}

.detail-value.discounted {
    color: var(--discounted-purple);
}

/* Program Colors (darker for text) */
.detail-value.primary-morning {
    color: #00838f;
    /* Darker cyan */
}

.detail-value.primary-extended {
    color: #d84315;
    /* Darker orange */
}

.detail-value.elementary {
    color: #f57f17;
    /* Darker yellow */
}

/* Status Colors (darker for text) */
.detail-value.status-pending-agreement {
    color: #e65100;
    /* Darker orange for pending agreement */
}

.detail-value.status-pending-payment {
    color: #d84315;
    /* Darker peach/orange */
}

.detail-value.status-paid {
    color: #2e7d32;
    /* Darker green */
}

.detail-value.status-enrolled {
    color: #1b5e20;
    /* Even darker green */
}

.detail-value.status-failed {
    color: #c62828;
    /* Darker red */
}

.detail-value.installments {
    color: var(--installments-orange);
}

.returning-badge {
    color: #f9a825;
    font-size: 14px;
}

/* ========== After School Remove Button ========== */
.remove-afterschool-btn {
    background: var(--error-red);
    border: none;
    color: white;
    font-size: 10px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: auto;
}

.remove-afterschool-btn:hover {
    background: #c0392b;
}

/* ========== Custom Modal ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: 8px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal.small {
    max-width: 400px;
}

.modal-header {
    background: var(--primary-blue);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.modal-actions {
    padding: 10px 20px;
    background: #f5f5f5;
    display: flex;
    gap: 10px;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-body p {
    margin-bottom: 15px;
    line-height: 1.5;
}

.modal-footer {
    padding: 15px 20px;
    background: #f5f5f5;
    display: flex;
    justify-content: center;
    /* Centered */
    gap: 10px;
}

.modal-footer.center {
    justify-content: center;
}

/* ... existing styles ... */

.modal-footer .btn-primary {
    background: #4CAF50;
    /* Green */
    color: white;
}

.modal-footer .btn-primary:hover {
    background: #45a049;
}

.contracts-table {
    width: 100%;
    border-collapse: collapse;
}

.contracts-table th,
.contracts-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-grey);
}

.contracts-table th {
    background: #f5f5f5;
    font-weight: 600;
    font-size: 13px;
}

.contracts-table tr:hover {
    background: #fafafa;
}

.btn-finalize {
    background: var(--success-green);
    color: white;
    padding: 12px 30px;
    font-size: 16px;
}

.btn-finalize:hover {
    background: #218838;
}

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

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

.btn-cancel {
    background: #6c757d;
    color: white;
}

.btn-cancel:hover {
    background: #5a6268;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 10px;
    }

    .toolbar {
        flex-wrap: wrap;
    }

    .dashboard {
        flex-direction: column;
    }

    .column {
        max-width: 100%;
    }
}

/* ========== View Toggles ========== */
.view-toggles {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 0 auto;
}

.view-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-grey);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.view-btn.active {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

/* ========== Table View ========== */
.hidden {
    display: none !important;
}

.table-view {
    padding: 20px 60px;
    /* increased padding to make rows stand out */
    flex: 1;
    overflow: auto;
    background: #e3f2fd;
    margin: 0;
    height: calc(100vh - 140px);
}

.student-row.locked td {
    background-color: var(--locked-grey) !important;
}

/* ========== Table View Reform ========== */
.student-table {
    width: 100%;
    border-collapse: separate;
    /* Required for border-radius on rows/cells */
    border-spacing: 0;
    margin-top: 10px;
}

.student-table th {
    padding: 12px 15px;
    text-align: left;
    background: #f1f4f3;
    font-weight: 600;
    color: var(--text-dark);
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid #e2e8e7;
}

.student-table td {
    padding: 10px 15px;
    vertical-align: middle;
    background: white;
    /* Default background for cells */
}

/* Family Group Styles */
.student-row td {
    border-top: 1px solid #eee;
    background: #ffffff;
}

/* Rounded Corners & Borders for Family Groups */
.family-first td:first-child {
    border-top-left-radius: 12px;
    border-left: 1px solid #eee;
}

.family-first td:last-child {
    border-top-right-radius: 12px;
    border-right: 1px solid #eee;
}

.family-last td:first-child {
    border-bottom-left-radius: 12px;
    border-left: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.family-last td:last-child {
    border-bottom-right-radius: 12px;
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

/* Side borders for middle rows */
.student-row:not(.family-first) td:first-child {
    border-left: 1px solid #eee;
}

.student-row:not(.family-first) td:last-child {
    border-right: 1px solid #eee;
}

.student-row:not(.family-last) td {
    border-bottom: 1px solid #f9f9f9;
    /* Lighter internal separator */
}

/* Top border for first row */
.family-first td {
    border-top: 1px solid #eee;
}

/* Hover effect on the entire family group row */
.student-row:hover td {
    background-color: #f8fcfd;
}

/* Family Separator */
.family-separator {
    height: 10px;
    /* Space between families */
}

.family-separator td {
    padding: 0;
    border: none;
    background: transparent;
}

/* Section Divider for Pending/Enrolled Groups */
.section-divider td {
    padding: 20px 15px 10px 15px;
    background: #e3f2fd;
    border: none;
    font-size: 16px;
    color: var(--text-dark);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-divider.enrolled td {
    padding-top: 30px;
}

/* Student Name Cell optimization */
.student-name-cell {
    display: flex;
    flex-direction: column;
}

.family-label {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
    font-weight: normal;
}

/* Status Cell */
.status-cell {
    font-size: 13px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    background: #f5f5f5;
    cursor: pointer;
}

.status-cell:hover {
    background: #e0e0e0;
}

.sortable {
    cursor: pointer;
    user-select: none;
}

.sortable:hover {
    background: #e9ecef;
}

/* ========== Chip Menu & Interactive Chips ========== */
.chip {
    min-width: 120px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 25px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    /* Regular weight */
    cursor: pointer;
    border: none;
    transition: opacity 0.2s;
    background: #eee;
    color: #000;
    /* Force Black */
}

.chip:hover {
    opacity: 0.9;
}

/* --- Status Colors (Image 1) --- */
.chip-status-pending-agreement {
    background: #ffe0b2;
}

.chip-status-pending-payment {
    background: #ffccbc;
}

.chip-status-paid {
    background: #c8e6c9;
}

.chip-status-enrolled {
    background: #81c784;
}

.chip-status-failed {
    background: #ffcdd2;
}

/* --- Payment Plan Colors (Image 2) --- */
/* Discounted: Purple */
.chip-payment-discounted {
    background: #d1c4e9;
}

/* Installments: Peach/Orange */
.chip-payment-installments {
    background: #ffccbc;
}

.chip-payment-standard {
    background: #f5f5f5;
}

/* --- Program Colors (Image 3) --- */
/* Primary Morning: Cyan/Teal */
.chip-program-primary-morning {
    background: #b2ebf2;
}

/* Primary Extended: Peach/Orange (same as installments roughly) */
.chip-program-primary-extended {
    background: #ffccbc;
}

/* Elementary: Yellow */
.chip-program-elementary,
.chip-program-elementary-full {
    background: #fff9c4;
}

/* --- Classroom Colors (Image 4) --- */
/* Unassigned: Grey */
.chip-classroom-unassigned {
    background: #e0e0e0;
}

/* Mountain Laurel: Green */
.chip-classroom-mountain-laurel {
    background: #c8e6c9;
}

/* Magnolia: Light Blue */
.chip-classroom-magnolia {
    background: #bbdefb;
}

/* Elementary: Yellow (Matches Program) */
.chip-classroom-elementary {
    background: #fff9c4;
}

/* Dropdown Menu */
.chip-menu {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px;
    list-style: none;
    z-index: 1000;
    min-width: 196px;
}

.chip-menu.hidden {
    display: none;
}

/* ========== Menu Item Styles (Synced with Chips) ========== */
/* Base Menu Item Style */
.chip-menu li {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    /* Regular weight */
    border-radius: 6px;
    margin-bottom: 4px;
    color: #000;
    /* Black text */
    transition: filter 0.2s;
}

.chip-menu li:last-child {
    margin-bottom: 0;
}

.chip-menu li:hover {
    filter: brightness(0.95);
}

/* Menu Item Colors (Exact Match to Chips) */
.menu-item-unassigned {
    background: #e0e0e0;
}

.menu-item-mountain-laurel {
    background: #c8e6c9;
}

.menu-item-magnolia {
    background: #bbdefb;
}

.menu-item-elementary {
    background: #fff9c4;
}

.menu-item-primary-morning {
    background: #b2ebf2;
}

.menu-item-primary-extended {
    background: #ffccbc;
}

.menu-item-program-elementary {
    background: #fff9c4;
}

.menu-item-standard {
    background: #f5f5f5;
}

.menu-item-discounted {
    background: #d1c4e9;
}

.menu-item-installments {
    background: #ffccbc;
}

/* Status Menu Colors (Exact Match) */
.menu-item-status-pending {
    background: #ffe0b2;
}

.menu-item-status-pending-payment {
    background: #ffccbc;
}

.menu-item-status-paid {
    background: #c8e6c9;
}

.menu-item-status-enrolled {
    background: #81c784;
}

.menu-item-status-failed {
    background: #ffcdd2;
}

/* ========== Loading Overlay ========== */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-size: 16px;
    font-weight: 500;
    color: var(--primary-blue);
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== Family Card View ========== */
.family-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    padding: 20px;
}

.family-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    /* Premium shadow */
    overflow: hidden;
    transition: transform 0.2s ease;
    border: 1px solid var(--border-grey);
}

.family-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.family-header {
    padding: 15px;
    background: linear-gradient(to right, #f8f9fa, #ffffff);
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.family-title h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #2c3e50;
    font-weight: 700;
}

.family-email {
    display: block;
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-top: 4px;
}

.family-body {
    padding: 0;
}

.family-student-row {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.family-student-row:last-child {
    border-bottom: none;
}

/* Row Layouts */
.family-student-row .student-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.family-student-row .student-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.family-student-row .student-meta {
    font-size: 0.8rem;
    color: #999;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
}

.family-student-row .student-program {
    display: flex;
    gap: 8px;
}

/* Action Buttons in Card */
.btn-sign-contract {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    border: none;
    padding: 0 25px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(39, 174, 96, 0.3);
    transition: all 0.2s;
    min-width: 120px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-sign-contract:hover {
    /* Animation removed */
}

.status-badge.enrolled {
    background: #e8f8f5;
    color: #27ae60;
    min-width: 120px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 25px;
    border-radius: 6px;
    /* Match chip border-radius */
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid #abebc6;
}

.status-text-muted {
    font-size: 0.75rem;
    color: #bdc3c7;
    font-style: italic;
}