/* ============================================================================
   pKaAtlas — Publication-oriented academic database interface
   Color: Deep ocean blue + teal + restrained amber accent
   ============================================================================ */

:root {
    --navy: #083b5c;
    --navy-dark: #052a43;
    --blue: #11758a;
    --blue-light: #edf8fa;
    --gold: #d39a2c;
    --green: #138269;
    --red: #c0392b;
    --gray-50: #f4f8fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-500: #adb5bd;
    --gray-700: #495057;
    --gray-900: #212529;
    --white: #ffffff;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", Consolas, monospace;
    --shadow-sm: 0 4px 16px rgba(5,42,67,.07);
    --shadow: 0 12px 32px rgba(5,42,67,.12);
    --radius: 12px;
    --radius-sm: 7px;
}

/* ---- Global Reset ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--gray-900);
    background: var(--gray-50);
    margin: 0;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; color: #1d4ed8; }

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--navy);
    margin-top: 0;
}

/* ---- Navigation Bar ---- */
.navbar {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%) !important;
    padding: 0 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
    min-height: 56px;
}
.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    color: #fff !important;
    padding: 0.5rem 0;
    display: inline-flex;
    align-items: center;
    gap: .65rem;
}
.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 10px;
    background: rgba(255,255,255,.07);
}
.brand-mark img { width: 33px; height: 33px; object-fit: contain; }
.brand-wordmark { line-height: 1; }
.brand-wordmark sub { font-size: .58em; bottom: -.05em; position: relative; }
.navbar .nav-link {
    color: rgba(255,255,255,.85) !important;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 1rem 1rem !important;
    transition: color .15s, background .15s;
}
.navbar .nav-link:hover,
.navbar .nav-link.active {
    color: #fff !important;
    background: rgba(255,255,255,.1);
    text-decoration: none;
}
#stats-badge {
    color: var(--gold) !important;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ---- Hero Section (minimal, search-first) ---- */
.hero {
    background:
        radial-gradient(circle at 84% 20%, rgba(47,196,190,.18), transparent 30%),
        linear-gradient(135deg, #052f4b 0%, #0b596a 54%, #06354e 100%);
    color: #fff;
    padding: 3.6rem 0 2.8rem;
    margin-bottom: 2.5rem;
    position: relative;
    overflow: hidden;
}
.hero-title {
    font-size: 2.45rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: .3rem;
    letter-spacing: -.5px;
}
.hero-subtitle {
    color: rgba(255,255,255,.78);
    font-size: 1rem;
    max-width: 620px;
    margin: 0 auto 1.5rem;
    line-height: 1.5;
}
/* Hero stat line */
.hero-statline {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.75rem;
    font-size: .82rem;
    color: rgba(255,255,255,.55);
}
.hero-statline strong {
    color: #f0c76c;
    font-weight: 700;
}

/* Search box */
.hero-search { max-width: 580px; margin: 0 auto; }
.search-box {
    display: flex;
    align-items: center;
    gap: 0;
    background: #fff;
    border: 1px solid rgba(255,255,255,.32);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,.3);
}
.search-icon {
    font-size: 1.1rem;
    color: var(--gray-500);
    align-self: stretch;
    display: grid;
    place-items: center;
    padding: 0 0 0 1rem;
    background: #fff;
    flex-shrink: 0;
}
.search-input {
    flex: 1;
    height: 52px;
    border: none;
    outline: none;
    padding: 0 .75rem;
    font-size: .95rem;
    background: #fff;
    color: var(--gray-900);
    min-width: 0;
}
.search-input::placeholder { color: var(--gray-500); }
.search-btn {
    flex-shrink: 0;
    align-self: stretch;
    min-height: 52px;
    border: none;
    background: #11758a;
    color: #fff;
    padding: 0 1.5rem;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
}
.search-btn:hover { background: #0c6072; }
.search-hints {
    margin-top: .6rem;
    font-size: .78rem;
    color: rgba(255,255,255,.45);
}
.search-hints a {
    color: rgba(255,255,255,.6);
    text-decoration: none;
    transition: color .15s;
}
.search-hints a:hover { color: #fff; text-decoration: underline; }

/* ---- Section Headers ---- */
.section-header {
    text-align: center;
    margin-bottom: 1.25rem;
}
.section-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: .2rem;
}

/* ---- Cards ---- */
.card {
    background: var(--white);
    border: 1px solid #dce8ed;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
    overflow: hidden;
}
.card-header {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 0.93rem;
    color: var(--navy);
}
.card-body { padding: 1.25rem; }

/* ---- Tables ---- */
.table {
    width: 100%;
    margin-bottom: 0;
    font-size: 0.86rem;
}
.table thead th {
    background: var(--gray-100);
    border-bottom: 2px solid var(--gray-300);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-700);
    padding: 0.6rem 0.75rem;
    white-space: nowrap;
}
.table tbody td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
    border-top: 1px solid var(--gray-200);
}
.table tbody tr:hover { background: var(--blue-light); }

/* ---- Badges ---- */
.badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25em 0.6em;
    border-radius: 3px;
    letter-spacing: 0.3px;
}
.badge-A, .badge.bg-success { background: #dff4ea !important; color: #126b4e !important; border: 1px solid #bde4d2; }
.badge-B, .badge.bg-info    { background: #dff2f6 !important; color: #0a6071 !important; border: 1px solid #b9dfe7; }
.badge-C, .badge.bg-warning { background: #fff2ce !important; color: #7c5a05 !important; border: 1px solid #ecd992; }
.badge-D, .badge.bg-danger  { background: #f8e3e0 !important; color: #8a3731 !important; border: 1px solid #e9c0bb; }

/* ---- Buttons ---- */
.btn {
    font-weight: 600;
    font-size: 0.88rem;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1.25rem;
    transition: all .15s;
}
.btn-primary { background: var(--blue); border-color: var(--blue); }
.btn-primary:hover { background: #0c6072; border-color: #0c6072; }
.btn-outline-primary { color: var(--blue); border-color: var(--blue); }
.btn-outline-primary:hover { background: var(--blue); color: #fff; }

/* ---- Form Controls ---- */
.form-control, .form-select {
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ---- Compound Report Card ---- */
.compound-header {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    flex-wrap: wrap;
}
.compound-structure {
    flex: 0 0 auto;
    min-width: 280px;
    background: #fafafa;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    text-align: center;
}
.compound-structure img { max-width: 100%; height: auto; }
.compound-meta { flex: 1; min-width: 250px; }
.compound-meta dl {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0.35rem 1rem;
    font-size: 0.88rem;
    margin: 0;
}
.compound-meta dt { font-weight: 600; color: var(--gray-700); }
.compound-meta dd { color: var(--gray-900); word-break: break-all; }
.compound-meta .font-monospace {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

/* ---- Data Tabs ---- */
.data-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 1rem;
}
.data-tab {
    padding: 0.6rem 1.1rem;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all .15s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.data-tab:hover { color: var(--blue); }
.data-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ---- Dashboard Stats ---- */
.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.35rem 1.15rem;
    text-align: center;
    transition: box-shadow .15s;
    height: 100%;
    min-height: 154px;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: #b7d8df; }
.stat-card .stat-number {
    width: 100%;
    height: 40px;
    display: grid;
    place-items: center;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--navy);
    line-height: 1.1;
}
.stat-card .stat-number .bi { display: block; line-height: 1; }
.stat-card .stat-label {
    font-size: 0.82rem;
    color: var(--gray-700);
    margin-top: 0.35rem;
    min-height: 1.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}
.stat-card .stat-sub {
    font-size: 0.73rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
    line-height: 1.45;
    max-width: 230px;
}

/* ---- Browse sidebar ---- */
.browse-sidebar .list-group-item {
    border: none;
    padding: 0.55rem 1rem;
    font-size: 0.88rem;
    color: var(--gray-700);
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    cursor: pointer;
}
.browse-sidebar .list-group-item:hover,
.browse-sidebar .list-group-item.active {
    background: var(--blue-light);
    color: var(--blue);
    font-weight: 600;
}
.browse-sidebar .list-group-item .bi { margin-right: 6px; }

/* ---- Featured compound carousel ---- */
.feat-carousel {
    position: relative;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    align-items: center;
    gap: .75rem;
}
.feat-grid {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 260px);
    justify-content: center;
    gap: 1rem;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline mandatory;
    scrollbar-width: thin;
    scrollbar-color: #aac6cf transparent;
    padding: .4rem .2rem .75rem;
}
.feat-control {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid #cbdde3;
    color: var(--navy);
    background: #fff;
    box-shadow: var(--shadow-sm);
    display: grid;
    place-items: center;
}
.feat-control:hover { color: #fff; background: var(--blue); border-color: var(--blue); }
.feat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    transition: box-shadow .15s, transform .15s;
    text-decoration: none !important;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    scroll-snap-align: center;
    min-height: 196px;
}
.feat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    border-color: var(--blue);
}
.feat-card .structure-svg {
    width: 100%;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fbfc;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}
.feat-card .feat-info {
    font-size: 0.8rem;
    color: var(--gray-700);
}
.feat-card .feat-info strong {
    color: var(--navy);
    font-size: 0.9rem;
}

/* ---- Footer ---- */
.footer {
    background: var(--navy-dark);
    color: rgba(255,255,255,.55);
    padding: 1.5rem 0;
    margin-top: 3rem;
    font-size: 0.83rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 750;
    color: var(--navy);
    display: flex;
    align-items: center;
    gap: .65rem;
}
.page-title .bi { color: var(--blue); }
.page-intro { color: var(--gray-700); max-width: 820px; margin-bottom: 1.4rem; }
.footer a { color: rgba(255,255,255,.8); }
.footer a:hover { color: #fff; text-decoration: underline; }
.footer .footer-title {
    font-weight: 700;
    color: #fff;
    font-size: 0.88rem;
    margin-bottom: 0.4rem;
}

/* ---- Breadcrumb ---- */
.breadcrumb {
    background: none;
    padding: 0;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}
.breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    font-weight: 700;
    color: var(--gray-500);
}

/* ---- Pagination ---- */
.pagination .page-link {
    border: 1px solid var(--gray-300);
    color: var(--blue);
    font-size: 0.83rem;
}
.pagination .active .page-link {
    background: var(--blue);
    border-color: var(--blue);
}

/* ---- Progress bars ---- */
.progress {
    background: var(--gray-200);
    border-radius: 10px;
    height: 10px;
}
.progress-bar { border-radius: 10px; }

/* ---- Alert / Skeleton states ---- */
.skeleton { pointer-events: none; opacity: .6; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .hero { padding: 2rem 0 1.5rem; }
    .hero-title { font-size: 1.5rem; }
    .hero-subtitle { font-size: .85rem; }
    .hero-statline { gap: 1rem; font-size: .75rem; }
    .feat-carousel { grid-template-columns: minmax(0, 1fr); }
    .feat-grid { justify-content: start; grid-auto-columns: minmax(235px, 82vw); gap: .75rem; }
    .feat-control { display: none; }
    .compound-header { flex-direction: column; }
    .compound-meta dl { grid-template-columns: 1fr; }
    .search-box { border-radius: 8px; flex-wrap: wrap; background: #fff; }
    .search-input { flex: 0 0 100%; width: 100%; height: 48px; padding: 0 .75rem; border-radius: 7px 7px 0 0; }
    .search-btn { min-height: 46px; margin-top: -1px; padding: 0 1rem; border-radius: 0 0 7px 7px; width: 100%; justify-content: center; }
    .search-icon { display: none; }
}
@media (max-width: 480px) {
    .hero-title { font-size: 1.35rem; }
    .feat-grid { grid-auto-columns: minmax(230px, 86vw); }
    .stat-card .stat-number { font-size: 1.4rem; }
}

/* ---- Utility ---- */
.text-mono { font-family: var(--font-mono); }
.text-gold { color: var(--gold); }
.bg-navy { background: var(--navy); }
