/* ============================================
   SignO — Styles V1
   Mobile-first, terrain-ready
   ============================================ */

/* --- Reset & base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-primary: #1a73e8;
    --color-primary-dark: #1557b0;
    --color-vert: #34a853;
    --color-orange: #f9a825;
    --color-rouge: #d93025;
    --color-bg: #f5f5f5;
    --color-surface: #ffffff;
    --color-text: #202124;
    --color-text-light: #5f6368;
    --color-border: #dadce0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.15);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.2);
    --topbar-height: 52px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    color: var(--color-text);
    background: var(--color-bg);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* --- Top bar --- */
#topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

#btn-menu {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}

#btn-menu:active {
    background: rgba(255,255,255,0.2);
}

#topbar-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.topbar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex: 1;
    overflow: hidden;
}

#topbar-plan-name {
    font-size: 12px;
    opacity: 0.85;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.btn-home {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.5);
    color: white;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-home:active {
    background: rgba(255,255,255,0.35);
}

/* --- Welcome screen --- */
#welcome-screen {
    position: fixed;
    inset: 0;
    top: var(--topbar-height);
    background: var(--color-bg);
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
}

.welcome-content {
    width: 100%;
    max-width: 420px;
    padding: 24px 20px 40px;
    text-align: center;
    margin: auto;
}

.welcome-city-logo {
    width: 160px;
    height: auto;
    margin-bottom: 6px;
}

.welcome-service {
    font-size: 11px;
    color: var(--color-text-light);
    letter-spacing: 0.3px;
    margin-bottom: 14px;
}

.welcome-logo {
    font-size: 38px;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.welcome-subtitle {
    font-size: 13px;
    color: var(--color-text-light);
    margin-bottom: 24px;
}

/* User selector */
.welcome-section {
    margin-bottom: 20px;
    text-align: left;
}

.welcome-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-light);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Action cards */
#welcome-actions {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 8px;
}

.welcome-action-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    width: 100%;
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px 18px;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    font-size: inherit;
    color: var(--color-text);
}

.welcome-action-card:hover,
.welcome-action-card:active {
    border-color: var(--color-primary);
    box-shadow: var(--shadow);
}

.plans-card {
    cursor: default;
}

.action-card-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.action-card-text {
    flex: 1;
    min-width: 0;
}

.action-card-title {
    font-size: 16px;
    font-weight: 600;
}

.action-card-desc {
    font-size: 13px;
    color: var(--color-text-light);
    margin-top: 2px;
}

/* Plans card controls */
.plans-card-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.plans-card-controls input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
}

.plans-card-controls input[type="text"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}

.plans-card-controls .btn-submit {
    margin-top: 4px;
}

.plans-card-controls .btn-submit:disabled {
    opacity: 0.5;
    cursor: default;
}

/* My reports panel */
#my-reports-panel {
    position: fixed;
    inset: 0;
    top: var(--topbar-height);
    background: var(--color-bg);
    z-index: 110;
    overflow-y: auto;
}

.reports-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 1;
}

.reports-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.reports-list {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.report-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    cursor: pointer;
    transition: border-color 0.15s;
    font-family: inherit;
    font-size: inherit;
    color: var(--color-text);
    text-align: left;
    width: 100%;
}

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

.report-item-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.report-item-body {
    flex: 1;
    min-width: 0;
}

.report-item-title {
    font-weight: 600;
    font-size: 14px;
}

.report-item-meta {
    font-size: 12px;
    color: var(--color-text-light);
    margin-top: 2px;
}

.report-item-urgency {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.reports-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-light);
    font-size: 14px;
}

/* --- Map --- */
#map {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    background: #e8e8e8;
}

/* --- Floating Action Button --- */
.fab {
    position: fixed;
    bottom: 24px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

.fab:active {
    transform: scale(0.92);
    background: var(--color-primary-dark);
}

.fab-icon {
    font-size: 30px;
    line-height: 1;
}

.fab.active {
    background: var(--color-rouge);
}

/* --- Annotation mode banner --- */
#annotation-banner {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    background: var(--color-primary);
    color: white;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 900;
    font-size: 14px;
    animation: slideDown 0.25s ease;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

#btn-cancel-annotation {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
}

/* --- Modal overlay --- */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

/* --- Modal form (bottom sheet on mobile) --- */
.modal {
    background: var(--color-surface);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    font-size: 26px;
    color: var(--color-text-light);
    cursor: pointer;
    padding: 4px 8px;
}

/* --- Form --- */
#form-annotation {
    padding: 8px 20px 24px;
}

.field {
    margin-bottom: 16px;
}

.field label, fieldset legend {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-light);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

fieldset {
    border: none;
    margin-bottom: 16px;
}

.field-error {
    border: 2px solid var(--color-rouge);
    border-radius: var(--radius-sm);
    padding: 8px;
    animation: shake 0.4s ease;
}

.field-error legend {
    color: var(--color-rouge);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* Symbol grid */
.symbol-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.symbol-option input { display: none; }

.symbol-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 4px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 22px;
    transition: border-color 0.15s, background 0.15s;
    text-align: center;
}

.symbol-card small {
    font-size: 11px;
    margin-top: 2px;
    color: var(--color-text-light);
}

.symbol-option input:checked + .symbol-card {
    border-color: var(--color-primary);
    background: rgba(26, 115, 232, 0.08);
}

/* Destinataires grid */
.destinataires-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px 12px;
}

.dest-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 6px;
}

.dest-option:active {
    background: rgba(26, 115, 232, 0.06);
}

.dest-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    flex-shrink: 0;
}

/* Urgency chips */
.urgency-row {
    display: flex;
    gap: 8px;
}

.urgency-option input { display: none; }

.urgency-chip {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    border: 2px solid transparent;
}

.urgency-vert {
    background: rgba(52, 168, 83, 0.15);
    color: var(--color-vert);
}
.urgency-orange {
    background: rgba(249, 168, 37, 0.15);
    color: #e6900e;
}
.urgency-rouge {
    background: rgba(217, 48, 37, 0.15);
    color: var(--color-rouge);
}

.urgency-option input:checked + .urgency-vert {
    background: var(--color-vert);
    color: white;
}
.urgency-option input:checked + .urgency-orange {
    background: #f9a825;
    color: white;
}
.urgency-option input:checked + .urgency-rouge {
    background: var(--color-rouge);
    color: white;
}

/* Text input / textarea */
textarea, select, input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    resize: vertical;
}

textarea:focus, select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235f6368' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* Photo */
.photo-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

input[type="file"] {
    font-size: 14px;
}

#photo-preview {
    width: 100%;
    max-height: 160px;
    overflow: hidden;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

#photo-preview img {
    width: 100%;
    height: auto;
    display: block;
}

/* Submit button */
.btn-submit {
    width: 100%;
    padding: 14px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
}

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

/* --- Side panel --- */
#side-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    background: var(--color-surface);
    z-index: 1500;
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    animation: slideRight 0.25s ease;
}

@keyframes slideRight {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

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

.panel-header h2 {
    font-size: 16px;
}

.panel-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
}

.panel-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 10px;
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
    cursor: pointer;
}

.layer-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
}

.annotation-count {
    font-size: 14px;
    color: var(--color-text-light);
}

/* --- Leaflet custom markers --- */
.marker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    font-size: 16px;
    line-height: 1;
}

.marker-icon span {
    transform: rotate(45deg);
}

.marker-vert { background: var(--color-vert); }
.marker-orange { background: #f9a825; }
.marker-rouge { background: var(--color-rouge); }

/* --- Detail panel (bottom sheet) --- */
#detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

#detail-panel {
    background: var(--color-surface);
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

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

.detail-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-header-left span:first-child {
    font-size: 22px;
}

.detail-header-left strong {
    font-size: 17px;
}

#detail-body {
    padding: 0 20px 8px;
    line-height: 1.6;
}

.popup-urgency {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: white;
}

.popup-text {
    margin: 8px 0;
    color: var(--color-text);
    font-size: 15px;
}

.detail-photo {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    margin: 10px 0;
    background: #f0f0f0;
}

.popup-meta {
    font-size: 13px;
    color: var(--color-text-light);
    line-height: 1.8;
    margin-top: 8px;
}

.detail-actions {
    display: flex;
    gap: 10px;
    padding: 12px 20px 20px;
}

.popup-btn {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--color-border);
    background: var(--color-surface);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
    color: var(--color-text);
}

.popup-btn:active {
    background: var(--color-bg);
}

.popup-btn.delete {
    color: var(--color-rouge);
    border-color: var(--color-rouge);
}

.popup-btn.delete:active {
    background: rgba(217, 48, 37, 0.06);
}

/* ---- Sub-plan bar ---- */
#subplan-bar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    z-index: 900;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    padding: 6px 10px;
}

#subplan-buttons {
    display: inline-flex;
    gap: 6px;
}

.subplan-btn {
    padding: 6px 14px;
    border: 1.5px solid var(--color-primary);
    border-radius: 20px;
    background: var(--color-surface);
    color: var(--color-primary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

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

.subplan-btn.disabled {
    opacity: 0.4;
    cursor: default;
    border-color: var(--color-text-light);
    color: var(--color-text-light);
}

#map.has-subplan-bar {
    top: calc(var(--topbar-height) + 42px);
}

/* ---- Notification badge ---- */
#notif-badge {
    position: fixed;
    top: 58px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    background: var(--color-rouge);
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    animation: slideDown 0.3s ease;
    pointer-events: none;
}

/* --- Responsive adjustments --- */
@media (min-width: 600px) {
    .modal {
        border-radius: var(--radius);
        margin-bottom: 20px;
    }

    #modal-overlay {
        align-items: center;
    }

    #detail-overlay {
        align-items: center;
    }

    #detail-panel {
        border-radius: var(--radius);
        margin-bottom: 20px;
    }
}
