/* =====================================================================
   CIVIC THEME  —  Step 6: modals
   ---------------------------------------------------------------------
   Additive. Loads last, AFTER civic-theme-step5-calendar.css.

   Reskins the four modals (location map, new post, business-card QR,
   event details) onto the redesign surface: neutral scrim, white card
   with a 16px radius and soft shadow, a bordered header row with a
   close ×, and a right-aligned slate/ghost button footer.

   Ships with the `.modal-head` / `.modal-body` / `.modal-foot` /
   `.modal-x` markup in templates/index.html.
   ===================================================================== */

/* ---- Scrim + card ---------------------------------------------------- */
.modal {
    background-color: rgba(27, 31, 38, .55);
    backdrop-filter: blur(2px);
}
.modal-content {
    background: #ffffff;
    border: 1px solid #e6e8ec;
    border-radius: 16px;
    box-shadow: 0 24px 55px -22px rgba(30, 40, 60, .55);
    padding: 0;
    text-align: left;
    max-width: 480px;
}
#postModal .modal-content {
    max-width: 600px;
}

/* ---- Header ---------------------------------------------------------- */
.modal-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid #eceef2;
}
.modal-head-icon {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
    opacity: .7;
}
.modal-title {
    font-family: obida, Georgia, serif;
    font-size: 1.3em;
    line-height: 1.1;
    color: #1b1f26;
    flex: 1;
    min-width: 0;
}
.modal-x {
    font-size: 1.5em;
    line-height: 1;
    color: #9aa0ab;
    padding: 0 2px;
    transition: color .15s ease;
}
.modal-x:hover {
    color: #1b1f26;
}

/* ---- Body + footer --------------------------------------------------- */
.modal-body {
    padding: 16px 20px;
}
.modal-note {
    font-size: .85em;
    line-height: 1.55;
    color: #6b727e;
    margin: 0;
}
.modal-foot {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 0 20px 18px;
}
.modal-foot .btn,
.action-btns .btn-post {
    font-size: .85em;
    font-weight: 600;
    border-radius: 9px;
    padding: 10px 18px;
    height: auto;
    margin: 0;
    border: 1px solid transparent;
}
.modal-foot .btn-cancel,
.action-btns .btn-cancel {
    color: #5a616e;
    background: #ffffff;
    border-color: #d3d9e6;
}
.modal-foot .btn-submit,
.action-btns .btn-submit {
    color: #ffffff;
    background: #566277;
}
.action-btns {
    gap: 10px;
    margin: 1.4em 0 0;
    padding: 16px 20px 18px;
    border-top: 1px solid #eceef2;
}
.action-btns .btn-post {
    margin-right: 0;   /* the old rule pushed both buttons 3em off the edge */
}

/* ---- Location map ---------------------------------------------------- */
#map {
    width: 100%;
    height: 320px;
    margin: 0;
    border-top: 1px solid #eceef2;
    border-bottom: 1px solid #eceef2;
}
.center-marker {
    width: 52px;
    height: 52px;
}
#mapModal .modal-body {
    padding: 16px 20px 4px;
}

/* MapLibre's own controls, matched to the card. */
#map .maplibregl-ctrl-group {
    border: 1px solid #d3d9e6;
    border-radius: 8px;
    box-shadow: none;
    overflow: hidden;
}

/* ---- New post form --------------------------------------------------- */
.post-form {
    padding: 0;
}
.post-form form {
    padding: 16px 20px 4px;
}
.post-form .form-group label {
    font-size: .85em;
    font-weight: 600;
    color: #6b727e;
}
.post-form input[type="text"],
.post-form select,
.post-form textarea {
    background: #f5f6f8;
    border: 1px solid #e6e8ec;
    border-radius: 9px;
    color: #1b1f26;
}
/* The paired <input type=file> is hidden, so the label is the button —
   size it like one instead of letting it span the whole row. */
#photo-label {
    background: #566277;
    border-radius: 9px;
    font-size: .85em;
    font-weight: 600;
    padding: 9px 16px;
    margin: 0 0 0 auto;
    flex: 0 0 auto;
}
#imgPre {
    border-radius: 10px;
    margin-top: .8em;
}

/* ---- Business card QR ------------------------------------------------ */
#QRModal .modal-body {
    text-align: center;
}
#qrcode {
    margin-bottom: 1em;
}
#qrcode img,
#qrcode canvas {
    margin: 0 auto;
    border-radius: 10px;
}

/* ---- Event details --------------------------------------------------- */
#event-details {
    margin: 0;
}
#event-details h2 {
    font-family: 'Newsreader', Georgia, serif;
    font-size: 1.5em;
    font-weight: 600;
    line-height: 1.2;
    color: #1b1f26;
    margin: 0 0 12px;
}
#eventModal .event-row {
    display: flex;
    gap: 10px;
    font-size: .9em;
    line-height: 1.6;
}
#eventModal .event-key {
    color: #8a90a0;
    min-width: 48px;
    flex-shrink: 0;
}
#eventModal .event-val {
    color: #1b1f26;
    font-weight: 600;
    min-width: 0;
}
#eventContent {
    margin: 12px 0 0;
    font-size: .9em;
    line-height: 1.6;
    color: #4a505b;
}
#event-details img {
    border-radius: 10px;
    margin-top: 12px;
}

/* ---- Toasts ---------------------------------------------------------- */
.toast {
    font-size: 1em;
    padding: 14px 20px;
    border-radius: 12px;
    background: #ffffff;
    color: #1b1f26;
    border: 1px solid #e6e8ec;
    box-shadow: 0 18px 40px -22px rgba(30, 40, 60, .5);
}
.toast.success {
    background: #eef2f7;
    border-color: #d3dbe8;
    color: #2c3e5e;
    box-shadow: 0 18px 40px -22px rgba(30, 40, 60, .5);
}
.toast.error {
    background: #fdeeed;
    border: 1px solid #f2c4c0;
    color: #a33328;
    box-shadow: 0 18px 40px -22px rgba(30, 40, 60, .5);
}
.toast.warning {
    background: #fdf6e3;
    border: 1px solid #ecdcae;
    color: #7a5a0b;
    box-shadow: 0 18px 40px -22px rgba(30, 40, 60, .5);
}

@media (max-width: 600px) {
    .modal-content {
        max-width: 100%;
    }
    #map {
        height: 300px;
    }
}

/* ---- New post: fit without scrolling -------------------------------
   The form was tall enough to scroll inside .modal-content on a laptop.
   Tightening the rows, shrinking the controls and capping the textarea
   gets the whole thing on screen; the modal still scrolls if a small
   viewport genuinely can't hold it. */
#postModal .modal-content {
    max-height: 92vh;
}
.post-form form {
    padding: 14px 20px 2px;
}
.post-form .form-group {
    margin-bottom: 7px;
}
.post-form .form-group label {
    flex: 0 0 92px;
    text-align: right;
}
.post-form input[type="text"],
.post-form select,
.post-form textarea {
    height: auto;
    padding: 7px 11px;
    margin-bottom: 0;
    font-size: .9em;
}
.post-form textarea#content {
    max-height: 22vh;
}
.post-form textarea#where {
    max-height: 12vh;
}
.post-form input[type="datetime-local"],
.post-form input[type="file"] {
    font-size: .85em;
}

/* ---- "This post is an event" switch --------------------------------
   Was a bare checkbox on a right-aligned form row above the title, which
   read like a field rather than the mode change it is. Now a full-width
   control sitting under Content, where the event fields it reveals appear. */
.event-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0 10px;
    padding: 10px 13px;
    background: #f5f6f8;
    border: 1px solid #e6e8ec;
    border-radius: 10px;
    transition: background .15s ease, border-color .15s ease;
}
.event-switch:hover {
    background: #eef1f7;
    border-color: #dbe0ea;
}
.event-switch-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}
.event-switch-title {
    font-size: .88em;
    font-weight: 600;
    color: #1b1f26;
    line-height: 1.3;
}
.event-switch-hint {
    font-size: .76em;
    color: #8a90a0;
}
/* The native box drives state; the track below is what you actually see. */
.event-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    transform: none;
}
.event-switch-track {
    position: relative;
    flex: 0 0 42px;
    height: 24px;
    border-radius: 20px;
    background: #d3d9e6;
    transition: background .18s ease;
}
.event-switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(30, 40, 60, .3);
    transition: transform .18s ease;
}
.event-switch input:checked ~ .event-switch-track {
    background: #566277;
}
.event-switch input:checked ~ .event-switch-track::after {
    transform: translateX(18px);
}
.event-switch input:focus-visible ~ .event-switch-track {
    outline: 2px solid #566277;
    outline-offset: 2px;
}

/* ---- Profile editor modal ------------------------------------------ */
#profileModal .modal-content {
    max-width: 620px;
    max-height: 92vh;
}
#profileModal .modal-body {
    padding: 16px 20px 4px;
}
#profileModal .profile-wide {
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
    border-radius: 0;
}
/* The form markup is a chota two-column row, which is far too tight inside a
   modal — it forced a horizontal scrollbar and clipped the email. Stack it. */
#profileModal .row {
    flex-direction: column;
    margin: 0;
}
#profileModal .col,
#profileModal .col-6,
#profileModal .col-12 {
    flex: 1 1 auto;
    max-width: 100%;
    width: 100%;
    min-width: 0;
    padding: 0;
}
#profileModal .form-group {
    margin-bottom: 9px;
    gap: 10px;
}
#profileModal .form-group label {
    flex: 0 0 150px;
    text-align: right;
}
#profileModal .form-group span,
#profileModal .form-group input,
#profileModal .form-group textarea {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: 0;
    overflow-wrap: anywhere;
}
#profileModal #avatar,
#profileModal .croppr,
#profileModal .cropper img {
    width: 140px;
    height: 140px;
    border-radius: 12px;
    object-fit: cover;
    margin: 0 auto;
}
#profileModal .img-model {
    display: block;
}
#profileModal .profile-controls {
    text-align: center;
    margin-bottom: .8em;
}
#profileModal .cropper {
    max-width: 260px;
    margin: 0 auto;
}
/* The edit/save buttons sit at the end of the form, after the float-right
   helpers — give them a row of their own so they don't collide. */
#profileModal .profile > .btn,
#profileModal .profile > .btn-action {
    margin-top: 10px;
}
#profileModal .profile::after {
    content: "";
    display: block;
    clear: both;
}

@media (max-width: 600px) {
    /* Narrow the label gutter so the controls (and the native date picker's
       own button) aren't clipped at the modal edge. */
    .post-form .form-group label {
        flex: 0 0 78px;
        font-size: .8em;
    }
    #profileModal .form-group label {
        flex: 0 0 108px;
        font-size: .8em;
    }
    .post-form form,
    #profileModal .modal-body {
        padding-left: 14px;
        padding-right: 14px;
    }
    .event-switch {
        padding: 10px 11px;
        gap: 10px;
    }
}
