/* ==========================================
   SCHOOL ADMIN DASHBOARD - STYLES
   SIBLINK School Management Dashboard
   ========================================== */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #F3F4F6;
    color: #374151;
    line-height: 1.5;
}

/* ==========================================
   LOGIN SCREEN
   ========================================== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2563EB 0%, #1E40AF 50%, #1E3A8A 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, #2563EB, #1E40AF);
    color: white;
    padding: 40px 32px;
    text-align: center;
}

.login-logo {
    font-size: 56px;
    display: block;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-header p {
    font-size: 14px;
    opacity: 0.9;
}

.login-form {
    padding: 32px;
}

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

.login-form .form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.login-form .form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.2s;
}

.login-form .form-group input:focus {
    outline: none;
    border-color: #2563EB;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 16px 24px;
    font-size: 16px;
}

.login-error {
    color: #DC2626;
    font-size: 14px;
    text-align: center;
    margin-top: 16px;
    min-height: 20px;
}

/* ==========================================
   APP LAYOUT
   ========================================== */
.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #2563EB 0%, #1E40AF 100%);
    color: white;
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    margin-bottom: 24px;
}

.logo-icon {
    font-size: 32px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
}

.nav {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: rgba(255,255,255,0.2);
    color: white;
    font-weight: 600;
}

.nav-icon {
    font-size: 20px;
}

.sidebar-footer {
    padding-top: 24px;
    border-top: 1px solid rgba(255,255,255,0.2);
}

.school-info {
    margin-bottom: 12px;
}

.school-name {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: white;
    margin-bottom: 4px;
}

.school-code {
    display: block;
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    font-family: monospace;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: rgba(255,255,255,0.8);
    margin-bottom: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #FCD34D;
}

.status-dot.connected {
    background: #10B981;
}

.status-dot.error {
    background: #EF4444;
}

.btn-logout {
    width: 100%;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    min-width: 0;
    overflow-x: hidden;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.header-right {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.subtitle {
    color: #6B7280;
    font-size: 14px;
}

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #2563EB, #1E40AF);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
    background: #F3F4F6;
    color: #374151;
}

.btn-secondary:hover {
    background: #E5E7EB;
}

.btn-danger {
    background: #EF4444;
    color: white;
}

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

.btn-success {
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-outline {
    background: white;
    color: #3B82F6;
    border: 1px solid #3B82F6;
}

.btn-outline:hover {
    background: #EFF6FF;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-icon {
    padding: 8px;
    border-radius: 8px;
    background: transparent;
}

.btn-icon:hover {
    background: #F3F4F6;
}

/* ==========================================
   CARDS
   ========================================== */
.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #E5E7EB;
}

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.card-subtitle {
    font-size: 14px;
    color: #6B7280;
}

.card-body {
    padding: 24px;
}

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

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-icon {
    font-size: 32px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #F3F4F6;
    border-radius: 12px;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
}

.stat-label {
    font-size: 14px;
    color: #6B7280;
}

/* ==========================================
   TABLES
   ========================================== */
.table-container {
    background: white;
    border-radius: 16px;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card .table-container {
    box-shadow: none;
    border-radius: 0;
}

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

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #E5E7EB;
    vertical-align: middle;
}

.data-table th {
    background: #F9FAFB;
    font-weight: 600;
    color: #6B7280;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
    background: #F9FAFB;
}

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

/* ==========================================
   FILTERS
   ========================================== */
.filters {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 200px;
}

.search-box input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: #2563EB;
}

.filter-group {
    display: flex;
    gap: 12px;
}

.filter-group select {
    padding: 12px 16px;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    min-width: 150px;
}

.filter-group select:focus {
    outline: none;
    border-color: #2563EB;
}

/* ==========================================
   BADGES
   ========================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.linked,
.status-badge.active {
    background: #D1FAE5;
    color: #065F46;
}

.status-badge.pending {
    background: #FEF3C7;
    color: #92400E;
}

.status-badge.inactive {
    background: #FEE2E2;
    color: #991B1B;
}

.status-badge.graduated {
    background: #DBEAFE;
    color: #1E40AF;
}

.grade-badge {
    display: inline-block;
    padding: 4px 10px;
    background: #EFF6FF;
    color: #2563EB;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}

.invite-code {
    font-family: monospace;
    font-size: 13px;
    background: #F3F4F6;
    padding: 4px 8px;
    border-radius: 6px;
    color: #374151;
}

/* ==========================================
   SECTION TABS
   ========================================== */
.section-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: white;
    padding: 6px;
    border-radius: 12px;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: #6B7280;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background: #F3F4F6;
    color: #374151;
}

.tab-btn.active {
    background: #DBEAFE;
    color: #2563EB;
}

/* ==========================================
   FORMS
   ========================================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2563EB;
}

.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
    background: #F9FAFB;
    color: #6B7280;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.input-hint {
    display: block;
    font-size: 12px;
    color: #9CA3AF;
    margin-top: 4px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #2563EB;
}

.days-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.days-checkboxes .checkbox-label {
    background: #F3F4F6;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s;
}

.days-checkboxes .checkbox-label:has(input:checked) {
    background: #DBEAFE;
    color: #2563EB;
}

/* Code Display */
.code-display {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #F3F4F6;
    padding: 12px 16px;
    border-radius: 12px;
    font-family: monospace;
    font-size: 16px;
    font-weight: 600;
}

.code-display span {
    flex: 1;
}

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

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

.modal {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    animation: modalIn 0.3s ease;
}

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

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

.modal.modal-large {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #E5E7EB;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #F3F4F6;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    color: #6B7280;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #E5E7EB;
    color: #374151;
}

.modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #E5E7EB;
    background: #F9FAFB;
}

/* ==========================================
   ALERTS
   ========================================== */
.alert {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.alert-warning {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FCD34D;
}

.alert-info {
    background: #DBEAFE;
    color: #1E40AF;
    border: 1px solid #93C5FD;
}

/* ==========================================
   LOADING & EMPTY STATES
   ========================================== */
.loading-cell {
    text-align: center;
    padding: 48px !important;
    color: #6B7280;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #E5E7EB;
    border-top-color: #2563EB;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

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

.empty-state {
    text-align: center;
    padding: 64px 32px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    color: #374151;
    margin-bottom: 8px;
}

.empty-state p {
    color: #6B7280;
    font-size: 14px;
}

/* ==========================================
   TOAST
   ========================================== */
.toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    background: #374151;
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 2000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: #059669;
}

.toast.error {
    background: #DC2626;
}

.toast-icon {
    font-size: 20px;
}

/* ==========================================
   SETTINGS PAGE
   ========================================== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
}

.bulk-action-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #F9FAFB;
    border-radius: 12px;
    margin-bottom: 12px;
}

.bulk-action-item:last-child {
    margin-bottom: 0;
}

.bulk-action-info h4 {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
}

.bulk-action-info p {
    font-size: 13px;
    color: #6B7280;
}

/* ==========================================
   STUDENT DETAIL
   ========================================== */
.student-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.student-detail-info h3,
.student-detail-stats h3,
.student-detail-activities h3 {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #E5E7EB;
}

.detail-item {
    display: flex;
    margin-bottom: 12px;
}

.detail-label {
    font-weight: 500;
    color: #6B7280;
    width: 100px;
    flex-shrink: 0;
}

.mini-stats {
    display: flex;
    gap: 16px;
}

.mini-stat {
    flex: 1;
    text-align: center;
    padding: 16px;
    background: #F9FAFB;
    border-radius: 12px;
}

.mini-stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #2563EB;
    margin-bottom: 4px;
}

.mini-stat-label {
    font-size: 12px;
    color: #6B7280;
}

/* ==========================================
   PREVIEW BOX
   ========================================== */
.preview-box {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}

.preview-box p {
    color: #6B7280;
    font-size: 14px;
}

/* ==========================================
   ACTION BUTTONS
   ========================================== */
.action-buttons {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.action-btn.view {
    background: #DBEAFE;
    color: #2563EB;
}

.action-btn.view:hover {
    background: #BFDBFE;
}

.action-btn.edit {
    background: #FEF3C7;
    color: #D97706;
}

.action-btn.edit:hover {
    background: #FDE68A;
}

.action-btn.delete {
    background: #FEE2E2;
    color: #DC2626;
}

.action-btn.delete:hover {
    background: #FECACA;
}

/* ==========================================
   TEXT UTILITIES
   ========================================== */
.text-center {
    text-align: center;
}

.text-muted {
    color: #6B7280;
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        padding: 16px;
    }

    .logo-text,
    .nav-item span:not(.nav-icon),
    .school-info,
    .connection-status span:not(.status-dot) {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .main-content {
        margin-left: 80px;
    }

    .btn-logout span {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .header {
        flex-direction: column;
        gap: 16px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .filter-group {
        flex-direction: column;
        width: 100%;
    }

    .filter-group select {
        width: 100%;
    }

    .stats-cards {
        grid-template-columns: 1fr 1fr;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .student-detail-grid {
        grid-template-columns: 1fr;
    }

    .section-tabs {
        flex-wrap: wrap;
        width: 100%;
    }

    .tab-btn {
        flex: 1;
        min-width: calc(33.33% - 8px);
        text-align: center;
    }
}

/* ==========================================
   LOGIN TABS & REGISTRATION
   ========================================== */
.login-tabs {
    display: flex;
    border-bottom: 2px solid #E5E7EB;
}

.login-tab {
    flex: 1;
    padding: 16px;
    background: #F9FAFB;
    border: none;
    font-size: 14px;
    font-weight: 600;
    color: #6B7280;
    cursor: pointer;
    transition: all 0.2s;
}

.login-tab:first-child {
    border-top-left-radius: 0;
}

.login-tab:last-child {
    border-top-right-radius: 0;
}

.login-tab:hover {
    background: #F3F4F6;
    color: #374151;
}

.login-tab.active {
    background: white;
    color: #2563EB;
    border-bottom: 2px solid #2563EB;
    margin-bottom: -2px;
}

/* Invite Code Section */
.invite-code-section {
    margin-bottom: 20px;
}

.invite-info-box {
    background: linear-gradient(135deg, #D1FAE5, #A7F3D0);
    border: 1px solid #10B981;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    text-align: center;
}

.input-hint {
    font-size: 12px;
    color: #6B7280;
    margin-top: 6px;
}

/* Registration Fields Animation */
#registrationFields {
    animation: slideDown 0.3s ease;
}

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

/* ==========================================
   WALI KELAS LINK STYLES
   ========================================== */
.link-display {
    display: flex;
    gap: 8px;
    align-items: center;
}

.link-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    font-size: 12px;
    background: #F9FAFB;
    color: #374151;
    min-width: 0;
}

.link-input:focus {
    outline: none;
    border-color: #2563EB;
}

/* Responsive adjustments for wali kelas table */
@media (max-width: 768px) {
    .link-input {
        max-width: 150px;
    }
}
