:root {
    --primary-color: #e2001a;
    --primary-hover: #b30014;
    --bg-color: #f7f7f9;
    --card-bg: #ffffff;
    --text-color: #1a1a1a;
    --text-muted: #666666;
    --border-color: #eaeaec;
    --success: #2e7d32;
    --font-main: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* Header */
#main-header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 600;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
}

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

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

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

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

.btn-secondary:hover {
    background-color: #f0f0f0;
}

.btn-icon {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 0.5rem;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.3);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
    display: block;
}

/* Typography & Utilities */
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

h1, h2, h3 { color: var(--text-color); }
.page-title { font-size: 2rem; font-weight: 800; margin-bottom: 0.5rem; letter-spacing: -0.5px; text-transform: tight; }
.page-desc { color: var(--text-muted); margin-bottom: 2rem; font-size: 1rem; line-height: 1.5; }

/* Views & Containers */
.view {
    min-height: calc(100vh - 64px);
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0,0,0,0.03);
}

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

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

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
}

input[type="text"], input[type="password"], input[type="date"], select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font-main);
    background-color: var(--bg-color);
    transition: border-color 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Login View */
#view-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: white;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.login-logo-wrapper {
    text-align: center;
    margin-bottom: 3rem;
}

.logo-large {
    font-size: 3rem;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 0.5rem;
}

/* Store Home View */
.departments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.dept-card {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border-color);
}

.dept-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.dept-card.active-filter {
    border: 2px solid var(--primary-color);
}

.dept-img {
    height: 180px;
    background-size: cover;
    background-position: center;
}

.dept-content {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dept-content h3 {
    font-size: 1.25rem;
}

.badge {
    background: var(--bg-color);
    color: var(--text-color);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

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

/* Questionnaire Items */
.q-item {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.q-item:hover {
    border-color: var(--primary-color);
}

.q-info h4 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.q-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.q-status {
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

.status-pending { background: #ffebee; color: var(--primary-color); }
.status-done { background: #e8f5e9; color: var(--success); }

/* Photo Upload */
.photo-upload-box {
    position: relative;
    margin-bottom: 1rem;
}

.photo-upload-box input[type="file"] {
    position: absolute;
    width: 0; height: 0; opacity: 0;
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    background: var(--bg-color);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

.upload-label i {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.upload-label:hover {
    border-color: var(--primary-color);
    background: white;
}

.photo-preview {
    width: 100%;
    height: 300px;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--border-color);
}

/* Admin Tabs Segmented Control Style */
.admin-tabs {
    display: inline-flex;
    gap: 0.5rem;
    margin-bottom: 2.5rem;
    background-color: var(--border-color);
    padding: 0.4rem;
    border-radius: 999px;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 999px;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background-color: white;
    color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08); /* slight depth */
}

.tab-btn:not(.active):hover {
    color: var(--text-color);
}

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

.stat-card {
    background: linear-gradient(145deg, #ffffff, #fdfdfd);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,0.03);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05); /* Match .card */
    text-align: left; /* Look more grown up */
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.stat-card h3 {
    font-size: 1.05rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-top: 0.5rem;
    line-height: 1;
    letter-spacing: -1.5px;
}

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.modal-content.modal-lg {
    max-width: 800px;
}

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

.modal-header h3 {
    font-size: 1.25rem;
}

.btn-close {
    background: none; border: none; font-size: 1.25rem; color: var(--text-muted); cursor: pointer;
}

.modal-body {
    padding: 1.5rem;
}

/* Admin lists */
.admin-list-item {
    padding: 1.25rem;
    border: 1px solid rgba(0,0,0,0.04);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: transform 0.2s, box-shadow 0.2s;
}

.admin-list-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.06);
    border-color: rgba(226, 0, 26, 0.2);
}

.sub-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.sub-item img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
}
.sub-info {
    flex: 1;
}

/* Checkbox list (Superviseur Stores) */
.stores-checkbox-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    max-height: 200px;
    overflow-y: auto;
}
.stores-checkbox-list label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-weight: 400;
    cursor: pointer;
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.05);
}
.stores-checkbox-list input[type="checkbox"] {
    accent-color: var(--primary-color);
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

/* Charts */
.chart-card {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    min-height: 150px;
}

/* Tables for Returns */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    margin-top: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    text-align: left;
    font-size: 0.95rem;
}
.admin-table th, .admin-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}
.admin-table th {
    background-color: var(--bg-color);
    font-weight: 600;
    color: var(--text-muted);
}
.admin-table tr:last-child td {
    border-bottom: none;
}
.admin-table tr:hover {
    background-color: #fafafa;
}

.version-label {
    position: fixed;
    bottom: 10px;
    right: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
    pointer-events: none;
    z-index: 1000;
}

@media (max-width: 600px) {
    .hide-mobile { display: none; }
    
    body {
        /* Prevents tap highlight on mobile devices for native feel */
        -webkit-tap-highlight-color: transparent;
    }

    .container {
        padding: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }
    
    .admin-list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .sub-item {
        flex-direction: column;
    }

    .sub-item img {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
    }

    /* Make buttons full width on small screens inside lists */
    .admin-list-item > div:last-child {
        width: 100%;
        justify-content: flex-end;
    }

    /* Modal adjustments */
    .modal-content {
        max-height: 100vh;
        border-radius: 12px 12px 0 0;
        margin-top: auto;
        position: absolute;
        bottom: 0;
    }
    
    /* Admin tabs full width stacked on mobile */
    .admin-tabs {
        display: flex;
        flex-direction: column;
        border-radius: 12px;
        width: 100%;
        padding: 0.5rem;
    }

    .tab-btn {
        border-radius: 8px;
        width: 100%;
        text-align: center;
        padding: 0.85rem;
    }

    /* Login full height */
    .login-container {
        padding: 1.5rem;
    }
}

.zoomed-image-active {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 99999 !important;
    max-width: 90vw !important;
    max-height: 90vh !important;
    width: auto !important;
    height: auto !important;
    box-shadow: 0 0 0 100vmax rgba(0,0,0,0.8) !important;
    cursor: zoom-out !important;
    object-fit: contain !important;
    border-radius: 8px !important;
}
