/* ===== CSS Variables ===== */
:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --primary-bg: #eff6ff;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --sidebar-width: 280px;
    --transition: 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== Modal ===== */
.modal {
    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;
    backdrop-filter: blur(4px);
}
.modal.active { display: flex; }

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 480px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

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

.modal-icon {
    width: 56px; height: 56px;
    background: var(--primary-bg);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}
.modal-icon .material-icons-outlined { color: var(--primary); font-size: 28px; }

.modal-content h2 { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.modal-content > p { color: var(--gray-500); font-size: 14px; margin-bottom: 20px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ===== App Layout ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 10;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
}
.logo-images {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.brand-logo {
    height: 48px;
    width: auto;
    max-width: 105px;
    object-fit: contain;
}
.logo-title {
    line-height: 1.2;
    letter-spacing: 0.01em;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--gray-600);
    transition: all var(--transition);
    position: relative;
}
.nav-item:hover { background: var(--gray-50); color: var(--gray-800); }
.nav-item.active { background: var(--primary-bg); color: var(--primary); }
.nav-item.completed .nav-number { background: var(--success); color: white; }

.nav-number {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--gray-200);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
    transition: all var(--transition);
}
.nav-item.active .nav-number { background: var(--primary); color: white; }

.nav-label { font-size: 14px; font-weight: 500; }

.nav-status {
    margin-left: auto;
    font-size: 18px;
}
.nav-item.completed .nav-status::before { content: 'check_circle'; color: var(--success); }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--gray-200);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px 40px;
    max-width: 1200px;
}

/* ===== Step Panels ===== */
.step-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}
.step-panel.active { display: block; }

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

.step-header {
    margin-bottom: 24px;
}
.step-header h1 {
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--gray-900);
}
.step-header h1 .material-icons-outlined {
    color: var(--primary);
    font-size: 28px;
}
.step-header p {
    color: var(--gray-500);
    margin-top: 4px;
    font-size: 15px;
}

/* ===== Form Card ===== */
.form-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}
.form-row:last-child { margin-bottom: 0; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.required { color: var(--danger); }

.form-group input[type="text"],
.form-group input[type="password"] {
    padding: 10px 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    transition: all var(--transition);
    outline: none;
}
.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.field-hint {
    font-size: 12px;
    color: var(--gray-400);
}

.radio-group {
    display: flex;
    gap: 20px;
    padding-top: 6px;
}
.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 400 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    color: var(--gray-700);
}
.radio-label input[type="radio"] {
    accent-color: var(--primary);
}

.hint {
    font-size: 12px;
    color: var(--gray-400);
}

.remember-api-key {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 14px;
    color: var(--gray-700);
    cursor: pointer;
}
.remember-api-key input {
    accent-color: var(--primary);
}

.kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    font-family: inherit;
    font-weight: 600;
    line-height: 1.4;
    color: var(--primary-dark);
    background-color: var(--primary-bg);
    border: 1px solid #bfdbfe;
    border-radius: 4px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}

/* ===== Step Actions ===== */
.step-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.btn .material-icons-outlined { font-size: 18px; }

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: var(--gray-300); cursor: not-allowed; }

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #15803d; }

.btn-ghost {
    background: transparent;
    color: var(--gray-500);
    padding: 8px 12px;
}
.btn-ghost:hover { background: var(--gray-50); color: var(--gray-700); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    padding: 4px 8px;
    font-size: 13px;
}
.btn-danger:hover { background: var(--danger-bg); }

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* ===== Upload Zone ===== */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
}
.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.upload-icon .material-icons-outlined {
    font-size: 48px;
    color: var(--gray-400);
}
.upload-zone:hover .upload-icon .material-icons-outlined,
.upload-zone.dragover .upload-icon .material-icons-outlined {
    color: var(--primary);
}

.upload-zone h3 {
    margin-top: 12px;
    font-size: 16px;
    color: var(--gray-700);
}
.upload-zone p { font-size: 14px; color: var(--gray-500); margin-top: 4px; }
.upload-zone a { color: var(--primary); font-weight: 600; }

/* ===== Image Preview Grid ===== */
.image-preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}

.image-preview-item {
    position: relative;
    width: 140px;
    height: 100px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--gray-200);
    transition: border-color var(--transition);
}
.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.image-preview-item .remove-btn {
    position: absolute;
    top: 4px; right: 4px;
    width: 24px; height: 24px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transition: opacity var(--transition);
}
.image-preview-item:hover .remove-btn { opacity: 1; }
.image-preview-item.matched { border-color: var(--success); }
.image-preview-item.unmatched { border-color: var(--warning); }

/* ===== Processing Indicator ===== */
.processing-indicator {
    text-align: center;
    padding: 32px;
    margin-top: 20px;
}
.processing-indicator p { color: var(--gray-600); margin-top: 12px; }

.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--gray-200);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar {
    width: 300px;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    margin: 12px auto 0;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

/* ===== Results Section ===== */
.results-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}
.results-section h3 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.results-section h3 .material-icons-outlined { color: var(--primary); font-size: 20px; }

.results-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* ===== Extracted List ===== */
.extracted-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.extracted-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    transition: all var(--transition);
}
.extracted-item:hover { background: var(--primary-bg); border-color: var(--primary-light); }

.extracted-item .item-number {
    width: 28px; height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.extracted-item .item-name {
    flex: 1;
    font-weight: 500;
    font-size: 14px;
}

.extracted-item .item-company {
    color: var(--gray-500);
    font-size: 13px;
}

.extracted-item .item-actions {
    display: flex;
    gap: 4px;
}

.extracted-item input.edit-name {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--primary);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
}

/* ===== Matched Section ===== */
.matched-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.match-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    background: white;
}

.match-item.matched {
    border-color: #86efac;
    background: var(--success-bg);
}
.match-item.missing {
    border-color: #fde68a;
    background: var(--warning-bg);
}

.match-icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.match-item.matched .match-icon { background: #dcfce7; color: var(--success); }
.match-item.missing .match-icon { background: #fef3c7; color: var(--warning); }

.match-info { flex: 1; }
.match-info .match-name { font-weight: 600; font-size: 14px; }
.match-info .match-details { font-size: 13px; color: var(--gray-500); margin-top: 2px; }

/* ===== Warnings Section ===== */
.warnings-section {
    margin-top: 16px;
    padding: 16px;
    background: var(--warning-bg);
    border: 1px solid #fde68a;
    border-radius: var(--radius);
}
.warnings-section h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--warning);
    font-size: 14px;
    margin-bottom: 8px;
}
.warnings-section ul {
    list-style: none;
    padding: 0;
}
.warnings-section li {
    padding: 4px 0;
    font-size: 13px;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 6px;
}
.warnings-section li::before {
    content: '⚠️';
}

/* ===== Preview Table ===== */
.preview-card { overflow-x: auto; }

.preview-header {
    margin-bottom: 24px;
    text-align: center;
}
.preview-header h2 {
    font-size: 20px;
    color: var(--gray-900);
    margin-bottom: 12px;
}
.preview-info {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 32px;
    justify-content: center;
    font-size: 14px;
    color: var(--gray-600);
}

.table-container { overflow-x: auto; }

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.preview-table th {
    background: var(--gray-800);
    color: white;
    padding: 10px 8px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    font-size: 12px;
    text-transform: uppercase;
}
.preview-table td {
    padding: 8px;
    border: 1px solid var(--gray-200);
    vertical-align: middle;
}
.preview-table tbody tr:hover { background: var(--primary-bg); }

.preview-table .col-no { width: 40px; text-align: center; }
.preview-table .col-name { min-width: 180px; }
.preview-table .col-company { min-width: 120px; }
.preview-table .col-dob { min-width: 100px; text-align: center; }
.preview-table .col-id { min-width: 130px; text-align: center; }
.preview-table .col-status { width: 100px; text-align: center; }

.preview-table td input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    background: transparent;
    transition: all var(--transition);
}
.preview-table td input:hover { background: white; border-color: var(--gray-300); }
.preview-table td input:focus {
    background: white;
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.status-badge.matched { background: #dcfce7; color: #166534; }
.status-badge.missing { background: #fef3c7; color: #92400e; }

/* ===== Preview Warnings ===== */
.preview-warnings {
    margin-top: 16px;
    padding: 14px 18px;
    background: var(--warning-bg);
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    font-size: 13px;
}
.preview-warnings .warning-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--warning);
    margin-bottom: 8px;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: var(--radius);
    background: white;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    animation: toastIn 0.3s ease;
    min-width: 300px;
    max-width: 500px;
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error { border-left-color: var(--danger); }

.toast .toast-icon { font-size: 20px; }
.toast.success .toast-icon { color: var(--success); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.error .toast-icon { color: var(--danger); }

.toast .toast-message { flex: 1; font-size: 14px; }

.toast .toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    font-size: 18px;
    padding: 0;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(50px); }
}

/* ===== Manual Add Student Modal ===== */
.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
    padding: 12px;
    background: var(--primary-bg);
    border-radius: var(--radius);
    border: 1px solid #bfdbfe;
}
.inline-form input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
.inline-form input:focus {
    border-color: var(--primary);
}

/* ===== Responsive ===== */
.mobile-navigation { display: none; }
@media (max-width: 1024px) {
    .mobile-navigation { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; position: sticky; top: 0; z-index: 50; background: white; padding: 10px 0; margin-bottom: 12px; }
    .mobile-navigation details { position: relative; }
    .mobile-navigation summary { cursor: pointer; padding: 10px 14px; border: 1px solid #cbd5e1; border-radius: 8px; }
    .mobile-navigation nav { position: absolute; right: 0; top: 100%; width: 260px; max-width: 80vw; padding: 8px; background: white; border: 1px solid #cbd5e1; border-radius: 8px; box-shadow: 0 6px 20px #0002; }
    .mobile-navigation nav button { display: block; width: 100%; min-height: 44px; text-align: left; border: 0; background: white; padding: 10px; font: inherit; color: #172033; cursor: pointer; }
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 20px; }
}

@media (max-width: 768px) {
    .form-row { flex-direction: column; gap: 12px; }
    .preview-info { flex-direction: column; gap: 8px; }
}


/* ===== Files Table for Added Images ===== */
.files-table-container {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-top: 20px;
    box-shadow: var(--shadow-sm);
}

.files-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.files-table-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 8px;
}

.files-table-actions {
    display: flex;
    gap: 8px;
}

.files-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.files-table th {
    background: #fafafa;
    color: var(--gray-600);
    font-weight: 600;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    font-size: 12px;
    text-transform: uppercase;
}

.files-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.files-table tr:hover {
    background: var(--gray-50);
}

.file-thumb-wrapper {
    width: 60px;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--gray-200);
    cursor: pointer;
    position: relative;
}

.file-thumb-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition);
}

.file-thumb-wrapper:hover img {
    transform: scale(1.1);
}

.file-name-cell {
    font-weight: 500;
    color: var(--gray-800);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-name-cell .file-badge {
    font-size: 11px;
    color: var(--gray-400);
}

/* Lightbox Modal */
.lightbox-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.lightbox-modal.active { display: flex; }

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: transparent;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
}

.lightbox-caption {
    color: white;
    margin-top: 12px;
    font-size: 14px;
    text-align: center;
}
