﻿/* ============================================
   PharmaDB Image Viewer — Stile globale
   ============================================ */

:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --border: #e5e7eb;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #4f46e5;
    --primary-2: #7c3aed;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-soft: #fef2f2;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 8px 24px rgba(15, 23, 42, .08);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ============================================
   LAYOUT
   ============================================ */

.app {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 0 12px 24px;
    color: #fff;
}

.brand-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.brand-accent {
    color: #a5b4fc;
}

.sidebar nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: .94rem;
    transition: all .2s;
}

    .nav-link:hover {
        background: rgba(255, 255, 255, .08);
        color: #fff;
    }

    .nav-link.active {
        background: var(--primary);
        color: #fff;
    }

.nav-icon {
    font-size: 1.1rem;
}

.sidebar-footer {
    padding: 16px 12px 8px;
    border-top: 1px solid rgba(255,255,255,.1);
    color: #64748b;
    font-size: .78rem;
}

.content {
    padding: 32px 40px;
    max-width: 960px;
    width: 100%;
}

/* ============================================
   PAGE
   ============================================ */

.page-header h1 {
    margin: 0 0 8px;
    font-size: 1.8rem;
    font-weight: 700;
}

.subtitle {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 1rem;
}

/* ============================================
   CARD
   ============================================ */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 20px;
    transition: box-shadow .2s;
}

    .card:hover {
        box-shadow: var(--shadow);
    }

/* ============================================
   TABS
   ============================================ */

.tabs {
    display: flex;
    gap: 4px;
    background: var(--surface-2);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 20px;
    width: fit-content;
}

.tab {
    border: none;
    background: transparent;
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 500;
    color: var(--muted);
    transition: all .2s;
}

    .tab:hover {
        color: var(--text);
    }

    .tab.active {
        background: var(--surface);
        color: var(--primary);
        box-shadow: 0 1px 3px rgba(0,0,0,.1);
        font-weight: 600;
    }

/* ============================================
   SEARCH
   ============================================ */

.search-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.input {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: border .2s, box-shadow .2s;
    outline: none;
    background: var(--surface);
}

    .input:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px var(--primary-soft);
    }

    .input:disabled {
        opacity: .6;
        cursor: not-allowed;
    }

.input-error {
    border-color: var(--danger);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
    font-family: inherit;
}

    .btn:disabled {
        opacity: .6;
        cursor: not-allowed;
    }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: #fff;
}

    .btn-primary:hover:not(:disabled) {
        background: var(--primary-hover);
        box-shadow: 0 4px 12px rgba(79, 70, 229, .35);
    }

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}

    .btn-ghost:hover {
        background: var(--surface-2);
        color: var(--text);
    }

/* ============================================
   SPINNER
   ============================================ */

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   ALERT
   ============================================ */

.alert {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: .95rem;
}

.alert-error {
    background: var(--danger-soft);
    border: 1px solid #fecaca;
    color: #991b1b;
}

.alert-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 600;
    margin-left: 8px;
}

.badge-error {
    background: var(--danger);
    color: #fff;
}

/* ============================================
   RESULT
   ============================================ */

.result-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: center;
}

.result-image {
    background: var(--surface-2);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

    .result-image img {
        max-width: 100%;
        max-height: 400px;
        object-fit: contain;
    }

.result-body h2 {
    margin: 0 0 16px;
    font-size: 1.2rem;
}

.kv {
    margin: 0 0 20px;
    display: grid;
    gap: 8px;
}

    .kv dt {
        font-weight: 600;
        font-size: .85rem;
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: .03em;
    }

    .kv dd {
        margin: 0 0 8px;
        font-size: 1rem;
    }

/* ============================================
   HISTORY
   ============================================ */

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

    .history-header h2 {
        margin: 0;
        font-size: 1.1rem;
    }

.table-wrap {
    overflow-x: auto;
}

.history {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

    .history th {
        text-align: left;
        padding: 8px 12px;
        border-bottom: 2px solid var(--border);
        color: var(--muted);
        font-weight: 600;
        white-space: nowrap;
    }

    .history td {
        padding: 10px 12px;
        border-bottom: 1px solid var(--border);
        vertical-align: top;
    }

    .history tr:last-child td {
        border-bottom: none;
    }

/* ============================================
   STATUS BADGES
   ============================================ */

.status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 600;
}

.status-ok {
    background: #ecfdf5;
    color: #047857;
}

.status-warn {
    background: #fffbeb;
    color: #b45309;
}

.status-err {
    background: #fef2f2;
    color: #b91c1c;
}

/* ============================================
   MISC
   ============================================ */

.muted {
    color: var(--muted);
}

.small {
    font-size: .8rem;
    margin-top: 4px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 12px 16px;
    }

        .sidebar nav {
            flex-direction: row;
        }

    .sidebar-footer {
        display: none;
    }

    .content {
        padding: 16px;
    }

    .result-card {
        grid-template-columns: 1fr;
    }

    .search-row {
        flex-direction: column;
    }
}
