* {
    box-sizing: border-box;
}

:root {
    --scale-factor: 1;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: #07151d;
    color: white;
    font-family: Aptos, Inter, "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}

input {
    padding: 8px;
    width: 200px;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.9;
}

button {
    padding: 8px 12px;
    cursor: pointer;
}

.map-scroll-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    align-items: start;
    justify-items: center;
    gap: 10px;
    padding: 0 10px 0 0;
}

.map-wrapper {
    position: relative;
    width: min(calc(100vw - 270px), 133.333333vh);
    width: min(calc(100vw - 270px), 133.333333dvh);
    aspect-ratio: 4 / 3;
}

#map {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#spots {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.date-label {
    position: absolute;
    top: 2%;
    left: 2%;
    z-index: 6;
    padding: calc(4px * var(--scale-factor)) calc(8px * var(--scale-factor));
    background: rgba(255, 255, 255, 0.82);
    border-radius: calc(4px * var(--scale-factor));
    color: #07151d;
    font-size: calc(18px * var(--scale-factor));
    font-weight: bold;
    pointer-events: none;
}

.custom-tooltip {
    position: fixed;
    z-index: 2000;
    max-width: 240px;
    padding: 7px 10px;
    background: #101922;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    color: #f8fafc;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
    font-size: 12px;
    font-weight: 650;
    opacity: 0;
    pointer-events: none;
}

.custom-tooltip.is-visible {
    opacity: 1;
}

.spot {
    position: absolute;

    width: calc(35px * var(--scale-factor));
    height: calc(18px * var(--scale-factor));

    display: flex;
    align-items: center;
    justify-content: center;

    transform: translate(-50%, -50%);

    background: rgba(0, 180, 255, 0.9);
    border: calc(2px * var(--scale-factor)) solid white;
    border-radius: calc(4px * var(--scale-factor));

    font-size: calc(13px * var(--scale-factor));
    font-weight: bold;

    pointer-events: auto;
    z-index: 5;

    box-sizing: border-box;
    cursor: pointer;
}

.width-2-5 {
    background: #22c55e;
    border-color: #86efac;
}

.width-3 {
    background: #3b82f6;
    border-color: #bfdbfe;
}

.width-3-5 {
    background: #fde047;
    border-color: #fef9c3;
}

.width-3-75 {
    background: #fb923c;
    border-color: #fed7aa;
}

.width-4 {
    background: #ef4444;
    border-color: #fecaca;
}

.width-4-5 {
    background: #a855f7;
    border-color: #ddd6fe;
}

.width-4-8 {
    background: #ec4899;
    border-color: #fbcfe8;
}

.width-default {
    background: rgba(0, 180, 255, 0.9);
    border-color: white;
}

textarea {
    width: 100%;
    height: 250px;
    margin-top: 20px;
    background: #10232d;
    color: #00d4ff;
    border: none;
    padding: 10px;
    box-sizing: border-box;
}

.vertical {
    transform: translate(-50%, -50%) rotate(90deg);
}

.client-name {
    position: absolute;
    transform: translateY(-50%);
    white-space: nowrap;
    pointer-events: auto;
    font-weight: bold;
    font-size: calc(14px * var(--scale-factor));
    color: #ff00ff;
    border-radius: calc(3px * var(--scale-factor));
    padding: calc(1px * var(--scale-factor)) calc(3px * var(--scale-factor));
    text-shadow: 0 0px 0 rgba(0, 0, 0, 0.6);
    z-index: 4;
    cursor: pointer;
}

.client-name.is-present {
    background: #18f0de;
}

.client-name.is-amodiataire {
    color: #303030;
}

.client-name.has-no-rental-location {
    color: #f59e0b;
}

.client-name.is-alert-name {
    color: #ef4444;
}

.client-name.has-missing-documents {
    background: #ef4444;
    color: #ffffff;
}

.client-name.is-outing {
    background:
        repeating-linear-gradient(
            135deg,
            rgba(252, 165, 165, 0.95) 0,
            rgba(252, 165, 165, 0.95) calc(3px * var(--scale-factor)),
            rgba(255, 255, 255, 0.7) calc(3px * var(--scale-factor)),
            rgba(255, 255, 255, 0.7) calc(6px * var(--scale-factor))
        );
    box-shadow: 0 0 0 calc(1px * var(--scale-factor)) #ef4444;
    color: #111827;
}

.client-name.vertical-name {
    transform: translate(-50%, 130%) rotate(90deg);
    transform-origin: bottom bottom;
    white-space: nowrap;
    font-size: calc(14px * var(--scale-factor));
}

.outings-panel {
    width: 260px;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
    background: #101922;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
}

.side-panel {
    display: grid;
    align-content: start;
    gap: 10px;
    width: 260px;
}

.outings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 14px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    background: #0c141c;
    color: #f8fafc;
    font-weight: bold;
}

.outings-header strong {
    min-width: 28px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #38bdf8;
    color: #082f49;
    text-align: center;
}

.outings-selection-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 10px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.outings-bulk-btn {
    width: 100%;
    padding: 10px 12px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.32);
    border-radius: 8px;
    color: #7dd3fc;
    font-weight: 750;
}

.outings-bulk-btn:hover,
.archive-btn:hover {
    background: rgba(56, 189, 248, 0.18);
    color: #bae6fd;
}

body.outing-selection-mode .client-name {
    outline: calc(2px * var(--scale-factor)) solid rgba(239, 68, 68, 0.8);
    outline-offset: calc(2px * var(--scale-factor));
}

body.outing-selection-mode .client-name:hover {
    filter: brightness(1.12);
}

.outings-list {
    display: grid;
    gap: 6px;
    max-height: calc(100vh - 86px);
    max-height: calc(100dvh - 86px);
    margin: 0;
    padding: 10px;
    overflow-y: auto;
    list-style: none;
}

.outings-list:empty {
    padding: 0;
}

.outings-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 8px;
    color: #f8fafc;
    font-size: 13px;
}

.outings-list small {
    color: #94a3b8;
    white-space: nowrap;
}

.archives-panel {
    width: 260px;
    padding: 14px;
    background: #101922;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
}

.archives-header {
    margin-bottom: 10px;
    color: #f8fafc;
    font-weight: bold;
}

.archive-select {
    width: 100%;
    padding: 10px 12px;
    background: #0f172a;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    color: #f8fafc;
}

.archives-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-top: 8px;
}

.archive-btn {
    width: 100%;
    padding: 10px 12px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.32);
    border-radius: 8px;
    color: #7dd3fc;
    font-weight: 750;
}

.archive-status {
    margin-top: 10px;
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 12px;
}

body.archive-mode .archives-panel {
    border-color: #f59e0b;
}

body.archive-mode .archive-status {
    color: #fbbf24;
    font-weight: bold;
}

body.archive-mode .spot,
body.archive-mode .client-name {
    cursor: default;
}

.modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 10, 15, 0.72);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-content {
    background: #101922;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 12px;
    padding: 0;
    max-width: 620px;
    max-height: 96vh;
    max-height: 96dvh;
    width: 90%;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    color: white;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    background: #0c141c;
}

.modal-header h2 {
    margin: 0;
    font-size: clamp(18px, 4vw, 24px);
    color: #f8fafc;
    letter-spacing: 0;
}

.modal-close {
    width: 34px;
    height: 34px;
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 50%;
    color: #cbd5e1;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(148, 163, 184, 0.18);
    color: white;
}

.modal-body {
    padding: clamp(18px, 4vw, 24px);
    max-height: calc(96vh - 58px);
    max-height: calc(96dvh - 58px);
    overflow-y: auto;
}

.modal-field {
    margin-bottom: 16px;
}

.modal-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 650;
    color: #94a3b8;
    font-size: 12px;
    text-transform: uppercase;
}

.modal-value {
    display: block;
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    color: #f8fafc;
    font-size: 14px;
}

.client-name-edit {
    display: flex;
    gap: 10px;
    align-items: center;
}

.client-name-edit input {
    flex: 1;
    min-width: 0;
    padding: 11px 12px;
    background: #0f172a;
    border: 1px solid rgba(148, 163, 184, 0.28);
    color: #f8fafc;
    border-radius: 8px;
    font-size: 15px;
}

.client-name-edit input:focus {
    outline: none;
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}

.client-status-edit {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    margin: 0;
    padding: 8px 14px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 999px;
    color: #e2e8f0;
    font-size: 14px;
    text-transform: none;
    cursor: pointer;
}

.toggle-label {
    min-width: 0;
    white-space: nowrap;
}

.client-status-edit:has(input:checked) {
    border-color: rgba(56, 189, 248, 0.58);
    background: rgba(56, 189, 248, 0.18);
    color: #f8fafc;
}

.status-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.client-status-edit input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.outing-field {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.outing-toggle {
    justify-content: center;
    width: 100%;
    display: inline-flex;
    text-align: center;
    border-color: rgba(248, 113, 113, 0.36);
    background: rgba(127, 29, 29, 0.18);
    color: #fecaca;
    letter-spacing: 0.04em;
}

.outing-toggle:has(input:checked) {
    border-color: rgba(239, 68, 68, 0.72);
    background: rgba(239, 68, 68, 0.28);
    color: #fff1f2;
}

.outing-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    accent-color: #ef4444;
}

.locations-section[hidden] {
    display: none;
}

#locations-list {
    display: grid;
    gap: 8px;
}

.location-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) 130px 130px 32px;
    gap: 8px;
    align-items: center;
}

.location-row input {
    width: 100%;
    min-width: 0;
    padding: 10px;
    background: #0f172a;
    border: 1px solid rgba(148, 163, 184, 0.28);
    color: #f8fafc;
    border-radius: 8px;
    font-size: 13px;
}

.document-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.documents-list {
    display: grid;
    gap: 12px;
}

.person-documents {
    padding: 10px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 10px;
}

.person-documents-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.person-documents-header strong {
    min-width: 0;
    overflow: hidden;
    color: #f8fafc;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.person-documents-header span {
    flex: 0 0 auto;
    color: #94a3b8;
    font-size: 12px;
}

.documents-empty {
    padding: 10px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 10px;
    color: #94a3b8;
    font-size: 13px;
}

.document-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 8px;
    align-items: stretch;
}

.document-link {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 9px 12px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.32);
    border-radius: 8px;
    color: #7dd3fc;
    font-size: 14px;
    font-weight: 750;
    text-align: center;
    text-decoration: none;
}

.document-link:hover {
    background: rgba(56, 189, 248, 0.18);
    color: #bae6fd;
}

.modal-field .insurance-validity-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px;
    gap: 8px;
    align-items: center;
    margin: 2px 0 0;
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 650;
}

.modal-field .insurance-validity-row input {
    width: 150px;
    height: 38px;
    padding: 8px 10px;
    background: #0f172a;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    color: #f8fafc;
    font: inherit;
}

.modal-field .insurance-validity-row input:focus {
    outline: none;
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}

.document-upload {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    width: 112px;
    margin: 0;
    margin-bottom: 0;
    padding: 9px 12px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 750;
    line-height: 1;
    cursor: pointer;
    text-transform: none;
}

.modal-field .document-upload {
    display: flex;
    margin: 0;
    color: #e2e8f0;
    font-size: 13px;
}

.document-upload:hover {
    background: rgba(148, 163, 184, 0.14);
}

.document-upload.is-dragover {
    background: rgba(56, 189, 248, 0.2);
    border-color: rgba(125, 211, 252, 0.85);
    color: #e0f2fe;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}

.document-upload input {
    display: none;
}

.document-upload.is-hidden,
.document-delete.is-hidden {
    display: none;
}

.document-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    width: 112px;
    margin: 0;
    padding: 9px 12px;
    background: rgba(127, 29, 29, 0.18);
    border: 1px solid rgba(248, 113, 113, 0.36);
    border-radius: 8px;
    color: #fecaca;
    font-size: 13px;
    font-weight: 750;
    line-height: 1;
    cursor: pointer;
}

.document-delete:hover {
    background: rgba(239, 68, 68, 0.28);
    color: #fff1f2;
}

.document-upload-status {
    min-height: 18px;
    margin-top: 8px;
    color: #cbd5e1;
    font-size: 12px;
}

.btn-secondary,
.btn-remove-location {
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

.btn-secondary {
    margin-top: 8px;
    padding: 9px 12px;
    background: rgba(56, 189, 248, 0.1);
    color: #7dd3fc;
    border: 1px solid rgba(56, 189, 248, 0.32);
}

.btn-remove-location {
    width: 32px;
    height: 32px;
    padding: 0;
    background: #ef4444;
    color: white;
    font-size: 20px;
    line-height: 1;
}

.btn-save {
    padding: 11px 16px;
    background: #38bdf8;
    border: none;
    color: #082f49;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 750;
    transition: background 0.2s, transform 0.2s;
    font-size: 14px;
}

.btn-save:hover {
    background: #7dd3fc;
    transform: translateY(-1px);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .map-scroll-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        align-content: start;
        gap: 8px;
        padding: 0 8px 8px;
        overflow-y: auto;
    }

    .map-wrapper {
        width: min(100%, 133.333333vh);
        width: min(100%, 133.333333dvh);
    }

    .client-name,
    .client-name.vertical-name {
        font-size: calc(7px * var(--scale-factor));
    }

    .side-panel,
    .outings-panel,
    .archives-panel {
        width: 100%;
    }

    .outings-panel {
        max-height: none;
    }

    .outings-header {
        padding: 7px 9px;
        font-size: 13px;
    }

    .outings-list {
        max-height: 28vh;
        max-height: 28dvh;
    }

    .outings-list li {
        padding: 5px 9px;
        font-size: 12px;
    }

    .modal-content {
        width: 95%;
        max-width: 90vw;
    }
}

@media (max-width: 480px) {
    .location-row {
        grid-template-columns: 1fr 1fr 32px;
    }

    .location-name-input {
        grid-column: 1 / -1;
    }

    .modal-field .insurance-validity-row {
        grid-template-columns: 1fr;
    }

    .modal-field .insurance-validity-row input {
        width: 100%;
    }

    .modal-content {
        width: 98%;
        max-width: 98vw;
    }
}
