/* GlobeCam.ai — Grid-First Dark Command Center Theme v2 */

:root {
    --bg-primary: #0a0e14;
    --bg-secondary: #0d1117;
    --bg-tertiary: #161b22;
    --bg-surface: #1e293b;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #00b4d8;
    --accent-hover: #0ea5e9;
    --accent-glow: rgba(0, 180, 216, 0.13);
    --status-live: #22c55e;
    --status-live-glow: rgba(34, 197, 94, 0.27);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #1e293b;
    --border-hover: #334155;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-pill: 12px;
    --sidebar-width: 260px;
    --header-height: 48px;
    --mobile-tab-height: 56px;
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;
    --font-body: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* ── Header ── */
.header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 12px;
    z-index: 100;
    position: relative;
}

.header__brand {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.header__icon { font-size: 20px; }

.header__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.header__title-dot {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 13px;
}

/* Grid/Map Toggle */
.header__toggle {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
    flex-shrink: 0;
}

.header__view-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms;
    white-space: nowrap;
}

.header__view-btn:hover { color: var(--text-primary); background: var(--bg-surface); }

.header__view-btn.active {
    background: var(--accent);
    color: #fff;
}

.header__view-btn svg { flex-shrink: 0; }

/* Search */
.header__search {
    flex: 1;
    max-width: 360px;
    position: relative;
}

.header__search input {
    width: 100%;
    padding: 6px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color 200ms;
}

.header__search input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }

.search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    margin-top: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 300px;
    overflow-y: auto;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.search-results.active { display: block; }

.search-result {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    transition: background 100ms;
}

.search-result:hover { background: var(--bg-tertiary); }
.search-result__name { font-size: 13px; }
.search-result__meta { font-size: 11px; color: var(--text-muted); }

.header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-shrink: 0;
}

.header__stats { font-size: 12px; color: var(--text-muted); }

.header__settings-btn {
    width: 32px; height: 32px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 150ms;
}
.header__settings-btn:hover { background: var(--bg-surface); border-color: var(--border-hover); }

/* Mobile header adjustments */
@media (max-width: 768px) {
    .header { padding: 0 8px; gap: 8px; }
    .header__toggle { display: none; }
    .header__search { max-width: none; }
    .header__stats { display: none; }
}

/* ── Layout ── */
.layout {
    display: flex;
    height: calc(100vh - var(--header-height) - 32px); /* 32px = ninja-footer */
}

@media (max-width: 768px) {
    .layout { height: calc(100vh - var(--header-height) - var(--mobile-tab-height)); }
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

@media (max-width: 768px) { .sidebar { display: none; } }

.sidebar__header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.sidebar__header-icon { font-size: 14px; }

.sidebar__header-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.sidebar__search {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.sidebar__search input {
    width: 100%;
    padding: 6px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
}

.sidebar__search input:focus { border-color: var(--accent); }

.sidebar__categories {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.sidebar__cat {
    padding: 3px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    transition: all 100ms;
    white-space: nowrap;
}

.sidebar__cat:hover { color: var(--text-primary); border-color: var(--border-hover); }
.sidebar__cat.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.sidebar__cameras {
    flex: 1;
    overflow-y: auto;
}

.sidebar-cam {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    border-bottom: 1px solid rgba(30, 41, 59, 0.5);
    transition: background 100ms;
}

.sidebar-cam:hover { background: var(--bg-tertiary); }

.sidebar-cam__thumb {
    width: 48px;
    height: 32px;
    border-radius: 3px;
    object-fit: cover;
    background: var(--bg-primary);
    flex-shrink: 0;
}

.sidebar-cam__info {
    flex: 1;
    min-width: 0;
}

.sidebar-cam__name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-cam__location {
    font-size: 10px;
    color: var(--text-muted);
}

.sidebar-cam__add {
    width: 24px; height: 24px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--accent);
    font-size: 14px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all 100ms;
}

.sidebar-cam__add:hover { background: rgba(0, 180, 216, 0.15); border-color: var(--accent); }

/* ── Main Content ── */
.main-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ── Grid View ── */
.grid-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.grid-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.grid-header__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.grid-header__count {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 8px;
    font-family: var(--font-mono);
}

.grid-header__controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.grid-size-switcher {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}

.grid-size-btn {
    padding: 3px 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms;
}

.grid-size-btn:hover { color: var(--text-primary); background: var(--bg-surface); }
.grid-size-btn.active { background: var(--bg-surface); border-color: var(--accent); color: var(--accent); }

/* Camera Grid */
.camera-grid {
    flex: 1;
    display: grid;
    gap: 4px;
    padding: 4px;
    overflow: hidden;
}

.camera-grid[data-cols="2"] { grid-template-columns: 1fr 1fr; }
.camera-grid[data-cols="3"] { grid-template-columns: 1fr 1fr 1fr; }
.camera-grid[data-cols="4"] { grid-template-columns: 1fr 1fr 1fr 1fr; }

.camera-grid[data-rows="2"] { grid-template-rows: 1fr 1fr; }
.camera-grid[data-rows="3"] { grid-template-rows: 1fr 1fr 1fr; }
.camera-grid[data-rows="4"] { grid-template-rows: 1fr 1fr 1fr 1fr; }

/* Grid Cell */
.grid-cell {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--bg-surface);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 200ms;
}

.grid-cell:hover { border-color: var(--accent); }

.grid-cell iframe,
.grid-cell img,
.grid-cell video {
    width: 100%; height: 100%;
    border: none;
    object-fit: cover;
    pointer-events: none;
}

.grid-cell__status {
    position: absolute;
    top: 6px; left: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    color: white;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    z-index: 2;
}

.grid-cell__status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--status-live);
}

.grid-cell__controls {
    position: absolute;
    top: 6px; right: 6px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 150ms;
    z-index: 2;
}

.grid-cell:hover .grid-cell__controls { opacity: 1; }

.grid-cell__ctrl-btn {
    width: 26px; height: 26px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 100ms;
}

.grid-cell__ctrl-btn:hover { background: rgba(0, 0, 0, 0.85); }

.grid-cell__info {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 6px 10px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
    z-index: 2;
}

.grid-cell__name {
    font-size: 12px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid-cell__location {
    font-size: 10px;
    color: var(--text-secondary);
}

/* Empty grid cell */
.grid-cell--empty {
    border: 2px dashed var(--border);
    cursor: pointer;
}

.grid-cell--empty:hover { border-color: var(--accent); }

.grid-cell__add {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
}

.grid-cell__add-icon {
    font-size: 32px;
    color: var(--border-hover);
    transition: color 200ms;
}

.grid-cell--empty:hover .grid-cell__add-icon { color: var(--accent); }
.grid-cell__add-label { font-size: 12px; }

/* ── Map View ── */
.map-view {
    height: 100%;
    position: relative;
}

#map { width: 100%; height: 100%; min-height: 300px; }

.map-layers {
    position: absolute;
    bottom: 40px; left: 10px;
    z-index: 1000;
    display: flex;
    gap: 4px;
}

.map-layer-btn {
    padding: 4px 10px;
    background: rgba(13, 17, 23, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 11px;
    backdrop-filter: blur(8px);
    transition: all 0.2s;
}

.map-layer-btn:hover { background: rgba(30, 41, 59, 0.9); color: var(--text-primary); }
.map-layer-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.status-bar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 28px;
    background: rgba(10, 14, 20, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 16px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    z-index: 5;
    border-top: 1px solid var(--border);
}

.status-bar__item { display: flex; align-items: center; gap: 4px; }
.status-bar__label { color: var(--text-muted); }
.status-bar__value { color: var(--text-primary); font-weight: 500; }
.status-bar__dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.status-bar__dot--live { background: var(--status-live); }

/* Leaflet overrides */
.leaflet-container { background: var(--bg-primary) !important; font-family: var(--font-body); }
.leaflet-tile-pane { will-change: transform; }
.leaflet-fade-anim .leaflet-tile { transition: opacity 250ms; }
.leaflet-control-zoom a {
    background: rgba(13, 17, 23, 0.9) !important;
    color: var(--text-primary) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}
.leaflet-control-zoom a:hover { background: rgba(30, 41, 59, 0.95) !important; color: var(--accent) !important; }
.leaflet-control-attribution { background: rgba(13, 17, 23, 0.7) !important; color: var(--text-muted) !important; font-size: 10px !important; }
.leaflet-control-attribution a { color: var(--text-secondary) !important; }

/* Map marker tooltip */
.leaflet-camera-tooltip {
    background: rgba(13, 17, 23, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
    padding: 8px 12px !important;
    font-family: var(--font-body) !important;
    font-size: 12px !important;
}

.leaflet-camera-tooltip .tooltip__name { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.leaflet-camera-tooltip .tooltip__loc { color: var(--text-secondary); font-size: 11px; margin-bottom: 4px; }
.leaflet-camera-tooltip .tooltip__status { font-size: 10px; }
.leaflet-camera-tooltip .tooltip__status--live { color: var(--status-live); }
.leaflet-tooltip-top::before { border-top-color: rgba(13, 17, 23, 0.95) !important; }

/* Map popup card */
.map-popup {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    overflow: hidden;
    width: 280px;
}

.map-popup__feed {
    width: 100%;
    height: 158px;
    background: #000;
    overflow: hidden;
}

.map-popup__feed iframe,
.map-popup__feed img {
    width: 100%; height: 100%;
    border: none;
    object-fit: cover;
}

.map-popup__body { padding: 10px; }
.map-popup__name { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.map-popup__loc { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }

.map-popup__actions { display: flex; gap: 6px; }

.map-popup__btn {
    flex: 1;
    padding: 6px 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: all 100ms;
}

.map-popup__btn:hover { background: var(--bg-surface); color: var(--text-primary); }
.map-popup__btn--accent { border-color: var(--accent); color: var(--accent); }
.map-popup__btn--accent:hover { background: rgba(0, 180, 216, 0.1); }

.leaflet-popup-content-wrapper { background: transparent !important; box-shadow: none !important; border-radius: 0 !important; padding: 0 !important; }
.leaflet-popup-content { margin: 0 !important; width: auto !important; }
.leaflet-popup-tip { background: var(--bg-secondary) !important; }

/* ── Camera Detail Panel ── */
.camera-detail {
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: 400px;
    height: calc(100vh - var(--header-height));
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    z-index: 1100;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 300ms ease-out;
}

.camera-detail.open { transform: translateX(0); }

@media (max-width: 768px) {
    .camera-detail {
        width: 100%;
        height: 60%;
        top: auto;
        bottom: var(--mobile-tab-height);
        right: 0;
        border-left: none;
        border-top: 1px solid var(--border);
        transform: translateY(100%);
    }
    .camera-detail.open { transform: translateY(0); }
}

.detail__topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    gap: 8px;
    min-height: 48px;
}

.detail__info { flex: 1; min-width: 0; }
.detail__name { font-size: 15px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail__meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.detail__location { font-size: 11px; color: var(--text-muted); }

.detail__status {
    display: inline-block;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.detail__status--live { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.detail__status--offline { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

.detail__btn {
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: all 100ms;
}

.detail__btn:hover { background: var(--bg-primary); color: var(--text-primary); }

.detail__btn--close {
    color: var(--text-secondary);
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    font-size: 16px;
    flex-shrink: 0;
    border-radius: 6px;
}

.detail__btn--close:hover { color: #fff; background: var(--danger); border-color: var(--danger); }

.detail__feed {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    overflow: hidden;
}

.detail__feed iframe,
.detail__feed img,
.detail__feed video {
    width: 100%; height: 100%;
    border: none;
    object-fit: cover;
}

.detail__feed .feed-loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* Detail Action Buttons */
.detail__actions {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.detail__action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 150ms;
    white-space: nowrap;
}

.detail__action-btn:hover { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-hover); }

.detail__action-btn--primary {
    background: rgba(0, 180, 216, 0.1);
    border-color: rgba(0, 180, 216, 0.3);
    color: var(--accent);
}

.detail__action-btn--primary:hover {
    background: rgba(0, 180, 216, 0.2);
    border-color: var(--accent);
}

.detail__action-btn--fav-active {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.detail__action-btn svg { flex-shrink: 0; }

/* AI Analyze Button */
.detail__ai-section {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.detail__ai-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(0, 180, 216, 0.08), rgba(0, 180, 216, 0.15));
    border: 1px solid rgba(0, 180, 216, 0.25);
    border-radius: var(--radius);
    color: var(--accent);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 150ms;
}

.detail__ai-btn:hover {
    background: linear-gradient(135deg, rgba(0, 180, 216, 0.15), rgba(0, 180, 216, 0.25));
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(0, 180, 216, 0.15);
}

.detail__ai-btn svg { flex-shrink: 0; }

.detail__ai-btn-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
    font-family: var(--font-mono);
}

/* AI Analysis */
.ai-analysis { border-top: 1px solid rgba(0, 180, 216, 0.2); flex: 1; overflow-y: auto; }
.ai-analysis__header { padding: 8px 14px; font-size: 12px; font-weight: 600; color: var(--accent); border-bottom: 1px solid var(--border); background: rgba(0, 180, 216, 0.05); }
.ai-analysis__content { padding: 10px 14px; font-size: 12px; line-height: 1.6; color: var(--text-secondary); }
.ai-snapshot-preview { width: 100%; max-height: 160px; object-fit: cover; border-radius: 6px; margin-bottom: 10px; border: 1px solid var(--border); }

/* AI Loading */
.ai-loading { display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: var(--accent); font-size: 13px; }
.ai-loading__spinner { width: 18px; height: 18px; border: 2px solid rgba(0, 180, 216, 0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-loading__text { font-weight: 500; }
.ai-error { padding: 12px 14px; color: var(--danger); font-size: 12px; }

/* AI Structured Output */
.ai-structured { padding: 6px 0; }
.ai-section { padding: 6px 14px; }
.ai-section__label { font-size: 10px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; }
.ai-section__text { font-size: 12px; line-height: 1.5; color: var(--text-secondary); }
.ai-section__text--mood { font-style: italic; color: var(--text-muted); }

/* Activity Bar */
.ai-activity-bar { position: relative; height: 8px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.ai-activity-bar__fill { height: 100%; border-radius: 4px; transition: width 600ms ease-out; }
.ai-activity-bar__label { position: absolute; right: 0; top: -16px; font-size: 10px; font-weight: 600; font-family: var(--font-mono); color: var(--text-secondary); }

/* Object Counts Grid */
.ai-objects { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; margin-top: 4px; }
.ai-object { background: var(--bg-tertiary); border-radius: var(--radius-sm); padding: 6px 8px; text-align: center; }
.ai-object__count { display: block; font-size: 18px; font-weight: 700; color: var(--accent); font-family: var(--font-mono); line-height: 1.2; }
.ai-object__label { font-size: 9px; color: var(--text-muted); text-transform: capitalize; }

/* AI Model Badge */
.ai-model-badge { padding: 6px 14px; font-size: 10px; color: var(--text-muted); text-align: right; font-family: var(--font-mono); }

/* Drag & Drop — Enhanced */
.grid-cell.dragging { opacity: 0.35; transform: scale(0.92) rotate(1.5deg); transition: opacity 200ms, transform 200ms cubic-bezier(0.4, 0, 0.2, 1); }
.grid-cell--drag-over { border-color: var(--accent) !important; box-shadow: inset 0 0 0 2px rgba(0, 180, 216, 0.3), 0 0 16px rgba(0, 180, 216, 0.15); transform: scale(1.02); transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 200ms; }
.grid-cell--empty.grid-cell--drag-over { border-color: var(--accent) !important; background: rgba(0, 180, 216, 0.08); transform: scale(1.02); }
.grid-cell[draggable="true"] { cursor: grab; transition: transform 200ms, opacity 200ms, border-color 200ms; }
.grid-cell[draggable="true"]:active { cursor: grabbing; }

/* Category Badge in Detail Panel */
.detail__category { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 10px; text-transform: capitalize; white-space: nowrap; }

/* Sidebar improvements */
.sidebar__cat-count { font-size: 10px; font-family: var(--font-mono); opacity: 0.7; margin-left: 2px; }
.sidebar-cam--in-grid { opacity: 0.6; }
.sidebar-cam__add--done { color: var(--success); border-color: var(--success); }
.sidebar-cam__thumb--empty { background: var(--bg-tertiary); }
.sidebar__empty { padding: 20px; color: var(--text-muted); font-size: 12px; text-align: center; }

/* Search result category dot */
.search-result__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-right: 6px; }

/* Mobile add button done state */
.mobile-cam__add--done { color: var(--success); border-color: var(--success); }

/* Toast types */
.toast--success { border-color: var(--success); }
.toast--info { border-color: var(--accent); }
.toast--warning { border-color: var(--warning); }

/* ── Grid Mode Toggle (AI Pick / Custom) ── */
.grid-mode-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
    flex-shrink: 0;
}

.grid-mode-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 150ms;
    white-space: nowrap;
}

.grid-mode-btn svg { flex-shrink: 0; }
.grid-mode-btn:hover { color: var(--text-secondary); }
.grid-mode-btn.active {
    background: var(--bg-surface);
    color: var(--accent);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ── Grid Presets ── */
.grid-presets { display: flex; gap: 4px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.grid-presets::-webkit-scrollbar { display: none; }
.preset-btn {
    padding: 3px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    font-size: 11px;
    font-family: var(--font-body);
    cursor: pointer;
    white-space: nowrap;
    transition: all 150ms;
}
.preset-btn:hover { background: var(--bg-surface); color: var(--text-primary); border-color: var(--accent); }

/* ── Keyboard Shortcuts Help ── */
.shortcuts-list { display: flex; flex-direction: column; gap: 8px; }
.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.shortcut-row:last-child { border-bottom: none; }
.shortcut-row kbd {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-hover);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent);
    min-width: 32px;
    text-align: center;
}
.shortcut-row span { color: var(--text-secondary); font-size: 13px; }

/* ── Sidebar Load More ── */
.sidebar__load-more {
    display: block;
    width: 100%;
    padding: 10px;
    background: none;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 11px;
    font-family: var(--font-body);
    cursor: pointer;
    margin-top: 4px;
    transition: all 150ms;
}
.sidebar__load-more:hover { border-color: var(--accent); background: var(--accent-glow); }

/* ── Mobile Bottom Tab Bar ── */
.mobile-tabs {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--mobile-tab-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    z-index: 1200;
    justify-content: space-around;
    align-items: center;
}

@media (max-width: 768px) { .mobile-tabs { display: flex; } }

.mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: color 150ms;
}

.mobile-tab svg { fill: currentColor; }
.mobile-tab:hover { color: var(--text-primary); }
.mobile-tab.active { color: var(--accent); position: relative; }
.mobile-tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 25%;
    right: 25%;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 2px 2px;
}

/* ── Mobile Browse Panel ── */
.mobile-browse {
    position: fixed;
    top: var(--header-height);
    left: 0; right: 0;
    bottom: var(--mobile-tab-height);
    background: var(--bg-primary);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-browse__search {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.mobile-browse__search input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.mobile-browse__categories {
    display: flex;
    gap: 6px;
    padding: 10px;
    overflow-x: auto;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.mobile-browse__cat {
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 100ms;
    flex-shrink: 0;
}

.mobile-browse__cat:hover { color: var(--text-primary); }
.mobile-browse__cat.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.mobile-browse__list {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
}

.mobile-cam {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid rgba(30, 41, 59, 0.5);
    cursor: pointer;
    transition: background 100ms;
}

.mobile-cam:hover { background: var(--bg-tertiary); }

.mobile-cam__thumb {
    width: 64px; height: 40px;
    border-radius: 4px;
    object-fit: cover;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.mobile-cam__info { flex: 1; min-width: 0; }
.mobile-cam__name { font-size: 14px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-cam__location { font-size: 11px; color: var(--text-muted); }

.mobile-cam__add {
    width: 32px; height: 32px;
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: var(--accent);
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.mobile-cam__add:hover { background: rgba(0, 180, 216, 0.15); }

/* ── Settings Overlay ── */
.settings-overlay {
    position: fixed; inset: 0; z-index: 1500;
    background: rgba(0, 0, 0, 0.6);
    display: flex; align-items: center; justify-content: center;
}

.settings-panel {
    width: 480px;
    max-height: 80vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex; flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

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

.settings-panel__header h2 { font-size: 15px; font-weight: 600; }
.settings-panel__close { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; padding: 4px; }
.settings-panel__close:hover { color: var(--text-primary); }
.settings-panel__body { flex: 1; overflow-y: auto; padding: 12px 16px; }

.settings-section { margin-bottom: 16px; }
.settings-section:last-child { margin-bottom: 0; }
.settings-section__title { font-size: 12px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.settings-section__text { font-size: 13px; color: var(--text-primary); line-height: 1.5; margin-bottom: 4px; }
.settings-section__text--muted { color: var(--text-secondary); font-size: 12px; }

.settings-sources { display: flex; flex-direction: column; gap: 6px; }
.settings-source { display: block; padding: 10px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius-sm); text-decoration: none; transition: all 150ms; }
.settings-source:hover { border-color: var(--accent); background: var(--bg-surface); }
.settings-source__name { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.settings-source__desc { font-size: 12px; color: var(--text-secondary); }

/* ── Toast Notification ── */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 10px 20px;
    color: var(--text-primary);
    font-size: 13px;
    z-index: 2000;
    opacity: 0;
    transition: all 300ms;
    pointer-events: none;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Mobile 1x1 Swipe Grid ── */
@media (max-width: 768px) {
    .grid-view .grid-header {
        padding: 6px 10px;
    }
    .grid-view .grid-header__title { font-size: 13px; }
    .grid-view .camera-grid {
        display: flex !important;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        gap: 0;
        padding: 0;
        grid-template-columns: unset !important;
        grid-template-rows: unset !important;
    }
    .grid-view .camera-grid .grid-cell,
    .grid-view .camera-grid .grid-cell--empty {
        min-width: 100%;
        max-width: 100%;
        flex-shrink: 0;
        scroll-snap-align: start;
        border-radius: 0;
        border: none;
        border-right: 1px solid var(--border);
    }
    .grid-view .camera-grid .grid-cell--empty {
        border: none;
        min-width: 100%;
    }
    .grid-size-switcher { display: none; }
    .grid-presets { display: none; }
    .grid-mode-toggle { display: none; }
}

.mobile-grid-nav {
    display: none;
}

@media (max-width: 768px) {
    .mobile-grid-nav {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        padding: 8px;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
    }
    .mobile-grid-nav__btn {
        width: 36px; height: 36px;
        background: var(--bg-tertiary);
        border: 1px solid var(--border);
        border-radius: 50%;
        color: var(--text-secondary);
        font-size: 16px;
        cursor: pointer;
        display: flex; align-items: center; justify-content: center;
        transition: all 150ms;
    }
    .mobile-grid-nav__btn:hover, .mobile-grid-nav__btn:active {
        background: var(--bg-surface);
        color: var(--accent);
        border-color: var(--accent);
    }
    .mobile-grid-nav__btn:disabled {
        opacity: 0.3;
        cursor: default;
    }
    .mobile-grid-nav__indicator {
        font-size: 13px;
        font-weight: 600;
        color: var(--text-primary);
        font-family: var(--font-mono);
        min-width: 60px;
        text-align: center;
    }
    .mobile-grid-nav__indicator span {
        color: var(--text-muted);
        font-weight: 400;
    }
}

/* ── Utility ── */
.mono { font-family: var(--font-mono); }

/* Category dot colors */
.cat-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.cat-dot--landmark { background: #f59e0b; }
.cat-dot--nature { background: #22c55e; }
.cat-dot--beach { background: #06b6d4; }
.cat-dot--traffic { background: #ef4444; }
.cat-dot--city { background: #a855f7; }
.cat-dot--space { background: #3b82f6; }

/* ── NinjaTech AI Footer CTA ── */
.ninja-footer {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    height: 32px;
    background: linear-gradient(135deg, rgba(13, 17, 23, 0.95), rgba(10, 14, 20, 0.98));
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 90;
    backdrop-filter: blur(8px);
}

.ninja-footer__text {
    font-size: 11px;
    color: var(--text-muted);
}

.ninja-footer__link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: color 150ms;
}

.ninja-footer__link:hover { color: var(--accent-hover); }

.ninja-footer__sep {
    color: var(--text-muted);
    font-size: 10px;
}

.ninja-footer__cta {
    font-size: 11px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 150ms;
}

.ninja-footer__cta:hover { color: var(--accent); }

@media (max-width: 768px) {
    .ninja-footer {
        display: none; /* Hidden on mobile — mobile tabs take priority */
    }
}

/* ── Settings CTA Section ── */
.settings-section--cta {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.settings-cta {
    background: linear-gradient(135deg, rgba(0, 180, 216, 0.05), rgba(0, 180, 216, 0.1));
    border: 1px solid rgba(0, 180, 216, 0.2);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
}

.settings-cta__badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--accent);
    background: rgba(0, 180, 216, 0.15);
    padding: 2px 10px;
    border-radius: 10px;
    margin-bottom: 8px;
    font-family: var(--font-mono);
}

.settings-cta__text {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.settings-cta__link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.settings-cta__link:hover { text-decoration: underline; }

.settings-cta__sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-style: italic;
}

.settings-cta__btn {
    display: inline-block;
    padding: 8px 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    transition: all 200ms;
    box-shadow: 0 2px 8px rgba(0, 180, 216, 0.25);
}

.settings-cta__btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 180, 216, 0.35);
}

.settings-link {
    color: var(--accent);
    text-decoration: none;
}

.settings-link:hover { text-decoration: underline; }
