
/* --- Teacher Data Table Premium Styling --- */
#teachers-table {
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(226, 232, 240, 0.8);
    margin-top: 10px;
}

#teachers-table thead th {
    background: #f8fafc;
    color: #475569;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 16px;
    border-bottom: 2px solid #e2e8f0;
}

#teachers-table tbody tr {
    transition: all 0.2s ease;
}

#teachers-table tbody tr:hover {
    background-color: #f1f5f9;
    transform: scale(1.002);
}

.name-primary {
    font-weight: 800;
    color: #1e293b;
    font-size: 1rem;
    /* Prevent wrapping & add ellipsis */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 280px; /* Constrain to prevent pushed layout */
    transition: color 0.2s ease;
}

.badge-grade-inline {
    background: #eff6ff;
    color: #3b82f6;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 800;
    margin-right: 6px;
    border: 1px solid #dbeafe;
    flex-shrink: 0;
}

/* ── Flexible Table Layout — Fix Wrapping ────────────────────── */
#teachers-table {
    display: block;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 12px;
}

#teachers-table thead, 
#teachers-table tbody {
    display: block;
    width: 100%;
}

#teachers-table tr {
    display: flex;
    align-items: center;
    width: 100%;
    background: white;
    border-radius: 14px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

/* Column Flex Ratios */
#teachers-table th, 
#teachers-table td {
    display: flex;
    align-items: center;
    padding: 16px 12px;
    overflow: hidden;
    flex: 1; /* Default equal share */
}

/* 1. Checkbox Column (Fixed Small) */
#teachers-table th:nth-child(1),
#teachers-table td:nth-child(1) {
    flex: 0 0 50px;
    justify-content: center;
}

/* 2. Name Column (Highest Priority - Flexible) */
#teachers-table th:nth-child(2),
#teachers-table td:nth-child(2) {
    flex: 2.5; 
    min-width: 180px;
    font-weight: 700;
}

/* 3. Subject & 4. Classes (Medium Priority) */
#teachers-table th:nth-child(3),
#teachers-table td:nth-child(3),
#teachers-table th:nth-child(4),
#teachers-table td:nth-child(4) {
    flex: 1.5;
    min-width: 120px;
}

/* 5. Leadership, 6. Phone, 7. Email (Lower Priority) */
#teachers-table th:nth-child(5),
#teachers-table td:nth-child(5),
#teachers-table th:nth-child(6),
#teachers-table td:nth-child(6),
#teachers-table th:nth-child(7),
#teachers-table td:nth-child(7),
#teachers-table th:nth-child(8),
#teachers-table td:nth-child(8) {
    flex: 1.2;
    min-width: 100px;
    font-size: 0.85rem;
    color: #64748b;
}

/* 9. Action Buttons (Fixed Width - No Shrink) */
#teachers-table th:nth-child(9),
#teachers-table td:nth-child(9) {
    flex: 0 0 160px;
    justify-content: flex-start;
}

/* Vertically center all badges/icons in cells */
.modern-badge {
    flex-shrink: 0;
    white-space: nowrap;
}

/* ── Action Buttons — Professional Icon Set ──────────────────── */
.action-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-start;
}

.btn-action-modern {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(226, 232, 240, 0.8);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: #ffffff;
    color: #64748b;
    outline: none;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.btn-action-modern:hover {
    transform: translateY(-2px);
}

.btn-action-modern:active {
    transform: scale(0.93);
    transition-duration: 0.08s;
}

/* Edit — blue accent */
.btn-action-modern.edit {
    background: #eff6ff;
    color: #3b82f6;
    border-color: #bfdbfe;
}
.btn-action-modern.edit:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

/* Delete — red accent */
.btn-action-modern.delete {
    background: #fff5f5;
    color: #ef4444;
    border-color: #fecaca;
}
.btn-action-modern.delete:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

/* Insight — purple accent */
.btn-action-modern.insight {
    background: #f5f3ff;
    color: #8b5cf6;
    border-color: #ddd6fe;
}
.btn-action-modern.insight:hover {
    background: #8b5cf6;
    color: white;
    border-color: #8b5cf6;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
}

/* WhatsApp — green accent */
.btn-action-modern.whatsapp {
    background: #f0fdf4;
    color: #22c55e;
    border-color: #bbf7d0;
}
.btn-action-modern.whatsapp:hover {
    background: #22c55e;
    color: white;
    border-color: #22c55e;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.3);
}

/* ── Modal Compact Scroll Fix ───────────────────────────────── */
/* Apply to ALL data modals: teacher, subject, class */
#teacher-modal,
#subject-modal,
#class-modal {
    align-items: center;
    padding: 16px 0;
}

#teacher-modal .modal-content,
#subject-modal .modal-content,
#class-modal .modal-content {
    max-width: 480px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

/* Modal inner header (title + close btn) stays fixed at top */
#teacher-modal .modal-content > .close-btn,
#subject-modal .modal-content > .close-btn,
#class-modal .modal-content > .close-btn {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 10;
}

#teacher-modal .modal-content > h2,
#subject-modal .modal-content > h2,
#class-modal .modal-content > h2 {
    flex-shrink: 0;
    margin: 0;
    padding: 22px 26px 16px;
    font-size: 1.2rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.07);
}

/* The form becomes the scrollable body */
#teacher-form,
#subject-form,
#class-form {
    flex: 1;
    overflow-y: auto;
    padding: 18px 26px 22px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

#teacher-form::-webkit-scrollbar,
#subject-form::-webkit-scrollbar,
#class-form::-webkit-scrollbar {
    width: 4px;
}
#teacher-form::-webkit-scrollbar-track,
#subject-form::-webkit-scrollbar-track,
#class-form::-webkit-scrollbar-track {
    background: transparent;
}
#teacher-form::-webkit-scrollbar-thumb,
#subject-form::-webkit-scrollbar-thumb,
#class-form::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Tighter form group spacing inside modal */
#teacher-form .form-group,
#subject-form .form-group,
#class-form .form-group {
    margin-bottom: 10px;
}

/* Submit button: sticky at bottom of scroll area */
#teacher-form button[type="submit"],
#subject-form button[type="submit"],
#class-form button[type="submit"] {
    position: sticky;
    bottom: -5px; /* Stick perfectly at bottom */
    margin-top: 14px;
    border-radius: 12px;
    padding: 13px;
    font-size: 1rem;
    z-index: 10;
    box-shadow: 0 -8px 20px rgba(255, 255, 255, 0.95);
    transform: translateY(-5px); /* Visual padding */
}

/* --- Data Tab Header & Controls Polish --- */
.setup-step-content {
    animation: fadeIn 0.5s ease-out;
}

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

.data-tab-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(226, 232, 240, 0.6);
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.section-header-modern {
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-header-modern h3 {
    font-size: 1.4rem;
    font-weight: 900;
    color: #1e293b;
    margin: 0;
}

.section-icon-wrap {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #3b82f6;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* Search Input Polish */
.search-wrapper-modern {
    position: relative;
    width: 100%;
    max-width: 300px;
}

.search-wrapper-modern input {
    width: 100%;
    padding: 12px 45px 12px 15px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.search-wrapper-modern input:focus {
    background: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    outline: none;
}

.search-icon-fixed {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

/* Add Button Polish */
.btn-add-modern {
    background: linear-gradient(135deg, #1a237e, #0d47a1);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 15px rgba(26, 35, 126, 0.2);
}

.btn-add-modern:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(26, 35, 126, 0.4);
}

.btn-add-modern {
    white-space: nowrap !important;
}

/* Modal Visibility Fix - Ensure it comes above everything */
.modal.show {
    display: flex !important;
    z-index: 99999 !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

.modal.hidden {
    display: none !important;
}

.btn-add-modern i {
    font-size: 1.1rem;
}
