/* The Hub — Dashboard Styles */

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-hover: #252836;
    --text: #e4e4e7;
    --text-dim: #8b8d97;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --green: #22c55e;
    --yellow: #eab308;
    --red: #ef4444;
    --border: #2a2d3a;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Navbar */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    height: 56px;
    gap: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
}

.nav-links { display: flex; gap: 1rem; }
.nav-links a {
    color: var(--text-dim);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    transition: all 0.2s;
}
.nav-links a:hover, .nav-links a.active {
    color: var(--text);
    background: var(--bg-hover);
}

/* YouTube tab — red branding */
.nav-links a.nav-yt { color: #ff4444; }
.nav-links a.nav-yt:hover, .nav-links a.nav-yt.active {
    background: #cc0000;
    color: #fff;
}

/* Divider between local tools and external platforms */
.nav-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 0.25rem;
    align-self: center;
}

.nav-search { margin-left: auto; }
.nav-search input {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    width: 250px;
    outline: none;
}
.nav-search input:focus {
    border-color: var(--accent);
}

/* Container */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.btn:hover { background: var(--accent); border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-large { padding: 0.6rem 2rem; font-size: 1rem; }
.btn-filter { background: var(--accent); border-color: var(--accent); }
.btn-clear { background: transparent; color: var(--text-dim); }
.btn-explorer { background: #374151; }
.btn-accent { background: #22c55e; border-color: #22c55e; color: #000; }
.btn-accent:hover { background: #16a34a; border-color: #16a34a; }

/* Page Header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem; }
.page-header h1 { margin: 0; font-size: 1.5rem; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* Gallery Header */
.gallery-header {
    margin-bottom: 1.5rem;
}
.gallery-header h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}
.gallery-header .count { color: var(--text-dim); font-weight: normal; }

/* Filters */
.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.filter-form select, .filter-form input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    outline: none;
}
.filter-form select:focus, .filter-form input:focus {
    border-color: var(--accent);
}
.tag-input { width: 140px; }
.camera-input { width: 120px; }
.quality-input { width: 100px; }

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.gallery-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: all 0.2s;
    position: relative;
}
.gallery-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.gallery-item a {
    display: block;
    aspect-ratio: 1;
    overflow: hidden;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}
.gallery-item:hover img { transform: scale(1.05); }

.gallery-item-info {
    padding: 0.4rem 0.6rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
}
.file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}
.dims { color: var(--text-dim); }

.video-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
}
.video-badge.large { padding: 4px 10px; font-size: 0.85rem; }

.file-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: var(--bg-hover);
    color: var(--text-dim);
}
.file-placeholder.large { min-height: 300px; }
.file-icon { font-size: 2.5rem; font-weight: 700; }
.file-ext { font-size: 0.85rem; margin-top: 0.5rem; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding: 1rem;
}
.page-info { color: var(--text-dim); }

/* Detail Page */
.detail-page { max-width: 1400px; margin: 0 auto; }
.detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.detail-header h1 {
    flex: 1;
    font-size: 1.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1.5rem;
}

.detail-image {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
.detail-image img {
    width: 100%;
    height: auto;
    display: block;
}

.detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.detail-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}
.detail-section h3 {
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-table { width: 100%; font-size: 0.85rem; }
.detail-table td {
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border);
}
.detail-table td:first-child {
    color: var(--text-dim);
    width: 110px;
}
.hash { font-family: monospace; font-size: 0.8rem; }
.path {
    word-break: break-all;
    font-size: 0.75rem;
    font-family: monospace;
}

/* Tags */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s;
}
.tag:hover { border-color: var(--accent); background: rgba(99, 102, 241, 0.15); }
.tag-conf { color: var(--text-dim); font-size: 0.65rem; }
.tag-rating { border-color: var(--yellow); }
.tag-character { border-color: var(--green); }

/* Rating Bars */
.rating-bars { display: flex; flex-direction: column; gap: 0.5rem; }
.rating-bar {
    display: grid;
    grid-template-columns: 90px 1fr 40px;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}
.rating-label { color: var(--text-dim); }
.rating-val { text-align: right; font-weight: 600; }
.bar-bg {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}
.bar-safe { background: var(--green); }
.bar-warn { background: var(--yellow); }
.bar-danger { background: var(--red); }
.bar-quality { background: var(--accent); }

/* Platform Badges */
.platform-badges { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.5rem; }
.badge {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.7rem;
}

/* VLM Text */
.vlm-text {
    font-size: 0.85rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
    color: var(--text-dim);
}
.transcription-text {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-dim);
    max-height: 200px;
    overflow-y: auto;
}

/* Search Page */
.search-page { max-width: 800px; margin: 0 auto; }
.search-page h1 { margin-bottom: 1.5rem; }
.search-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}
.search-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    align-items: center;
    gap: 1rem;
}
.search-row label {
    color: var(--text-dim);
    font-size: 0.9rem;
}
.search-row input, .search-row select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    outline: none;
}
.search-row input:focus, .search-row select:focus {
    border-color: var(--accent);
}

/* Stats */
.stats-section { margin-top: 2rem; }
.stats-section h2 { margin-bottom: 1rem; font-size: 1.2rem; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}
.stat-val {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}
.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
}

/* Insights Page */
.insights-page { max-width: 1400px; margin: 0 auto; }
.insights-header { margin-bottom: 1.5rem; }
.insights-header h1 { font-size: 1.5rem; margin: 0; }
.insights-subtitle { color: var(--text-dim); margin-top: 0.25rem; font-size: 0.9rem; }
.insights-summary { margin-bottom: 2rem; }
.stat-val-sm { font-size: 1rem; }

.insights-section h3 { margin-bottom: 1rem; }

.insights-cards {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.insight-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1.1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    border-left: 4px solid var(--accent);
}

.insight-info { border-left-color: var(--accent); }
.insight-success { border-left-color: var(--green); }
.insight-warning { border-left-color: var(--yellow); }
.insight-caution { border-left-color: var(--red); }

.insight-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    line-height: 1.5;
}
.insight-caution .insight-icon { color: var(--red); }
.insight-warning .insight-icon { color: var(--yellow); }
.insight-success .insight-icon { color: var(--green); }
.insight-info .insight-icon { color: var(--accent); }

.insight-text {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text);
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.chart-container { min-height: 280px; }
.chart-container canvas { max-height: 260px; }

.theme-bars {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.theme-row {
    display: grid;
    grid-template-columns: 180px 1fr 50px;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}
.theme-name { color: var(--text); font-weight: 500; white-space: nowrap; }
.theme-score { text-align: right; color: var(--text-dim); font-size: 0.8rem; }

/* ── Face Recognition ─────────────────────────────── */
.cluster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.cluster-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.cluster-faces { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 0.75rem; }
.cluster-faces img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; }
.cluster-label-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.cluster-label-form input { flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 0.4rem 0.6rem; border-radius: var(--radius); font-size: 0.9rem; min-width: 120px; }
.cluster-size { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.5rem; }
.cluster-expand-btn { width: 100%; margin-bottom: 0.5rem; font-size: 0.8rem; padding: 0.3rem; background: var(--bg); border: 1px dashed var(--border); color: var(--text-dim); cursor: pointer; border-radius: var(--radius); transition: border-color 0.2s, color 0.2s; }
.cluster-expand-btn:hover { border-color: var(--accent); color: var(--text); }
.btn-suggest { background: transparent; border: 1px solid var(--yellow); color: var(--yellow); font-size: 0.8rem; padding: 0.3rem 0.6rem; border-radius: var(--radius); cursor: pointer; white-space: nowrap; transition: background 0.2s; }
.btn-suggest:hover { background: var(--yellow); color: #000; }

.person-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; }
.person-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; text-align: center; text-decoration: none; color: var(--text); transition: border-color 0.2s; }
.person-card:hover { border-color: var(--accent); }
.person-card img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.person-name { padding: 0.3rem 0.4rem 0; font-size: 0.85rem; font-weight: 600; }
.person-count { font-size: 0.75rem; color: var(--text-dim); padding-bottom: 0.4rem; }

.person-face-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.75rem; }
.person-face-item { text-align: center; }
.person-face-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; cursor: pointer; transition: transform 0.2s; }
.person-face-item img:hover { transform: scale(1.05); }
.face-meta { font-size: 0.7rem; color: var(--text-dim); margin-top: 0.25rem; display: flex; gap: 0.4rem; justify-content: center; }

/* Responsive */
@media (max-width: 768px) {
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .detail-layout { grid-template-columns: 1fr; }
    .filter-form { gap: 0.3rem; }
    .nav-search { display: none; }
    .charts-grid { grid-template-columns: 1fr; }
    .theme-row { grid-template-columns: 130px 1fr 40px; }
    .cluster-grid { grid-template-columns: 1fr; }
    .person-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}
