/* ═══════════════════════════════════════════════════════════
   ArtRiver — common.css
   Shared styles for all pages with sidebar layout.
   ═══════════════════════════════════════════════════════════ */

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

/* ── Base ──────────────────────────────────────────────────── */
body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #f8f9fa;
    color: #495057;
}

/* ── Layout ────────────────────────────────────────────────── */
.container { display: flex; min-height: 100vh; }

.sidebar {
    width: 210px;
    background: #2c3e50;
    color: white;
    padding: 1.5rem 1rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0,0,0,.1);
}

.sidebar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: .5rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.sidebar-subtitle {
    font-size: .85rem;
    color: rgba(255,255,255,.7);
    margin-bottom: 2rem;
}

.sidebar-nav { list-style: none; }
.sidebar-nav li { margin: .5rem 0; }
.sidebar-nav a {
    color: rgba(255,255,255,.8);
    text-decoration: none;
    display: block;
    padding: .75rem 1rem;
    border-radius: 6px;
    transition: all .2s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.1); color: white; }
.sidebar-nav a.active { background: #3498db; color: white; }

.main-content { flex: 1; margin-left: 210px; padding: 2rem; }

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
    background: white;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e9ecef;
    margin: -2rem -2rem 2rem -2rem;
}
.topbar-title  { font-size: 1.75rem; font-weight: 700; color: #1a1a2e; }
.topbar-subtitle { font-size: .9rem; color: #868e96; margin-top: .25rem; }

/* ── Card ──────────────────────────────────────────────────── */
.card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card h2 { font-size: 1.25rem; color: #1a1a2e; margin-bottom: 1.5rem; font-weight: 600; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .375rem .75rem;
    border-radius: 12px;
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.badge-pending    { background: #e2e3e5; color: #6c757d; }
.badge-crawling   { background: #cfe2ff; color: #0d6efd; }
.badge-analyzing  { background: #cfe2ff; color: #0d6efd; }
.badge-matching   { background: #fff3cd; color: #856404; }
.badge-completed  { background: #d1e7dd; color: #0f5132; }
.badge-analyzed   { background: #d1e7dd; color: #0f5132; }
.badge-failed     { background: #f8d7da; color: #842029; }

/* ── State helpers ─────────────────────────────────────────── */
.loading     { text-align: center; padding: 2rem; color: #868e96; }
.empty-state { text-align: center; padding: 2rem; color: #868e96; font-style: italic; }
.error-state { text-align: center; padding: 2rem; color: #842029; }

.back-link {
    color: #0d6efd;
    text-decoration: none;
    font-size: .9rem;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}
.back-link:hover { text-decoration: underline; }

/* ── Shared buttons ────────────────────────────────────────── */
.btn-link {
    color: #0d6efd;
    text-decoration: none;
    font-weight: 500;
    transition: color .2s;
}
.btn-link:hover { color: #0b5ed7; text-decoration: underline; }

.btn-sm {
    background: transparent;
    border: 1px solid currentColor;
    padding: .25rem .5rem;
    border-radius: 4px;
    font-size: .8rem;
    cursor: pointer;
    margin-left: .25rem;
}
.btn-danger          { color: #dc3545; }
.btn-danger:hover    { background: #dc3545; color: white; }
.btn-warning         { color: #fd7e14; }
.btn-warning:hover   { background: #fd7e14; color: white; }

/* ── Tasks table (index + image-search list) ───────────────── */
.tasks-table { width: 100%; border-collapse: collapse; }
.tasks-table thead { background: #f8f9fa; border-bottom: 2px solid #dee2e6; }
.tasks-table th {
    padding: 1rem .875rem;
    text-align: left;
    font-weight: 600;
    color: #495057;
    font-size: .9rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.tasks-table td { padding: 1rem .875rem; border-bottom: 1px solid #e9ecef; color: #495057; }
.tasks-table tbody tr { transition: background-color .2s; }
.tasks-table tbody tr:hover { background: #f8f9fa; }

.url-cell {
    font-family: 'Monaco','Menlo',monospace;
    font-size: .82rem;
    color: #0d6efd;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Match cards (image-detail + image-search-report) ──────── */
.match-list { display: flex; flex-direction: column; gap: 1rem; }

.match-card {
    display: flex;
    gap: 1.25rem;
    padding: 1.25rem;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #fff;
    transition: box-shadow .15s;
    align-items: flex-start;
}
.match-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.07); }

.match-thumb-col { flex-shrink: 0; }
.match-thumb {
    width: 300px; height: 200px;
    object-fit: cover; border-radius: 6px;
    border: 1px solid #dee2e6; background: #f8f9fa; display: block;
}
.match-thumb-broken {
    width: 300px; height: 200px; border-radius: 6px;
    border: 1px dashed #dee2e6; background: #f8f9fa;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; color: #ced4da; font-size: 2.5rem; gap: .5rem;
}
.match-thumb-broken span { font-size: .8rem; color: #adb5bd; }

.match-details { flex: 1; min-width: 0; }

.score-wrap { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.score-bar { height: 8px; border-radius: 4px; background: #dee2e6; width: 80px; }
.score-bar-fill { height: 100%; border-radius: 4px; }
.score-text { font-weight: 700; font-size: .9rem; min-width: 38px; }

.match-url-row { margin-bottom: .6rem; }
.match-url {
    color: #0d6efd;
    text-decoration: none;
    font-size: .85rem;
    word-break: break-all;
    display: inline-block;
}
.match-url:hover { text-decoration: underline; }

/* ── Image preview (image-detail + image-search-report) ────── */
.image-preview-wrapper { display: flex; gap: 2rem; align-items: flex-start; flex-wrap: wrap; }
.image-preview-wrapper img {
    max-width: 260px; max-height: 260px;
    object-fit: contain; border-radius: 6px;
    border: 1px solid #dee2e6; background: #f0f0f0;
}
.image-info { flex: 1; min-width: 200px; }
.image-info p { margin-bottom: .5rem; font-size: .9rem; line-height: 1.5; }
.image-info strong { color: #495057; }
.image-info a { color: #0d6efd; word-break: break-all; }
.phash-value { font-family: monospace; font-size: .75rem; color: #6c757d; word-break: break-all; }

/* ── File metadata grid (image-detail + image-search-report) ─ */
.meta-section { margin-top: .75rem; }
.meta-section-title {
    font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .6px; color: #adb5bd; margin-bottom: .4rem;
}
.meta-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .2rem .75rem;
    font-size: .82rem;
}
.meta-key {
    color: #adb5bd; font-size: .72rem; text-transform: uppercase;
    letter-spacing: .3px; white-space: nowrap; padding-top: .05rem;
}
.meta-val { color: #495057; word-break: break-all; }
.meta-loading { color: #ced4da; font-style: italic; font-size: .8rem; margin-top: .5rem; }

/* ── Spinner ───────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 24px; height: 24px;
    border: 3px solid rgba(13,110,253,.2);
    border-top-color: #0d6efd;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin-right: .75rem;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
    .match-thumb        { width: 180px; height: 130px; }
    .match-thumb-broken { width: 180px; height: 130px; }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%; height: auto; position: relative;
        padding: 1rem; box-shadow: none;
        border-bottom: 1px solid #e9ecef;
    }
    .main-content { margin-left: 0; }
    .match-card { flex-direction: column; }
    .match-thumb        { width: 100%; height: 180px; }
    .match-thumb-broken { width: 100%; height: 180px; }
}
