/* ===== CSS Variables - Light Theme ===== */
:root {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.08);
    --text-primary: #1a1a2e;
    --text-secondary: rgba(26, 26, 46, 0.7);
    --text-muted: rgba(26, 26, 46, 0.5);
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --border-radius: 16px;
    --border-radius-sm: 10px;
    --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 8px 32px rgba(99, 102, 241, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html,
body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 0;
}

/* ===== Background ===== */
.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.1), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139, 92, 246, 0.08), transparent),
        radial-gradient(ellipse 40% 30% at 10% 80%, rgba(168, 85, 247, 0.05), transparent);
    pointer-events: none;
    z-index: -1;
}

/* ===== Container & Cards ===== */
.container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    animation: fadeIn 0.5s ease-out;
}

.container.wide {
    max-width: 900px;
}

.container.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
}

.card-header {
    text-align: center;
    margin-bottom: 32px;
}

.card-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 8px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.card-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== Logo ===== */
.logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: var(--accent-gradient);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.3);
}

.logo svg {
    width: 32px;
    height: 32px;
    color: white;
}

/* ===== Navigation Tabs ===== */
.nav-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: var(--border-radius-sm);
}

.nav-tab {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.03);
}

.nav-tab.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-primary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn svg {
    width: 20px;
    height: 20px;
}

.btn-primary {
    width: 100%;
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.05);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-ghost:hover {
    color: var(--text-primary);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.85rem;
    width: auto;
}

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

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

.btn-large {
    padding: 18px 36px;
    font-size: 1.1rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.btn-icon.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

/* ===== Dropzone ===== */
.dropzone {
    border: 2px dashed var(--glass-border);
    border-radius: var(--border-radius);
    padding: 40px;
    text-align: center;
    margin-bottom: 24px;
    transition: var(--transition);
    cursor: pointer;
    background: var(--bg-primary);
}

.dropzone:hover,
.dropzone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.05);
}

.dropzone-content svg {
    width: 48px;
    height: 48px;
    color: var(--accent-primary);
    margin-bottom: 16px;
}

.dropzone-content p {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.dropzone-content span {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.dropzone-content .btn-secondary {
    margin-top: 16px;
}

.file-selected {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(99, 102, 241, 0.08);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.file-selected.hidden {
    display: none;
}

.file-selected svg {
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
}

.file-selected span {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Progress ===== */
.progress-container {
    margin-bottom: 32px;
}

.progress-bar {
    height: 8px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.4),
            transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.progress-stats span:first-child {
    color: var(--accent-primary);
    font-weight: 600;
}

.progress-stats span:last-child {
    color: var(--text-secondary);
}

.progress-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.step {
    text-align: center;
    padding: 16px 8px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    border: 1px solid transparent;
    transition: var(--transition);
    opacity: 0.4;
}

.step.active {
    opacity: 1;
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.08);
}

.step.complete {
    opacity: 1;
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.08);
}

.step-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.step span {
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: block;
}

/* ===== Success & Error ===== */
.success-icon,
.error-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 24px;
}

.success-icon {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border: 2px solid var(--success);
}

.error-icon {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 2px solid var(--error);
}

.error-card .card-header h1 {
    background: linear-gradient(135deg, var(--error), #f87171);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== User Info ===== */
.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--glass-border);
}

.user-badge {
    background: rgba(99, 102, 241, 0.1);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--accent-primary);
    font-weight: 500;
}

/* ===== Error Message ===== */
.error-message {
    color: var(--error);
    font-size: 0.875rem;
    text-align: center;
    margin-top: 16px;
    min-height: 20px;
}

/* ===== Institutions Table ===== */
.institutions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.institutions-header h2 {
    font-size: 1.1rem;
    color: var(--text-primary);
}

#institutions-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
}

.institutions-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.institutions-table th,
.institutions-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

.institutions-table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-primary);
}

.institutions-table td {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.institutions-table tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}

.institutions-table .actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-glow);
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal h3 {
    font-size: 1.25rem;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn {
    flex: 1;
}

/* ===== Tab Content ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .card {
        padding: 28px 20px;
    }

    .progress-steps {
        grid-template-columns: repeat(2, 1fr);
    }

    .dropzone {
        padding: 30px 20px;
    }

    .nav-tabs {
        flex-direction: column;
    }

    .form-row {
        flex-direction: column;
    }
}