/*
 * Exam Analytics (Beta) v1.0.0
 * Component Styles: Buttons, Forms, Tables, Cards, Modals
 */

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    line-height: 1;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

.btn-secondary {
    background-color: var(--color-surface-secondary);
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--color-border);
}

.btn-success {
    background-color: var(--color-success);
    color: white;
    border-color: var(--color-success);
}

.btn-success:hover:not(:disabled) {
    background-color: var(--color-accent-hover);
}

.btn-outline {
    background-color: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-outline:hover:not(:disabled) {
    background-color: var(--color-primary);
    color: white;
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-lg);
}

/* ==================== Forms ==================== */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: var(--color-text);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background-color: var(--color-surface-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

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

.form-file {
    padding: var(--space-3);
}

.form-help {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.form-error {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--color-error);
}

.form-checkbox,
.form-radio {
    width: auto;
    margin-right: var(--space-2);
}

.form-check {
    display: flex;
    align-items: center;
    margin-bottom: var(--space-3);
}

.form-check-label {
    margin-bottom: 0;
    font-weight: var(--font-weight-normal);
}

/* ==================== Tables ==================== */
.table-wrapper {
    overflow-x: auto;
    margin-bottom: var(--space-6);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.table th,
.table td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.table th {
    background-color: var(--color-surface-secondary);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    position: sticky;
    top: 0;
    z-index: var(--z-base);
}

.table tbody tr:hover {
    background-color: var(--color-surface-secondary);
}

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

.table-striped tbody tr:nth-child(odd) {
    background-color: var(--color-surface);
}

.table-striped tbody tr:nth-child(even) {
    background-color: var(--color-surface-secondary);
}

.table-sm th,
.table-sm td {
    padding: var(--space-2) var(--space-3);
}

/* Sortable Table Headers */
.table th.sortable {
    cursor: pointer;
    user-select: none;
}

.table th.sortable:hover {
    background-color: var(--color-border);
}

.table th.sortable::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: var(--space-2);
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    opacity: 0.3;
}

.table th.sortable.asc::after {
    border-bottom: 4px solid currentColor;
    opacity: 1;
}

.table th.sortable.desc::after {
    border-top: 4px solid currentColor;
    opacity: 1;
}

/* ==================== Cards ==================== */
.card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

.card-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-2);
}

.card-description {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.card-body {
    margin-bottom: var(--space-4);
}

.card-footer {
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
}

/* ==================== Alerts ==================== */
.alert {
    padding: var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    border-left: 4px solid;
}

.alert-info {
    background-color: var(--color-primary-light);
    border-color: var(--color-info);
    color: var(--color-text);
}

.alert-success {
    background-color: #D1FAE5;
    border-color: var(--color-success);
    color: var(--color-text);
}

.alert-warning {
    background-color: #FEF3C7;
    border-color: var(--color-warning);
    color: var(--color-text);
}

.alert-error {
    background-color: #FEE2E2;
    border-color: var(--color-error);
    color: var(--color-text);
}

[data-theme="dark"] .alert-info {
    background-color: rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .alert-success {
    background-color: rgba(16, 185, 129, 0.2);
}

[data-theme="dark"] .alert-warning {
    background-color: rgba(245, 158, 11, 0.2);
}

[data-theme="dark"] .alert-error {
    background-color: rgba(239, 68, 68, 0.2);
}

/* ==================== Badges ==================== */
.badge {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-primary {
    background-color: var(--color-primary);
    color: white;
}

.badge-success {
    background-color: var(--color-success);
    color: white;
}

.badge-warning {
    background-color: var(--color-warning);
    color: white;
}

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

.badge-secondary {
    background-color: var(--color-surface-secondary);
    color: var(--color-text);
}

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

.modal-overlay.is-open {
    display: flex;
}

.modal {
    background-color: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.2s ease-out;
}

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

.modal-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--font-size-2xl);
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: var(--space-2);
    line-height: 1;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--color-text);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

.modal-lg {
    max-width: 900px;
}

/* ==================== Loading Spinner ==================== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

/* ==================== Progress Bar ==================== */
.progress {
    height: 8px;
    background-color: var(--color-surface-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--color-primary);
    transition: width var(--transition-base);
}

/* ==================== Stats Cards ==================== */
.stat-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    text-align: center;
}

.stat-value {
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-primary);
    margin-bottom: var(--space-2);
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-medium);
}

/* ==================== Toggle Switch ==================== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-border);
    transition: var(--transition-fast);
    border-radius: var(--radius-full);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition-fast);
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--color-primary);
}

.toggle-switch input:focus-visible + .toggle-slider {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* ==================== Tabs ==================== */
.tabs {
    border-bottom: 2px solid var(--color-border);
    margin-bottom: var(--space-6);
}

.tabs-list {
    display: flex;
    gap: var(--space-2);
    list-style: none;
}

.tab-button {
    background: none;
    border: none;
    padding: var(--space-3) var(--space-5);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
}

.tab-button:hover {
    color: var(--color-text);
}

.tab-button.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab-panel {
    display: none;
}

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

/* ==================== Breadcrumbs ==================== */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
    font-size: var(--font-size-sm);
}

.breadcrumbs a {
    color: var(--color-primary);
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

.breadcrumbs-separator {
    color: var(--color-text-muted);
}

/* ==================== Empty State ==================== */
.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-8);
}

.empty-state-icon {
    font-size: var(--font-size-4xl);
    color: var(--color-text-muted);
    margin-bottom: var(--space-4);
}

.empty-state-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-2);
}

.empty-state-description {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-6);
}

/* ==================== Modern UI Components ==================== */

/* Hero Modern */
.hero-modern {
    background: linear-gradient(135deg, #6B8DD6 0%, #8E9AAF 100%);
    color: white;
    padding: var(--space-12) 0 var(--space-16) 0;
    text-align: center;
    position: relative;
    overflow: hidden;
    margin-top: 0 !important;
}

.hero-modern::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="30" fill="rgba(255,255,255,0.05)"/></svg>');
    opacity: 0.1;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    margin-bottom: var(--space-6);
    font-size: var(--font-size-sm);
}

.hero-title-modern {
    font-size: 3.5rem;
    font-weight: var(--font-weight-bold);
    line-height: 1.1;
    margin-bottom: var(--space-6);
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.hero-subtitle-modern {
    font-size: 1.25rem;
    line-height: 1.6;
    opacity: 0.95;
    max-width: 700px;
    margin: 0 auto var(--space-8);
}

.hero-cta-group {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: var(--space-12);
}

.btn-modern {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    border-radius: var(--radius-xl);
    text-decoration: none;
    transition: all var(--transition-base);
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.btn-modern:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.btn-modern-primary {
    background: white;
    color: #667eea;
}

.btn-modern-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(10px);
}

.btn-modern-white {
    background: white;
    color: #667eea;
}

.hero-stats {
    display: flex;
    gap: var(--space-8);
    justify-content: center;
    flex-wrap: wrap;
}

.hero-stat {
    text-align: center;
}

.hero-stat-value {
    font-size: 2.5rem;
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-2);
}

.hero-stat-label {
    font-size: var(--font-size-sm);
    opacity: 0.9;
}

/* Section Headers */
.section-header-center {
    text-align: center;
    margin-bottom: var(--space-12);
}

.section-title-modern {
    font-size: 2.5rem;
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-4);
    color: var(--color-text);
}

.section-description-modern {
    font-size: 1.125rem;
    color: var(--color-text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Features Grid */
.section-features {
    padding: var(--space-16) 0;
    background: var(--color-surface);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-8);
}

.feature-card {
    background: var(--color-background);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.feature-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-6);
    color: white;
}

.feature-title {
    font-size: 1.25rem;
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-3);
    color: var(--color-text);
}

.feature-description {
    color: var(--color-text-secondary);
    line-height: 1.7;
}

/* Steps Grid */
.section-how-it-works {
    padding: var(--space-16) 0;
}

.steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-8);
    margin-top: var(--space-12);
}

.step-card {
    text-align: center;
    position: relative;
}

.step-number {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: var(--font-weight-bold);
    margin: 0 auto var(--space-6);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.step-title {
    font-size: 1.25rem;
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-3);
    color: var(--color-text);
}

.step-description {
    color: var(--color-text-secondary);
}

/* CTA Section */
.section-cta {
    padding: var(--space-16) 0;
    position: relative;
    overflow: hidden;
}

.cta-box {
    text-align: center;
    padding: var(--space-12);
    background: white;
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    max-width: 800px;
    margin: 0 auto;
}

.cta-title {
    font-size: 2.5rem;
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-4);
}

.cta-description {
    font-size: 1.25rem;
    margin-bottom: var(--space-8);
    opacity: 0.95;
}

/* Language Switcher */
.language-switcher {
    display: flex;
    gap: var(--space-2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .hero-title-modern {
        font-size: 2rem;
    }

    .hero-subtitle-modern {
        font-size: 1rem;
    }

    .btn-modern {
        font-size: var(--font-size-base);
        padding: var(--space-3) var(--space-6);
    }

    .section-title-modern {
        font-size: 1.75rem;
    }

    .cta-title {
        font-size: 1.75rem;
    }

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

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

/* Dark Theme Adjustments */
[data-theme="dark"] .feature-card {
    background: var(--color-surface);
}

[data-theme="dark"] .section-features {
    background: var(--color-background);
}
