/**
 * Interactive Maps - Styles
 * Version: 2.6.0
 *
 * v2.1: admin CSS classes replacing inline styles; dynamic map height.
 * v2.2: modal number inputs, coord row, preview/provisional markers, geo-error modal.
 * v2.3: ilm-info font-size 16px; ilm-btn gradient + 3D press; coloured type markers.
 * v2.4: .ilm-admin-map embedded map in Add/Edit pin forms.
 *
 * v2.5 additions:
 *  - .ilm-notice bar (replaces alert() — F2)
 *  - .ilm-loading overlay with spinner (F4)
 *  - .ilm-confirm-content — generic confirm modal styling (F2)
 *  - .ilm-layer-control + .ilm-layer-toggle + .ilm-layer-swatch (F5)
 *  - .ilm-popup-desc, .ilm-popup-coords, .ilm-popup-link (D2, D3)
 *  - .ilm-modal-content textarea styling (F3)
 *  - .ilm-col-bar + .ilm-col-toggle + .ilm-col-total (C1-C12)
 *  - .ilm-status-pending (A3)
 *  - .ilm-btn-danger (F2 confirm button)
 *
 * v2.6 additions:
 *  - Fix 1: .ilm-col-bar vertical layout (matches Books v3.5 pattern)
 *  - Fix 2: sorted/sortable column header styles (match WP_List_Table)
 *  - Fix 5: .ilm-settings-group outer grouping box
 *  - Fix 6: .ilm-type-preview marker icon preview container
 */

/* ── Map container ──────────────────────────────────────────────────────── */

.ilm-container {
    position: relative;  /* anchor for loading overlay */
    margin: 20px 0;
}

#ilm-map {
    width: 100%;
    /* Height set dynamically via inline style from ilm_map_height option. */
    border: 2px solid #ddd;
    border-radius: 4px;
}

/* ── Notice bar (F2 — replaces alert()) ─────────────────────────────────── */

.ilm-notice {
    padding: 10px 16px;
    margin-bottom: 8px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
}

.ilm-notice-info    { background: #e7f3ff; border-color: #b8d9f8; color: #0c5080; }
.ilm-notice-success { background: #eaffea; border-color: #9ad09a; color: #185c18; }
.ilm-notice-error   { background: #fff0f0; border-color: #f5b8b8; color: #7b1111; }

/* ── Loading overlay (F4) ───────────────────────────────────────────────── */

.ilm-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.75);
    padding: 16px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.ilm-loading-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #ddd;
    border-top-color: #0078A8;
    border-radius: 50%;
    animation: ilm-spin 0.8s linear infinite;
}

@keyframes ilm-spin {
    to { transform: rotate(360deg); }
}

/* ── Controls bar ───────────────────────────────────────────────────────── */

.ilm-controls {
    padding: 15px;
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.ilm-btn {
    padding: 10px 20px;
    margin: 5px;
    background: linear-gradient(to bottom, #1a91c4, #0078A8);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
    transition: background 0.2s ease, box-shadow 0.1s ease;
}

.ilm-btn:hover   { background: linear-gradient(to bottom, #1e9fd8, #006f9a); box-shadow: 0 3px 6px rgba(0,0,0,.3); }
.ilm-btn:active  { background: linear-gradient(to bottom, #0078A8, #005a7d); box-shadow: inset 0 2px 4px rgba(0,0,0,.2); }
.ilm-btn:disabled { background: #ccc; box-shadow: none; cursor: not-allowed; }

.ilm-btn-secondary         { background: linear-gradient(to bottom, #888, #666); }
.ilm-btn-secondary:hover   { background: linear-gradient(to bottom, #999, #777); }
.ilm-btn-secondary:active  { background: linear-gradient(to bottom, #666, #444); box-shadow: inset 0 2px 4px rgba(0,0,0,.2); }

.ilm-btn-danger            { background: linear-gradient(to bottom, #e8424f, #dc3545); }
.ilm-btn-danger:hover      { background: linear-gradient(to bottom, #ec5460, #c82333); }
.ilm-btn-danger:active     { background: linear-gradient(to bottom, #dc3545, #a71d2a); box-shadow: inset 0 2px 4px rgba(0,0,0,.2); }

/* ── Info / instructions (above buttons, 16px) ──────────────────────────── */

.ilm-info {
    padding: 10px;
    background: #e7f3ff;
    margin-bottom: 10px;
    border-radius: 4px;
    font-size: 16px;
}

/* ── Coloured divIcon per pin type ──────────────────────────────────────── */

.ilm-type-marker { background: transparent; border: none; }

.ilm-type-inner {
    width: 20px;
    height: 20px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,.3);
}

/* ── Modal overlay ──────────────────────────────────────────────────────── */

.ilm-modal {
    position: fixed;
    z-index: 10000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: transparent;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 0;
    pointer-events: none;
}

.ilm-modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,.3);
    max-width: 500px;
    width: 90%;
    margin-top: 12vh;
    margin-right: 5vw;
    pointer-events: auto;
    max-height: 80vh;
    overflow-y: auto;
}

.ilm-modal-content h3 { margin-top: 0; margin-bottom: 20px; }

.ilm-modal-content label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.ilm-modal-content input[type="text"],
.ilm-modal-content input[type="number"],
.ilm-modal-content select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 16px;
    box-sizing: border-box;
}

.ilm-modal-content input[type="number"] { -moz-appearance: textfield; }
.ilm-modal-content input[type="number"]::-webkit-inner-spin-button,
.ilm-modal-content input[type="number"]::-webkit-outer-spin-button { opacity: 1; }

/* Description textarea (F3) */
.ilm-modal-content textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 16px;
    box-sizing: border-box;
    resize: vertical;
    font-family: inherit;
}

.ilm-modal-buttons { display: flex; gap: 10px; justify-content: flex-end; }

/* Generic confirm modal — more centred than the location modal */
.ilm-confirm-content {
    margin-top: 40vh;
    transform: translateY(-50%);
    max-width: 360px;
}

.ilm-confirm-content p { margin: 0 0 20px; font-size: 15px; }

/* ── Popup content ──────────────────────────────────────────────────────── */

.ilm-popup             { font-size: 14px; line-height: 1.6; }
.ilm-popup strong      { color: #333; }
.ilm-popup-desc        { margin: 6px 0; color: #555; font-size: 13px; }
.ilm-popup-coords      { font-size: 12px; color: #888; }
.ilm-popup-link        { display: inline-block; margin-top: 6px; font-size: 13px; color: #0078A8; text-decoration: underline; }
.ilm-popup-link:hover  { color: #005a7d; }

.ilm-delete-pin {
    margin-top: 10px;
    padding: 6px 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.ilm-delete-pin:hover { background: #c82333; }

/* ── Coordinate adjustment ──────────────────────────────────────────────── */

.ilm-coord-row   { display: flex; gap: 12px; margin-bottom: 4px; }
.ilm-coord-field { flex: 1; min-width: 0; }
.ilm-coord-field label { display: block; margin-bottom: 6px; font-weight: bold; font-size: 14px; }

.ilm-coord-hint {
    font-size: 12px;
    color: #666;
    margin: 0 0 16px;
    line-height: 1.5;
}

/* ── Preview marker ─────────────────────────────────────────────────────── */

.ilm-preview-marker { background: transparent; border: none; cursor: grab; }

.ilm-preview-inner {
    width: 22px; height: 22px;
    background: rgba(255,255,255,.6);
    border: 2px dashed #000;
    border-radius: 50%;
    box-sizing: border-box;
}

/* ── Provisional pulsing marker ─────────────────────────────────────────── */

.ilm-provisional-marker { background: transparent; border: none; }

.ilm-provisional-inner {
    width: 22px; height: 22px;
    background: #e8820c;
    border: 2px solid #fff;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 2px 4px rgba(0,0,0,.3);
    animation: ilm-pulse 1.6s ease-in-out infinite;
}

@keyframes ilm-pulse {
    0%   { box-shadow: 0 0 0 0    rgba(232,130,12,.7), 0 2px 4px rgba(0,0,0,.3); }
    60%  { box-shadow: 0 0 0 10px rgba(232,130,12,0),  0 2px 4px rgba(0,0,0,.3); }
    100% { box-shadow: 0 0 0 0    rgba(232,130,12,0),  0 2px 4px rgba(0,0,0,.3); }
}

/* ── Confirm popup (inside Leaflet popup) ───────────────────────────────── */

.ilm-confirm-note {
    font-size: 12px; color: #e8820c; font-style: italic;
    margin: 0 0 8px; line-height: 1.4;
}

.ilm-confirm-popup .ilm-btn {
    display: block; width: 100%;
    padding: 7px 10px; margin: 6px 0 0;
    font-size: 12px; text-align: center;
    box-sizing: border-box;
}

/* ── Geo-error modal ────────────────────────────────────────────────────── */

.ilm-browser-steps {
    background: #f0f7ff;
    border-left: 4px solid #0078A8;
    padding: 12px 14px; border-radius: 4px;
    font-size: 13px; line-height: 1.6; margin: 10px 0;
}
.ilm-browser-steps p { margin: 4px 0; }

.ilm-geo-reload-hint { font-size: 12px; color: #666; margin: 8px 0 16px; line-height: 1.5; }

/* ── Layer control panel (F5) ───────────────────────────────────────────── */

.ilm-layer-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255,255,255,.92);
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    margin-top: 6px;
}

.ilm-layer-control strong { margin-right: 6px; }

.ilm-layer-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-weight: normal;
}

.ilm-layer-swatch {
    display: inline-block;
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,.2);
    flex-shrink: 0;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    #ilm-map { max-height: 400px; }
    .ilm-btn { display: block; width: 100%; margin: 5px 0; }
    .ilm-controls { padding: 10px; }
    .ilm-modal-content { padding: 20px; }
}

@media (max-width: 480px) {
    .ilm-coord-row { flex-direction: column; gap: 0; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ADMIN PAGE STYLES
   ═══════════════════════════════════════════════════════════════════════════ */

.ilm-admin-card {
    background: #fff;
    padding: 20px;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    margin: 20px 0;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
}

.ilm-admin-actions {
    margin: 20px 0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ilm-status-active  { color: #46b450; font-weight: 600; }
.ilm-status-retired { color: #999;    font-weight: 600; }
.ilm-status-pending { color: #d68910; font-weight: 600; }  /* A3 */

/* ── Admin Leaflet map (Add/Edit forms) ─────────────────────────────────── */

.ilm-admin-map {
    height: 300px;
    max-width: 600px;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    margin-top: 6px;
}

/* ── Column bar — vertical Books v3.5 pattern (Fix 1) ──────────────────── */

.ilm-col-bar {
    background: #f0f0f1;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    padding: 10px 14px 12px;
    margin-bottom: 12px;
}

.ilm-col-bar-title {
    font-size: 13px;
    font-weight: 600;
    color: #1d2327;
    margin: 0 0 8px 0;
    display: block;
}

.ilm-col-bar-cols {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 0;
}

.ilm-col-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 4px 10px 4px 0;
    border-right: 1px solid #dcdcde;
    margin-right: 10px;
}

.ilm-col-item:last-child { border-right: none; }

.ilm-col-item-label {
    font-size: 11px;
    font-weight: 600;
    color: #1d2327;
    margin-bottom: 3px;
    white-space: nowrap;
}

.ilm-col-visible-wrap {
    font-size: 11px;
    margin-bottom: 3px;
    white-space: nowrap;
}

.ilm-col-width { width: 58px; font-size: 12px; }

.ilm-col-bar-actions { margin-top: 10px; }

#ilm-col-save-status { margin-left: 10px; font-size: 12px; }

/* Keep pins table columns horizontally stable */
.ilm-pins-table { table-layout: fixed; width: 100%; }
.ilm-pins-table th,
.ilm-pins-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Sortable column headers — match WP_List_Table appearance (Fix 2) ───── */

.ilm-pins-table thead th.sortable a,
.ilm-pins-table thead th.sorted a {
    display: block;
    text-decoration: none;
    color: #1d2327;
}
.ilm-pins-table thead th.sortable a:hover,
.ilm-pins-table thead th.sorted a:hover { color: #135e96; }
.ilm-pins-table thead th.sorted { background-color: #f0f0f1; }

/* Sorting indicator arrows */
.ilm-pins-table thead th.sorted.asc    .sorting-indicator::after { content: ' \25B2'; }
.ilm-pins-table thead th.sorted.desc   .sorting-indicator::after { content: ' \25BC'; }
.ilm-pins-table thead th.sortable.desc .sorting-indicator::after { content: ' \25BC'; opacity: 0.4; }

/* ── Outer grouping box (Fix 5) ─────────────────────────────────────────── */

.ilm-settings-group {
    background: #f6f7f7;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 4px 16px 16px;
    margin: 20px 0;
}
.ilm-settings-group .ilm-admin-card {
    margin: 12px 0;
    box-shadow: none;
}
.ilm-settings-group > .submit { padding: 0 0 4px; }

/* ── Marker type icon preview (Fix 6) ───────────────────────────────────── */

.ilm-type-preview {
    margin-top: 6px;
    padding: 6px;
    background: #f0f0f1;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    display: inline-block;
}
