/* === CSS Variables === */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --white: #ffffff;
    --border-radius: 8px;
    --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.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
}

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

/* === Header === */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    background: var(--primary);
    color: var(--white);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
}

.logo-text {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--gray-800);
}

.nav {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: all 0.15s ease;
}

.nav-btn:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-select {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    background: var(--white);
}

/* === Main Content === */
.main-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* === Views === */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* === Stats Row === */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    padding: 1.25rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* === Sections === */
.section {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* === Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge.green { background: #dcfce7; color: #166534; }
.badge.yellow { background: #fef3c7; color: #92400e; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.gray { background: var(--gray-200); color: var(--gray-600); }
.badge.blue { background: #dbeafe; color: #1e40af; }

/* === Item List === */
.item-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.item-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-200);
}

.item-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.item-code {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--primary);
}

.item-title {
    font-size: 0.875rem;
    color: var(--gray-700);
}

.item-score {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.item-actions {
    display: flex;
    gap: 0.5rem;
}

.item-btn {
    padding: 0.375rem 0.75rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.item-btn.approve { background: var(--success); color: var(--white); }
.item-btn.review { background: var(--warning); color: var(--white); }
.item-btn.view { background: var(--gray-200); color: var(--gray-700); }

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--gray-400);
    font-size: 0.875rem;
}

/* === Collapsible === */
.collapsible-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.collapse-icon {
    font-size: 1.25rem;
    color: var(--gray-400);
}

.collapsed {
    display: none;
}

/* === Form Styles === */
.submit-form {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    max-width: 700px;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.helper-text {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.form-divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
    color: var(--gray-400);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-divider::before,
.form-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-200);
}

.form-divider span {
    padding: 0 1rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
}

/* === Buttons === */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

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

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

/* === Review Screen === */
.review-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.review-column h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
}

.review-card {
    background: var(--white);
    padding: 1.25rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.review-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.review-item:last-child {
    border-bottom: none;
}

.review-label {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.review-value {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-800);
}

.review-value.suggestion {
    color: var(--warning);
}

.review-value.confirmed {
    color: var(--success);
}

/* === Analysis Section === */
.analysis-section {
    background: var(--white);
    padding: 1.25rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.analysis-section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 1rem;
}

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.analysis-item {
    text-align: center;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--border-radius);
}

.analysis-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.analysis-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-bottom: 0.25rem;
}

.analysis-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-800);
}

.score-display {
    text-align: center;
    padding: 1.5rem;
    background: var(--gray-50);
    border-radius: var(--border-radius);
}

.score-label {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.score-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
}

.score-routing {
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

.score-routing.queue { color: var(--success); }
.score-routing.review { color: var(--warning); }
.score-routing.parking { color: var(--gray-500); }

/* === Alternatives Section === */
.alternatives-section {
    background: var(--white);
    padding: 1.25rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.alternatives-section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 1rem;
}

.alternatives-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.alternative-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.alternative-option:hover {
    border-color: var(--gray-300);
}

.alternative-option.selected {
    border-color: var(--primary);
    background: #eff6ff;
}

.alternative-radio {
    margin-top: 0.125rem;
}

.alternative-content {
    flex: 1;
}

.alternative-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-800);
}

.alternative-desc {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* === Final Selection === */
.final-selection {
    background: var(--white);
    padding: 1.25rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.final-selection h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 1rem;
}

/* === Loading Overlay === */
.loading-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;
    flex-direction: column;
    z-index: 1000;
}

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

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--white);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    color: var(--white);
    margin-top: 1rem;
    font-size: 0.875rem;
}

/* === Toast Notifications === */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success { background: var(--success); color: var(--white); }
.toast.error { background: var(--danger); color: var(--white); }
.toast.warning { background: var(--warning); color: var(--white); }
.toast.info { background: var(--primary); color: var(--white); }

/* === Footer === */
.footer {
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* === Responsive === */
@media (max-width: 1024px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .analysis-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .review-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }

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

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