/* ── Design tokens ── */
:root {
    --um-dark:        #1c3829;
    --um-green:       #2d5a3d;
    --um-bg:          #f5f2eb;
    --um-card-bg:     #ffffff;
    --um-card-radius: 14px;
    --um-shadow-sm:   0 1px 3px rgba(0,0,0,0.07), 0 2px 8px rgba(0,0,0,0.05);
    --um-shadow:      0 1px 4px rgba(0,0,0,0.08), 0 6px 20px rgba(0,0,0,0.07);
    --um-shadow-lg:   0 4px 8px rgba(0,0,0,0.1),  0 12px 32px rgba(0,0,0,0.1);
    --um-text:        #1a1a1a;
    --um-muted:       #6b7280;
    --um-border:      #e8e4dc;
}

body {
    background-color: var(--um-bg);
    font-family: system-ui, -apple-system, sans-serif;
    color: var(--um-text);
}

/* ── Navbar ── */
.navbar.navbar-um {
    background-color: var(--um-dark) !important;
    padding-top: 0;
    padding-bottom: 0;
    box-shadow: 0 1px 0 rgba(255,255,255,0.06);
}
.navbar.navbar-um .navbar-brand {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    padding: 14px 0;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}
.navbar.navbar-um .navbar-brand .brand-icon {
    width: 30px;
    height: 30px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}
.navbar.navbar-um .nav-link {
    color: rgba(255,255,255,0.75) !important;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 18px 14px !important;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.navbar.navbar-um .nav-link:hover,
.navbar.navbar-um .nav-link.active {
    color: #fff !important;
    border-bottom-color: #fff;
}
.navbar.navbar-um .nav-link.active { font-weight: 600; }
.navbar.navbar-um .dropdown-menu {
    border: none;
    border-radius: 12px;
    box-shadow: var(--um-shadow-lg);
    padding: 6px;
    margin-top: 2px;
}
.navbar.navbar-um .dropdown-item {
    border-radius: 8px;
    font-size: 0.875rem;
    padding: 8px 12px;
}
.navbar.navbar-um .dropdown-item.active,
.navbar.navbar-um .dropdown-item:active {
    background: #f0f7f2;
    color: var(--um-green);
}

/* User avatar */
.um-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #4a9b6f;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Page header ── */
.um-page-header {
    margin-bottom: 1.25rem;
}
.um-page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}
.um-page-header .um-subtitle {
    font-size: 0.8rem;
    color: var(--um-muted);
    margin-top: 2px;
}

/* ── Stat cards ── */
.um-stat-card {
    background: var(--um-card-bg);
    border-radius: var(--um-card-radius);
    box-shadow: var(--um-shadow-sm);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.um-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.um-stat-body {
    min-width: 0;
}
.um-stat-num {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
}
.um-stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--um-text);
    margin-top: 3px;
}
.um-stat-sub {
    font-size: 0.72rem;
    color: var(--um-muted);
    margin-top: 1px;
}

/* Circular progress for stat card */
.um-stat-progress-wrap {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}
.um-stat-progress-wrap svg {
    transform: rotate(-90deg);
    width: 48px;
    height: 48px;
}
.um-stat-progress-wrap .track { stroke: #e8f0ec; }
.um-stat-progress-wrap .fill  { stroke: var(--um-green); stroke-linecap: round; transition: stroke-dasharray 0.4s; }
.um-stat-progress-num {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--um-green);
}

/* ── Location cards ── */
.um-loc-card {
    background: var(--um-card-bg);
    border-radius: var(--um-card-radius);
    box-shadow: var(--um-shadow-sm);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
    color: var(--um-text);
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
    overflow: hidden;
    text-decoration: none !important;
    height: 100%;
}
.um-loc-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--um-shadow-lg);
    color: var(--um-text);
}
.um-loc-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}
.um-loc-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.um-loc-open-badge {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    min-width: 26px;
    height: 26px;
    border-radius: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
}
.um-loc-name {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 4px 0;
    line-height: 1.2;
}
.um-type-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 20px;
    letter-spacing: 0.01em;
}
.um-type-building {
    background: #eef0ff;
    color: #4f46e5;
}
.um-type-area {
    background: #ecfdf5;
    color: #059669;
}
.um-loc-meta {
    font-size: 0.78rem;
    color: var(--um-muted);
    margin: 8px 0 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.um-loc-progress {
    height: 5px;
    background: #f0ede6;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 5px;
}
.um-loc-progress-bar {
    height: 100%;
    border-radius: 3px;
    background: var(--um-green);
    transition: width 0.3s;
}
.um-loc-pct {
    font-size: 0.72rem;
    color: var(--um-muted);
    margin-bottom: 10px;
}
.um-priority-row {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 8px;
}
.um-priority-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
}
.um-pri-high   { background: #fef2f2; color: #dc2626; }
.um-pri-medium { background: #fffbeb; color: #d97706; }
.um-pri-low    { background: #eff6ff; color: #2563eb; }

/* Decorative card tint at bottom */
.um-loc-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 50px;
    pointer-events: none;
    border-radius: 0 0 var(--um-card-radius) var(--um-card-radius);
}

/* ── Site map section ── */
.um-map-wrap {
    background: var(--um-card-bg);
    border-radius: var(--um-card-radius);
    box-shadow: var(--um-shadow-sm);
    overflow: hidden;
}
.um-map-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--um-border);
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ── Sidebar location list ── */
.um-loc-list {
    background: var(--um-card-bg);
    border-radius: var(--um-card-radius);
    box-shadow: var(--um-shadow-sm);
    overflow: hidden;
}
.um-loc-list-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--um-border);
    font-weight: 600;
    font-size: 0.875rem;
}
.um-loc-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    border-bottom: 1px solid var(--um-border);
    text-decoration: none;
    color: var(--um-text);
    font-size: 0.875rem;
    transition: background 0.12s;
}
.um-loc-list-item:last-child { border-bottom: none; }
.um-loc-list-item:hover { background: #faf8f4; color: var(--um-text); }
.um-loc-list-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.um-loc-list-meta {
    font-size: 0.72rem;
    color: var(--um-muted);
}

/* ── Floor Plan Viewer ── */
.floorplan-wrap {
    position: relative;
    width: 100%;
    display: block;
}
.floorplan-wrap img {
    width: 100%;
    height: auto;
    display: block;
}

/* ── Zoomable viewer ── */
.fp-zoomable {
    overflow: hidden;
    max-height: 72vh;
    cursor: default;
    /* Rounded bottom corners clip the zoom content */
    border-radius: 0 0 var(--um-card-radius) var(--um-card-radius);
}
.fp-zoomable.fp-zoomed { cursor: grab; }
.fp-zoomable.fp-zoomed:active { cursor: grabbing; }

/* Inner element that receives the CSS transform */
.fp-zoom-inner {
    position: relative;
    width: 100%;
    transform-origin: 0 0;
    will-change: transform;
    /* No transition: transform must be instant for smooth drag/wheel */
}

/* Zoom control buttons overlay */
.fp-zoom-controls {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.fp-zoom-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.1);
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 17px;
    font-weight: 600;
    line-height: 1;
    color: #1a1a1a;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
    transition: background 0.1s, box-shadow 0.1s;
    user-select: none;
    padding: 0;
}
.fp-zoom-btn:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.22);
}
.fp-zoom-btn:active { transform: scale(0.93); }

/* Zoom hint that fades in when not zoomed */
.fp-zoom-hint {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 20px;
    pointer-events: none;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.4s;
    z-index: 40;
}
.fp-zoomable.fp-zoomed .fp-zoom-hint { opacity: 0; }

@media print {
    .fp-zoomable {
        max-height: none;
        overflow: visible;
    }
    .fp-zoom-controls,
    .fp-zoom-hint { display: none !important; }
    .fp-zoom-inner { transform: none !important; }
}

.hotspot-area {
    position: absolute;
    border: 2px solid;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3px;
    box-sizing: border-box;
    border-radius: 3px;
}
.hotspot-area:hover {
    filter: brightness(1.15);
    box-shadow: 0 2px 12px rgba(0,0,0,0.35);
    z-index: 20;
}

/* Top row inside hotspot */
.hs-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    gap: 3px;
}

.hotspot-label {
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    pointer-events: none;
    min-width: 0;
}

.hs-count {
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    text-align: center;
    flex-shrink: 0;
    pointer-events: none;
}

/* Bottom priority bar */
.hs-bottom { width: 100%; }
.hs-pbar {
    display: flex;
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
    gap: 1px;
    margin-bottom: 2px;
}
.hs-pbar-seg { border-radius: 2px; }
.hs-high   { background: #dc3545; }
.hs-medium { background: #ffc107; }
.hs-low    { background: #0dcaf0; }

.hs-pbar-legend {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 9px;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
    line-height: 1;
}
.hs-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Floor Plan Editor (Admin) ── */
#editor-wrapper {
    position: relative;
    display: block;
    cursor: crosshair;
    user-select: none;
}
#editor-img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
    border: 1px solid var(--um-border);
}
#hotspot-canvas {
    position: absolute;
    top: 0; left: 0;
    pointer-events: all;
    border-radius: 6px;
}

/* ── Status / Priority badges (Bootstrap compat) ── */
.badge-status-open        { background-color: #6c757d; }
.badge-status-in_progress { background-color: #fd7e14; }
.badge-status-done        { background-color: #198754; }
.badge-priority-high      { background-color: #dc3545; }
.badge-priority-medium    { background-color: #ffc107; color: #000 !important; }
.badge-priority-low       { background-color: #0dcaf0; color: #000 !important; }

/* ── Photo Gallery ── */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}
.photo-item {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 10px;
    border: 1px solid var(--um-border);
    background: #eee;
}
.photo-item img {
    width: 100%; height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s;
    display: block;
}
.photo-item:hover img { transform: scale(1.05); }
.photo-item .photo-actions {
    position: absolute;
    top: 4px; right: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}
.photo-item:hover .photo-actions { opacity: 1; }
.photo-type-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    pointer-events: none;
    letter-spacing: 0.02em;
}
.photo-type-before { background: rgba(80,80,80,0.82); color: #fff; }
.photo-type-after  { background: rgba(25,135,84,0.85); color: #fff; }

/* ── Shopping List ── */
.purchase-done td { opacity: 0.55; text-decoration: line-through; }
.cost-cell { font-family: monospace; }

/* ── Room chips ── */
.room-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.todo-done-row { opacity: 0.6; }

/* ── Generic card style ── */
.um-card {
    background: var(--um-card-bg);
    border-radius: var(--um-card-radius);
    box-shadow: var(--um-shadow-sm);
    border: none;
}
.um-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--um-border);
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--um-card-radius) var(--um-card-radius) 0 0 !important;
}

/* Ensure Bootstrap cards also look nicer */
.card {
    border-color: var(--um-border);
    border-radius: var(--um-card-radius);
}
.card.shadow-sm { box-shadow: var(--um-shadow-sm) !important; }

/* ── Location icon (large, for location.php header) ── */
.location-icon-lg {
    font-size: 2.2rem;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(0,0,0,0.04);
}

/* ── Section label ── */
.um-section-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--um-muted);
    margin-bottom: 12px;
}

/* ── Due date badges ── */
.um-due-overdue {
    background: #dc2626;
    color: #fff;
}
.um-due-today {
    background: #d97706;
    color: #fff;
}
.um-due-soon {
    background: #ca8a04;
    color: #fff;
}

/* ── Overdue row highlight ── */
.um-overdue-row {
    border-left: 3px solid #dc2626 !important;
    background: #fff8f8;
}
.um-overdue-row:hover { background: #fff0f0 !important; }

/* ── Navbar search ── */
.nav-search {
    max-width: 240px;
    width: 100%;
}
@media (max-width: 991px) {
    .nav-search { max-width: 100%; margin-top: 0.5rem; margin-bottom: 0.25rem; }
}
.nav-search-input {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 8px 0 0 8px;
}
.nav-search-input::placeholder { color: rgba(255,255,255,0.5); }
.nav-search-input:focus {
    background: rgba(255,255,255,0.18);
    border-color: rgba(255,255,255,0.4);
    color: #fff;
    box-shadow: none;
}
.nav-search-btn {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    border-left: none;
    color: rgba(255,255,255,0.8);
    border-radius: 0 8px 8px 0;
}
.nav-search-btn:hover {
    background: rgba(255,255,255,0.22);
    color: #fff;
}

/* ── Search result highlight ── */
.um-highlight {
    background: #fff3cd;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}
.um-search-excerpt {
    font-size: 0.8rem;
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ── Tag badges ── */
.um-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    color: #fff;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

/* Tag toggle in todo_form.php — styled checkbox-as-badge */
.tag-toggle {
    cursor: pointer;
    /* Fallback for browsers without color-mix() */
    background: #e9ecef;
    color: #495057;
    /* Modern browsers */
    background: color-mix(in srgb, var(--tag-color) 22%, #e9ecef);
    color: color-mix(in srgb, var(--tag-color) 90%, #111);
    border: 2px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    user-select: none;
    font-size: 0.8rem;
}
input[type="checkbox"]:checked + label .tag-toggle {
    background: var(--tag-color);
    color: #fff;
    border-color: var(--tag-color);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
input[type="checkbox"]:focus-visible + label .tag-toggle {
    outline: 2px solid var(--tag-color);
    outline-offset: 2px;
}

/* ── Tag filter bar ── */
.tag-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 1rem;
}
.tag-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 2px solid transparent;
    text-decoration: none;
    transition: opacity 0.15s, border-color 0.15s;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.tag-filter-btn:hover       { opacity: 0.85; color: #fff; }
.tag-filter-btn.active      { border-color: rgba(255,255,255,0.6); box-shadow: 0 0 0 2px rgba(0,0,0,0.12); }
.tag-filter-btn.tag-all     { background: #6c757d; }
.tag-filter-btn.tag-all.active { background: #495057; }

/* ── Print ── */
@media print {
    .navbar, .btn, .no-print, footer { display: none !important; }
    body { background: #fff; }
    .card, .um-loc-card, .um-stat-card { border: 1px solid #999 !important; box-shadow: none !important; }
}

/* ── Mobile tweaks ── */
@media (max-width: 575px) {
    .um-stat-card { padding: 14px 16px; gap: 12px; }
    .um-stat-num  { font-size: 1.4rem; }
    .um-loc-card  { padding: 16px; }
}
