/* assets/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
    /* Soft background gradient */
    background-image: radial-gradient(circle at top right, var(--color-primary-light), transparent 40%),
                      radial-gradient(circle at bottom left, var(--color-primary-light), transparent 40%);
    background-attachment: fixed;
}

/* Decorative Background Logos */
.bg-logo {
    position: fixed;
    background-image: url('https://www.univ-khenchela.dz/static/medias/2025/04/LOGO-ar-1-3-scaled.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    z-index: 0;
    opacity: var(--logo-opacity, 0.05);
    filter: var(--logo-filter, none);
    will-change: transform;
}

.bg-logo-1 {
    bottom: -15vh;
    right: -10vw;
    width: 60vw;
    height: 60vh;
    min-width: 400px;
    min-height: 400px;
    animation: float1 15s ease-in-out infinite;
}

.bg-logo-2 {
    top: -5vh;
    left: -5vw;
    width: 30vw;
    height: 30vh;
    min-width: 250px;
    min-height: 250px;
    animation: float2 20s ease-in-out infinite reverse;
}

@keyframes float1 {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-30px) rotate(2deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

@keyframes float2 {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(20px) rotate(-2deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

/* Typography */
h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; line-height: 1.2; margin-bottom: 1rem; }
h2 { font-size: clamp(1.5rem, 4vw, 2.25rem); font-weight: 600; margin-bottom: 1rem; }
h3 { font-size: clamp(1.25rem, 3vw, 1.5rem); font-weight: 600; margin-bottom: 0.75rem; }
p { font-size: clamp(1rem, 2vw, 1.125rem); margin-bottom: 1rem; color: var(--color-text-muted); }

/* Layout */
.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    position: relative;
    z-index: 1;
}

/* Cards & Glassmorphism */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: clamp(1.5rem, 4vw, 3rem);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
    transition: all 0.3s ease;
}

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

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

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

.form-control {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--color-text);
    background-color: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 4px var(--color-primary-light);
}

/* Custom Radio & Checkbox as Cards */
.options-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

.option-card {
    position: relative;
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--color-surface);
}

.option-card:hover {
    border-color: var(--color-primary-light);
    background: var(--color-surface-hover);
}

.option-card input[type="radio"],
.option-card input[type="checkbox"] {
    position: absolute;
    opacity: 0;
}

.option-card input:checked ~ .option-content {
    color: var(--color-primary);
    font-weight: 600;
}

.option-card:has(input:checked) {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.option-content {
    margin-left: 0.5rem;
    flex: 1;
    color: var(--color-text);
    transition: color 0.2s;
}

/* Autre input */
.autre-input-wrapper {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--color-surface-hover);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    animation: slideDown 0.3s ease;
}

.autre-input-wrapper .autre-input {
    font-size: 0.95rem;
    padding: 0.75rem 1rem;
}

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

/* Conditional textarea wrapper */
.conditional-textarea-wrapper {
    animation: slideDown 0.3s ease;
}

/* ========================================
   Validation Error States
   ======================================== */

/* Error state on text/textarea inputs */
.form-control.input-error {
    border-color: var(--color-error);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
    animation: shake 0.35s ease;
}

.form-control.input-error:focus {
    border-color: var(--color-error);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18);
}

/* Error state on option-card groups (radio/checkbox) */
.options-grid.group-error .option-card {
    border-color: rgba(239, 68, 68, 0.4);
    animation: shake 0.35s ease;
}

/* Inline error message */
.field-error-msg {
    display: none;
    align-items: center;
    gap: 0.35rem;
    color: var(--color-error);
    font-size: 0.825rem;
    font-weight: 500;
    margin-top: 0.4rem;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-md);
    background: rgba(239, 68, 68, 0.07);
    animation: slideDown 0.2s ease;
}

.field-error-msg::before {
    content: '!';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--color-error);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
}

.field-error-msg.visible {
    display: flex;
}

/* Shake keyframe — short, subtle */
@keyframes shake {
    0%   { transform: translateX(0); }
    20%  { transform: translateX(-6px); }
    40%  { transform: translateX(6px); }
    60%  { transform: translateX(-4px); }
    80%  { transform: translateX(4px); }
    100% { transform: translateX(0); }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 2rem;
    font-size: 1.125rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px; /* Touch target size */
}

.btn-primary {
    background-color: var(--color-primary);
    color: #ffffff;
    box-shadow: var(--shadow-md);
}

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

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

.btn-outline {
    background-color: transparent;
    color: var(--color-text);
    border: 2px solid var(--color-border);
}

.btn-outline:hover {
    border-color: var(--color-text);
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Progress Bar */
.progress-bar {
    height: 100%;
    background-color: var(--color-primary);
    width: 0%;
    border-radius: var(--radius-full);
    transition: width 0.4s ease-out;
}

/* SPA / Slides */
#app-container {
    position: relative;
    width: 100%;
    min-height: 60vh;
}

.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.slide.active {
    position: relative;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Shutter Overlay */
.shutter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--color-primary);
    z-index: 9999;
    transform: scaleX(0);
    transform-origin: left;
    pointer-events: none;
}

/* Theme Selector */
.theme-selector {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 9000;
}

.theme-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    cursor: pointer;
    background-color: var(--color-surface);
    transition: transform 0.2s;
}

.theme-btn:hover {
    transform: scale(1.1);
}

.theme-btn[data-set-theme="light"] { background: #F9FAFB; }
.theme-btn[data-set-theme="dark"] { background: #111827; border-color: #374151;}
.theme-btn[data-set-theme="accent"] { background: #EC4899; }

/* Admin Table */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
}

th {
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

tr:hover td {
    background-color: var(--color-surface-hover);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-full);
}

.badge-primary { background-color: var(--color-primary-light); color: var(--color-primary); }
.badge-success { background-color: rgba(16, 185, 129, 0.1); color: var(--color-success); }

/* Grid Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    text-align: center;
    padding: 1.5rem;
}

.kpi-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.kpi-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Stat Chart */
.stat-item {
    margin-bottom: 1rem;
}
.stat-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}
.stat-bar-container {
    width: 100%;
    height: 12px;
    background-color: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.stat-bar-fill {
    height: 100%;
    background-color: var(--color-primary);
    border-radius: var(--radius-full);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat-bar-fill.highlight {
    background-color: var(--color-success);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s;
}

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

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

/* Flex utilities */
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.align-center { align-items: center; }
.gap-2 { gap: 1rem; }
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 2rem; }
.text-center { text-align: center; }

/* Responsive Adjustments */
@media (min-width: 768px) {
    .options-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile compact adjustments */
@media (max-width: 480px) {
    h2 {
        font-size: 1.15rem;
    }

    .slide-question h2 {
        font-size: 1.1rem;
        line-height: 1.4;
    }

    .option-card {
        padding: 0.75rem 1rem;
    }

    .option-content {
        font-size: 0.9rem;
    }

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

    .card {
        padding: 1.25rem;
    }

    .badge {
        font-size: 0.8rem;
        padding: 0.2rem 0.6rem;
    }

    .autre-input-wrapper {
        padding: 0.5rem;
    }

    .autre-input-wrapper .autre-input {
        font-size: 0.875rem;
        padding: 0.6rem 0.75rem;
    }
}
