/* ========================================
   RÉFÉRENCE STOP - PWA Styles
   ======================================== */

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

:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --success: #16a34a;
    --success-dark: #15803d;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ========================================
   SCREENS
   ======================================== */

.screen {
    display: none;
    min-height: 100vh;
    background: var(--gray-50);
    flex-direction: column;
}

.screen.active {
    display: flex;
}

.screen-content {
    flex: 1;
    padding: 20px;
    padding-bottom: 40px;
    overflow-y: auto;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

.center-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ========================================
   HEADER
   ======================================== */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 18px;
    font-weight: 700;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    font-size: 28px;
}

.header-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
}

.header-btn:active {
    background: rgba(255,255,255,0.3);
}

.back-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    color: white;
}

/* ========================================
   LOGIN SCREEN
   ======================================== */

#screen-login {
    background: linear-gradient(135deg, var(--primary) 0%, #1e3a8a 100%);
}

#screen-login .screen-content {
    padding-bottom: 20px;
}

.logo {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.logo-icon {
    font-size: 72px;
    margin-bottom: 16px;
}

.logo h1 {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: 1px;
}

.subtitle {
    opacity: 0.9;
    margin-top: 8px;
    font-size: 16px;
}

.login-form {
    width: 100%;
    max-width: 320px;
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.demo-hint {
    color: rgba(255,255,255,0.7);
    font-size: 13px;
    margin-top: 24px;
    text-align: center;
}

/* ========================================
   SECTIONS
   ======================================== */

.section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 12px;
}

.section-hint {
    font-size: 13px;
    color: var(--danger);
    font-weight: 600;
    margin-bottom: 16px;
    padding: 10px;
    background: #fef2f2;
    border-radius: var(--radius-sm);
}

/* ========================================
   LOCATION
   ======================================== */

.location-box {
    background: white;
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.location-result {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.location-result.hidden {
    display: none;
}

.location-address {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 8px;
    font-size: 15px;
}

.location-coords {
    font-size: 13px;
    color: var(--gray-500);
    font-family: monospace;
}

/* ========================================
   RADIO GROUP (Type situation)
   ======================================== */

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    border: 2px solid var(--gray-200);
    transition: all 0.2s;
}

.radio-option:has(input:checked) {
    border-color: var(--primary);
    background: rgba(30, 64, 175, 0.05);
}

.radio-option input {
    display: none;
}

.radio-box {
    width: 24px;
    height: 24px;
    border: 2px solid var(--gray-400);
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

.radio-option:has(input:checked) .radio-box {
    border-color: var(--primary);
}

.radio-option:has(input:checked) .radio-box::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
}

.radio-label {
    font-weight: 500;
    font-size: 15px;
}

/* ========================================
   QUESTIONS
   ======================================== */

.questions-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.question-card {
    background: white;
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.question-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--gray-800);
    margin-bottom: 14px;
    line-height: 1.4;
}

.answer-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.answer-option {
    flex: 1;
    min-width: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    text-align: center;
}

.answer-option input {
    display: none;
}

.answer-option span {
    pointer-events: none;
}

/* OUI sélectionné */
.answer-oui:has(input:checked) {
    background: #dcfce7;
    border-color: var(--success);
    color: var(--success-dark);
}

/* NON sélectionné */
.answer-non:has(input:checked) {
    background: #fef2f2;
    border-color: var(--danger);
    color: var(--danger-dark);
}

/* Non concerné sélectionné */
.answer-nc:has(input:checked) {
    background: var(--gray-100);
    border-color: var(--gray-400);
    color: var(--gray-600);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-large {
    padding: 18px 32px;
    font-size: 18px;
}

.btn-block {
    width: 100%;
}

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

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

.btn-outline {
    background: white;
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
}

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

.btn-evaluate {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: white;
    font-size: 20px;
    padding: 20px;
    box-shadow: 0 4px 14px rgba(30, 64, 175, 0.4);
}

.btn-evaluate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30, 64, 175, 0.5);
}

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

.btn-white:hover {
    background: var(--gray-100);
}

/* ========================================
   FORMS
   ======================================== */

.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 500;
    font-size: 14px;
    color: var(--gray-700);
}

.form-group input {
    padding: 14px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

/* ========================================
   LEGAL FOOTER
   ======================================== */

.legal-footer {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

.legal-text {
    font-size: 12px;
    color: var(--gray-500);
    text-align: center;
    margin-bottom: 8px;
}

.legal-rule {
    font-size: 11px;
    color: var(--gray-400);
    text-align: center;
    line-height: 1.4;
}

/* ========================================
   RESULT SCREENS
   ======================================== */

.screen-result {
    background: var(--success);
}

.screen-result .result-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
    text-align: center;
    color: white;
}

.result-top {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
}

.result-stop {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.result-icon {
    font-size: 80px;
    margin-bottom: 16px;
}

.result-title {
    font-size: 64px;
    font-weight: 900;
    letter-spacing: 4px;
    margin-bottom: 8px;
}

.result-subtitle {
    font-size: 18px;
    font-weight: 600;
    opacity: 0.95;
    margin-bottom: 32px;
}

.result-message {
    background: rgba(255,255,255,0.15);
    padding: 24px;
    border-radius: var(--radius);
    margin-bottom: 32px;
    max-width: 320px;
}

.result-message p {
    font-size: 16px;
    margin-bottom: 8px;
}

.result-message p:last-child {
    margin-bottom: 0;
}

.result-reasons {
    background: rgba(255,255,255,0.15);
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    max-width: 320px;
    text-align: left;
}

.reasons-title {
    font-weight: 700;
    margin-bottom: 12px;
}

.result-reasons ul {
    list-style: none;
    padding-left: 0;
}

.result-reasons li {
    padding: 6px 0;
    padding-left: 24px;
    position: relative;
}

.result-reasons li::before {
    content: '⚠️';
    position: absolute;
    left: 0;
}

.result-actions {
    background: rgba(255,255,255,0.15);
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 32px;
    max-width: 320px;
    text-align: left;
}

.actions-title {
    font-weight: 700;
    margin-bottom: 12px;
}

.result-actions p {
    margin-bottom: 8px;
}

.result-badge {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 32px;
}

/* ========================================
   HISTORY
   ======================================== */

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    border-left: 4px solid var(--gray-300);
    transition: transform 0.2s;
}

.history-card:active {
    transform: scale(0.98);
}

.history-card.result-top-card {
    border-left-color: var(--success);
}

.history-card.result-stop-card {
    border-left-color: var(--danger);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 8px;
}

.history-result {
    font-size: 14px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
}

.history-result.top {
    background: #dcfce7;
    color: var(--success-dark);
}

.history-result.stop {
    background: #fef2f2;
    color: var(--danger-dark);
}

.history-date {
    font-size: 13px;
    color: var(--gray-500);
}

.history-address {
    font-weight: 600;
    font-size: 15px;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.history-situation {
    font-size: 13px;
    color: var(--gray-500);
}

.empty-history {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-history-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* ========================================
   DETAIL
   ======================================== */

.detail-content {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
}

.detail-section {
    padding: 16px;
    border-bottom: 1px solid var(--gray-100);
}

.detail-section:last-child {
    border-bottom: none;
}

.detail-label {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.detail-value {
    font-size: 15px;
    color: var(--gray-800);
}

.detail-result {
    text-align: center;
    padding: 24px;
}

.detail-result.top {
    background: #dcfce7;
}

.detail-result.stop {
    background: #fef2f2;
}

.detail-result-text {
    font-size: 24px;
    font-weight: 800;
}

.detail-result.top .detail-result-text {
    color: var(--success-dark);
}

.detail-result.stop .detail-result-text {
    color: var(--danger-dark);
}

.detail-questions {
    padding: 16px;
}

.detail-questions h3 {
    font-size: 14px;
    color: var(--gray-600);
    margin-bottom: 12px;
}

.detail-question-item {
    display: flex;
    justify-content: space-between;
    align-items: start;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
    gap: 12px;
}

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

.detail-q-text {
    font-size: 13px;
    color: var(--gray-700);
    flex: 1;
}

.detail-q-answer {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.detail-q-answer.oui {
    background: #dcfce7;
    color: var(--success-dark);
}

.detail-q-answer.non {
    background: #fef2f2;
    color: var(--danger-dark);
}

.detail-q-answer.nc {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ========================================
   TOAST & OFFLINE
   ======================================== */

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--gray-800);
    color: white;
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
    max-width: calc(100% - 40px);
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--warning);
    color: var(--gray-900);
    padding: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    transform: translateY(-100%);
    transition: transform 0.3s;
    z-index: 1001;
}

.offline-banner.show {
    transform: translateY(0);
}

.hidden {
    display: none !important;
}

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

@media (min-width: 768px) {
    .screen-content {
        max-width: 480px;
    }
}

/* ========================================
   BARRE DE NAVIGATION FIXE
   ======================================== */

.nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.nav-btn:active {
    background: var(--gray-100);
}

.nav-icon {
    font-size: 24px;
}

.nav-label {
    font-size: 11px;
    color: var(--gray-600);
    font-weight: 500;
}

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

.nav-logout .nav-label {
    color: var(--danger);
}

/* Ajuster le padding bottom des écrans pour la nav bar */
.screen.has-nav .screen-content {
    padding-bottom: 100px;
}

.screen.has-nav .result-content {
    padding-bottom: 100px;
}
