/* assets/css/style.css */

:root {
    --color-primary: #2563EB;
    --color-primary-dark: #1E40AF;
    --color-accent: #10B981;
    --color-danger: #EF4444;
    --color-bg: #F8FAFC;
    --color-surface: #FFFFFF;
    --color-text: #1E293B;
    --color-muted: #64748B;
    --color-border: #E2E8F0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --transition: 200ms ease;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

/* ================================
   PUBLIC PAGES
   ================================ */

.public-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #EEF2FF 0%, #F8FAFC 50%, #ECFDF5 100%);
}

.public-container {
    width: 100%;
    max-width: 520px;
}

/* ================================
   FORM LOGOS
   ================================ */

.form-logos {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 0 0.25rem;
}

.form-logo {
    object-fit: contain;
}

.form-logo-wide {
    max-width: 160px;
    height: auto;
    border-radius: 6px;
}

.form-logo-square {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

@media (max-width: 480px) {
    .form-logo-wide {
        max-width: 130px;
    }
    .form-logo-square {
        width: 42px;
        height: 42px;
    }
}

/* ================================
   CARDS
   ================================ */

.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    border: 1px solid var(--color-border);
}

.card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--color-text);
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--color-muted);
    margin-bottom: 1.5rem;
}

/* ================================
   FORMS & INPUTS
   ================================ */

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

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

.form-input,
input[type="text"],
input[type="tel"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

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

.input-error {
    border-color: var(--color-danger) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.input-valid {
    border-color: var(--color-accent) !important;
}

.field-error {
    display: block;
    color: var(--color-danger);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
    min-height: 1.25rem;
}

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

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

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .form-group {
    min-width: 140px;
}

.flex-1 {
    flex: 1;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.5rem;
    cursor: pointer;
}

.checkbox-inline input[type="checkbox"] {
    width: auto;
}

/* ================================
   BUTTONS
   ================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all var(--transition);
    line-height: 1.4;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

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

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

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

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

.btn-success {
    background: var(--color-accent);
    color: #fff;
}

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

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8125rem;
    border-radius: 6px;
}

/* ================================
   LANGUAGE SELECTION
   ================================ */

.language-card {
    text-align: center;
}

.language-card h1 {
    margin-bottom: 0.25rem;
}

.language-card p {
    color: var(--color-muted);
    margin-bottom: 2rem;
}

.language-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-language {
    flex: 1;
    max-width: 200px;
    padding: 1.5rem 1rem;
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    transition: all var(--transition);
}

.btn-language:hover {
    border-color: var(--color-primary);
    background: #EEF2FF;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.flag {
    font-size: 2.5rem;
    line-height: 1;
}

/* ================================
   FORM STEP-BY-STEP
   ================================ */

.form-card {
    max-width: 560px;
    margin: 0 auto;
}

.form-title {
    text-align: center;
    margin-bottom: 1.5rem;
}

.progress-container {
    margin-bottom: 2rem;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: var(--color-muted);
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.question-slide {
    min-height: 120px;
}

.question-label {
    font-size: 1.125rem;
    font-weight: 600;
    display: block;
    margin-bottom: 1rem;
}

.options-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.option-label:hover {
    border-color: var(--color-primary);
    background: #EEF2FF;
}

.option-label input {
    width: auto;
    accent-color: var(--color-primary);
}

.option-label input:checked + .option-text {
    font-weight: 600;
    color: var(--color-primary);
}

.rating-group {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin: 1rem 0;
}

.rating-star {
    background: none;
    border: none;
    font-size: 2.5rem;
    color: var(--color-border);
    cursor: pointer;
    transition: color var(--transition), transform var(--transition);
    padding: 0;
    line-height: 1;
}

.rating-star:hover,
.rating-star.active {
    color: #FBBF24;
    transform: scale(1.15);
}

.form-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    gap: 1rem;
}

#formError:not(:empty) {
    margin-top: 1rem;
    padding: 0.625rem 1rem;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: 8px;
    color: #B91C1C;
    font-weight: 500;
    font-size: 0.875rem;
}

/* ================================
   THANK YOU PAGE
   ================================ */

.thank-you-card {
    text-align: center;
}

.success-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #ECFDF5;
    color: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 1.5rem;
}

.error-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #FEF2F2;
    color: var(--color-danger);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 1.5rem;
}

.summary-box {
    background: var(--color-bg);
    border-radius: 8px;
    padding: 1.25rem;
    margin-top: 1.5rem;
    text-align: left;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-label {
    font-weight: 500;
    color: var(--color-muted);
}

.summary-value {
    font-weight: 600;
}

/* ================================
   ALERTS
   ================================ */

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-danger {
    background: #FEF2F2;
    color: #B91C1C;
    border: 1px solid #FECACA;
}

.alert-success {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

/* ================================
   ADMIN LAYOUT
   ================================ */

.admin-body {
    background: var(--color-bg);
}

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--color-text);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #fff;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.15);
    border-left: 3px solid var(--color-primary);
}

.nav-icon {
    font-size: 1.125rem;
    width: 1.5rem;
    text-align: center;
}

.admin-main {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.btn-hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--color-text);
}

.topbar-user {
    font-size: 0.875rem;
    color: var(--color-muted);
    font-weight: 500;
}

.admin-content {
    padding: 1.5rem;
    flex: 1;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.admin-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* ================================
   STATS CARDS
   ================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--color-border);
    text-align: center;
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.25rem;
    word-break: break-word;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--color-muted);
    font-weight: 500;
}

/* ================================
   DATA TABLES
   ================================ */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    background: var(--color-bg);
    font-weight: 600;
    text-align: left;
    padding: 0.75rem;
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
    color: var(--color-muted);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

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

.data-table code {
    background: var(--color-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.8125rem;
}

.actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

/* ================================
   BADGES
   ================================ */

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-success {
    background: #ECFDF5;
    color: #065F46;
}

.badge-danger {
    background: #FEF2F2;
    color: #B91C1C;
}

/* ================================
   FILTER FORM
   ================================ */

.filter-form {
    margin-bottom: 0;
}

.filter-form .form-row {
    align-items: flex-end;
}

.filter-form .form-group {
    margin-bottom: 0;
}

/* ================================
   FORM BUILDER (Admin)
   ================================ */

.question-item {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: box-shadow var(--transition);
}

.question-item:hover {
    box-shadow: var(--shadow);
}

.question-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.drag-handle {
    cursor: grab;
    font-size: 1.25rem;
    color: var(--color-muted);
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.question-number {
    font-weight: 600;
    font-size: 0.9375rem;
    flex: 1;
}

.btn-remove-q {
    padding: 0.2rem 0.5rem !important;
    font-size: 1rem !important;
    line-height: 1 !important;
}

.q-options-group textarea {
    font-size: 0.875rem;
}

/* ================================
   MODALS
   ================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 440px;
    width: 100%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-muted);
    line-height: 1;
}

/* ================================
   TOASTS
   ================================ */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
}

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

.toast-success {
    background: var(--color-accent);
}

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

.toast-info {
    background: var(--color-primary);
}

/* ================================
   UTILITIES
   ================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--color-muted); }
.mt-4 { margin-top: 1.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1.5rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* ================================
   RESPONSIVE
   ================================ */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

    .admin-main {
        margin-left: 0;
    }

    .btn-hamburger {
        display: block;
    }

    .admin-content {
        padding: 1rem;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

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

    .language-buttons {
        flex-direction: column;
        align-items: center;
    }

    .btn-language {
        max-width: 100%;
    }

    .actions-cell {
        flex-direction: column;
    }

    .card {
        padding: 1.25rem;
    }

    .public-container {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    body {
        font-size: 14px;
    }

    .card h1 {
        font-size: 1.25rem;
    }
}
