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

:root {
    --blue: #00ADFF;
    --blue-light: #f3fbff;
    --blue-dark: #0090d4;
    --purple: #6C68A5;
    --green: #7cb342;
    --green-light: #d5e0a8;
    --orange: #ea580c;
    --red: #dc2626;
    --gray-50: #f5f7f8;
    --gray-100: #f0f2f4;
    --gray-200: #e2e5e8;
    --gray-300: #d1d5db;
    --gray-500: #606060;
    --gray-700: #3a3a3a;
    --gray-900: #1C1C1C;
    --radius: 10px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--gray-900);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transition: transform 0.25s ease;
}
.sidebar-logo {
    padding: 20px 18px 16px;
    font-size: 18px;
    font-weight: 700;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo span {
    color: var(--blue);
}
.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    list-style: none;
}
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.sidebar-nav li a:hover {
    color: white;
    background: rgba(255,255,255,0.06);
}
.sidebar-nav li a.active {
    color: white;
    background: rgba(255,255,255,0.08);
    border-left-color: var(--blue);
}
.sidebar-nav li a svg {
    flex-shrink: 0;
    opacity: 0.7;
}
.sidebar-nav li a.active svg,
.sidebar-nav li a:hover svg {
    opacity: 1;
}
.sidebar-footer {
    padding: 16px 18px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 12px;
    color: rgba(255,255,255,0.35);
    text-align: center;
    line-height: 1.6;
}
.sidebar-footer a {
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    transition: color 0.15s;
}
.sidebar-footer a:hover {
    color: white;
}
.sidebar-footer .heart {
    color: #e25555;
    display: inline;
}

/* Main content with sidebar */
.main-content {
    flex: 1;
    margin-left: 220px;
}
.container { max-width: 1100px; margin: 0 auto; padding: 20px; }
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.header h1 { font-size: 24px; }

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 60;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: var(--gray-900);
    color: white;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

@media (max-width: 800px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-toggle {
        display: flex;
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 40;
    }
    .sidebar-overlay.open {
        display: block;
    }
}

/* Cards */
.card {
    background: white;
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px;
    border: none; border-radius: 30px;
    font-size: 14px; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--gray-900); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--gray-200); }
th { background: var(--gray-50); font-weight: 600; font-size: 13px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; }
td { font-size: 14px; }
tr:hover td { background: var(--blue-light); }

/* Badge */
.badge {
    display: inline-block; padding: 2px 8px;
    border-radius: 12px; font-size: 12px; font-weight: 500;
}
.badge-green { background: #e8f0d2; color: #5a7a1a; }
.badge-orange { background: #fff7ed; color: #c2410c; }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }
.badge-red { background: #fef2f2; color: #dc2626; }

/* Progress bar */
.progress-bar {
    height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden;
}
.progress-bar .fill {
    height: 100%; background: var(--blue); border-radius: 4px;
    transition: width 0.3s;
}

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; font-size: 14px; margin-bottom: 4px; color: var(--gray-700); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--gray-300); border-radius: var(--radius);
    font-size: 15px; font-family: inherit;
    transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus {
    outline: none; border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0, 173, 255, 0.15);
}

/* Modal */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.4); z-index: 100;
    justify-content: center; align-items: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: white; border-radius: 12px;
    padding: 24px; width: 90%; max-width: 500px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal h2 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Grid metrics */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric-card {
    background: white; border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px; text-align: center;
}
.metric-card .value { font-size: 32px; font-weight: 700; color: var(--blue); }
.metric-card .label { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* QR section */
.qr-section { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.qr-section img { width: 160px; height: 160px; border-radius: var(--radius); }
.qr-info { flex: 1; min-width: 200px; }
.qr-link {
    display: block; padding: 8px 12px; background: var(--gray-100);
    border-radius: var(--radius); font-size: 14px; word-break: break-all;
    color: var(--blue); margin-top: 8px;
}

/* Copro cards grid */
.copro-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}
.copro-card {
    background: white;
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}
.copro-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}
.copro-card-header {
    height: 120px;
    background: linear-gradient(135deg, #00ADFF 0%, #6C68A5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.copro-card-qr img {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    background: white;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.copro-card-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2);
    border-radius: 14px;
}
.copro-card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.copro-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.3;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.copro-card-address {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.copro-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}
.copro-card-responses {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500);
}

/* Empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--gray-500); }
.empty p { margin-bottom: 16px; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }
.tab {
    padding: 10px 20px; border: none; background: none;
    font-size: 14px; font-weight: 500; cursor: pointer;
    color: var(--gray-500); border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all 0.15s;
}
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* File drop */
.file-drop {
    border: 2px dashed var(--gray-300); border-radius: var(--radius);
    padding: 30px; text-align: center; color: var(--gray-500);
    cursor: pointer; transition: all 0.15s;
}
.file-drop:hover, .file-drop.dragover {
    border-color: var(--blue); background: var(--blue-light); color: var(--blue);
}
.file-drop input { display: none; }

/* Toast */
.toast {
    position: fixed; bottom: 20px; right: 20px;
    padding: 12px 20px; border-radius: var(--radius);
    background: var(--gray-900); color: white;
    font-size: 14px; z-index: 200;
    animation: slideIn 0.3s, fadeOut 0.3s 2.7s;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }

/* ==================== FORM PUBLIC (legacy) ==================== */
.form-public {
    max-width: 600px; margin: 0 auto; padding: 20px;
}
.form-public h1 { font-size: 22px; margin-bottom: 4px; }
.form-public .subtitle { color: var(--gray-500); margin-bottom: 24px; }

.step { display: none; }
.step.active { display: block; }

.type-choice {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0;
}
.type-choice button {
    padding: 20px; border: 2px solid var(--gray-200);
    border-radius: var(--radius); background: white;
    font-size: 16px; font-weight: 500; cursor: pointer;
    transition: all 0.15s;
}
.type-choice button:hover { border-color: var(--blue); background: var(--blue-light); }
.type-choice button.selected { border-color: var(--blue); background: var(--blue-light); color: var(--blue); }

.confirmation {
    text-align: center; padding: 40px 20px;
}
.confirmation .check { font-size: 48px; margin-bottom: 16px; }

/* ==================== SMART IMPORT ==================== */

.smart-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: smart-spin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes smart-spin {
    to { transform: rotate(360deg); }
}

.smart-edit {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s;
}
.smart-edit:focus {
    outline: none;
    border-color: var(--blue);
}
.smart-edit[type="number"] {
    text-align: right;
}

/* ==================== CHECKLIST ==================== */

.checklist {
    list-style: none;
    padding: 0;
    margin: 0;
}
.checklist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}
.checklist-item:hover {
    background: var(--gray-50);
}
.checklist-item.done .checklist-label {
    color: var(--gray-500);
    text-decoration: line-through;
}
.checklist-check {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: 2px solid var(--gray-300);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.checklist-check.checked {
    background: var(--blue);
    border-color: var(--blue);
}
.checklist-check.checked::after {
    content: '';
    display: block;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}
.checklist-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
}
.checklist-item.locked {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
.checklist-item.locked .checklist-check {
    border-color: var(--gray-200);
}

/* Copro grid responsive */
@media (max-width: 800px) {
    .copro-grid { grid-template-columns: 1fr !important; }
    .charts-grid { grid-template-columns: 1fr !important; }
}

/* ==================== FORMULAIRE CONVERSATIONNEL (Typeform) ==================== */

.tf-body {
    background: #f5f7f8;
    overflow: hidden;
}

.tf {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Progress bar */
.tf-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    z-index: 10;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(6px);
}
.tf-progress-bar.visible {
    display: flex;
}
.tf-progress-track {
    flex: 1;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}
.tf-progress-fill {
    height: 100%;
    width: 0;
    background: var(--blue);
    border-radius: 3px;
    transition: width 0.4s ease;
}
.tf-progress-pct {
    font-size: 13px;
    font-weight: 600;
    color: var(--blue);
    min-width: 36px;
    text-align: right;
}

/* Back button */
.tf-back {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 10;
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--gray-100);
    color: var(--gray-700);
    cursor: pointer;
    transition: background 0.15s;
}
.tf-back:hover {
    background: var(--gray-200);
}

/* Slides container */
.tf-slides {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Slide */
.tf-slide {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    transition: transform 0.4s ease, opacity 0.4s ease;
}
.tf-slide.active {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

/* Animations entree */
.tf-slide.enter-from-below {
    transform: translateY(60px);
    opacity: 0;
}
.tf-slide.enter-from-above {
    transform: translateY(-60px);
    opacity: 0;
}

/* Animations sortie */
.tf-slide.exit-up {
    display: flex;
    transform: translateY(-60px);
    opacity: 0;
    pointer-events: none;
}
.tf-slide.exit-down {
    display: flex;
    transform: translateY(60px);
    opacity: 0;
    pointer-events: none;
}

/* Content */
.tf-content {
    width: 100%;
    max-width: 520px;
}

/* Question / titre */
.tf-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
    margin-bottom: 8px;
}
.tf-question {
    font-size: 24px;
    font-weight: 600;
    color: var(--gray-900);
    line-height: 1.3;
    margin-bottom: 12px;
}
.tf-subtitle {
    font-size: 18px;
    color: var(--gray-500);
    margin-bottom: 8px;
}
.tf-help {
    font-size: 15px;
    color: var(--gray-500);
    margin-bottom: 16px;
    line-height: 1.4;
}
.tf-label-small {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

/* Input style Typeform */
.tf-input {
    display: block;
    width: 100%;
    padding: 12px 0;
    border: none;
    border-bottom: 2px solid var(--gray-300);
    background: transparent;
    font-size: 20px;
    font-family: inherit;
    color: var(--gray-900);
    outline: none;
    transition: border-color 0.2s;
}
.tf-input:focus {
    border-bottom-color: var(--blue);
}
.tf-input::placeholder {
    color: var(--gray-300);
}
/* Masquer les spinners des inputs number */
.tf-input[type="number"]::-webkit-inner-spin-button,
.tf-input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.tf-input[type="number"] {
    -moz-appearance: textfield;
}

/* Select */
.tf-select {
    display: block;
    width: 100%;
    padding: 12px 0;
    border: none;
    border-bottom: 2px solid var(--gray-300);
    background: transparent;
    font-size: 18px;
    font-family: inherit;
    color: var(--gray-900);
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}
.tf-select:focus {
    border-bottom-color: var(--blue);
}

/* Actions (bouton OK + hint) */
.tf-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}
.tf-btn-ok {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    border: none;
    border-radius: 30px;
    background: var(--blue);
    color: white;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.tf-btn-ok:hover {
    background: var(--gray-900);
}
.tf-btn-ok:active {
    transform: scale(0.97);
}
.tf-hint {
    font-size: 13px;
    color: var(--gray-500);
}

/* Bouton Commencer */
.tf-btn-start {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 16px 44px;
    margin-top: 32px;
    border: none;
    border-radius: 30px;
    background: var(--blue);
    color: white;
    font-size: 18px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    box-shadow: 0 4px 14px rgba(0, 173, 255, 0.3);
}
.tf-btn-start:hover {
    background: var(--gray-900);
    box-shadow: 0 4px 14px rgba(28, 28, 28, 0.2);
}
.tf-btn-start:active {
    transform: scale(0.97);
}

/* Choix (type occupant) */
.tf-choices {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}
.tf-choices-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.tf-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 28px 20px;
    border: 2px solid var(--gray-200);
    border-radius: 16px;
    background: white;
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.tf-choice:hover {
    border-color: var(--blue);
    background: var(--blue-light);
    color: var(--blue);
    box-shadow: 0 4px 14px rgba(0, 173, 255, 0.15);
}
.tf-choice.selected {
    border-color: var(--blue);
    background: var(--blue-light);
    color: var(--blue);
    box-shadow: 0 4px 14px rgba(0, 173, 255, 0.15);
}

/* Grille nb personnes */
.tf-choices-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 8px;
}
.tf-choice-sm {
    padding: 18px;
    border: 2px solid var(--gray-200);
    border-radius: 14px;
    background: white;
    font-size: 22px;
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.tf-choice-sm:hover {
    border-color: var(--blue);
    background: var(--blue-light);
    color: var(--blue);
    box-shadow: 0 4px 14px rgba(0, 173, 255, 0.15);
}
.tf-choice-sm.selected {
    border-color: var(--blue);
    background: var(--blue-light);
    color: var(--blue);
    box-shadow: 0 4px 14px rgba(0, 173, 255, 0.15);
}

/* Erreur inline */
.tf-error {
    margin-top: 12px;
    padding: 8px 14px;
    border-radius: 8px;
    background: #fef2f2;
    color: var(--red);
    font-size: 14px;
    font-weight: 500;
    animation: tf-shake 0.4s;
}
@keyframes tf-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* Checkmark anime */
.tf-checkmark {
    animation: tf-pop 0.5s ease;
}
@keyframes tf-pop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== Responsive mobile ===== */
@media (max-width: 640px) {
    .tf-title { font-size: 26px; }
    .tf-question { font-size: 20px; }
    .tf-input { font-size: 18px; }
    .tf-choices-2 { grid-template-columns: 1fr; }
    .tf-choice { padding: 22px 16px; }
    .tf-choices-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .tf-choice-sm { padding: 14px; font-size: 20px; }
    .tf-btn-start { width: 100%; justify-content: center; }
    .tf-slide { padding: 20px 16px; }
}

/* Responsive */
@media (max-width: 640px) {
    .container { padding: 12px; }
    .header h1 { font-size: 20px; }
    .metrics { grid-template-columns: 1fr 1fr; }
    .qr-section { flex-direction: column; align-items: flex-start; }
    table { font-size: 13px; }
    th, td { padding: 8px 6px; }
    .type-choice { grid-template-columns: 1fr; }
}
