/* ============================================================
   IAMS – Custom CSS (layered over Bootstrap 5)
   ============================================================ */

/* ── Root tokens ── */
:root {
    --clr-primary:      #1a3a5c;   /* Deep navy */
    --clr-primary-lt:   #2a5298;
    --clr-accent:       #f0a500;   /* Amber */
    --clr-surface:      #f4f6fb;
    --clr-sidebar-bg:   #0d2137;
    --clr-text:         #1e293b;
    --clr-muted:        #64748b;
    --radius:           0.5rem;
    --shadow-sm:        0 1px 4px rgba(0,0,0,.10);
    --shadow-md:        0 4px 16px rgba(0,0,0,.12);
    --transition:       0.18s ease;
}

/* ── Body ── */
body {
    background-color: var(--clr-surface);
    color: var(--clr-text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.9rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Navbar (dark navy) ── */
.bg-primary-dark { background-color: var(--clr-primary) !important; }

.navbar-brand { letter-spacing: .05em; }

.iams-navbar { padding-top: .25rem; padding-bottom: 0; }
.iams-nav-top { min-height: 46px; }
.iams-user-label {
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.iams-nav-links {
    width: 100%;
    border-top: 1px solid rgba(255,255,255,.14);
}
.iams-nav-links .navbar-nav { flex-wrap: wrap; row-gap: .15rem; }
.navbar-nav .nav-link {
    font-size: 0.8rem;
    padding: .28rem .55rem;
    border-radius: var(--radius);
    transition: background var(--transition);
    white-space: nowrap;
}
.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
    background-color: rgba(255,255,255,.15);
}

/* ── Card component ── */
.card {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    background: linear-gradient(135deg, var(--clr-primary), var(--clr-primary-lt));
    color: #fff;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    padding: .75rem 1.25rem;
}
.card-header .card-title { margin: 0; font-size: 1rem; font-weight: 600; }

/* ── Stat / KPI cards ── */
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card .stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .78rem; color: var(--clr-muted); text-transform: uppercase; letter-spacing: .04em; }

.stat-icon.blue   { background: #e0ebff; color: var(--clr-primary-lt); }
.stat-icon.green  { background: #dcfce7; color: #15803d; }
.stat-icon.amber  { background: #fef3c7; color: #d97706; }
.stat-icon.red    { background: #fee2e2; color: #b91c1c; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.teal   { background: #ccfbf1; color: #0f766e; }

/* ── Table ── */
.table thead th {
    background-color: var(--clr-primary);
    color: #fff;
    font-weight: 600;
    font-size: .82rem;
    letter-spacing: .03em;
    white-space: nowrap;
    border: none;
}
.table tbody tr { transition: background var(--transition); }
.table-hover tbody tr:hover { background-color: #eef2ff; }
.table td, .table th { vertical-align: middle; }

/* ── Page title bar ── */
.page-title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: .5rem;
    flex-wrap: wrap;
}
.page-title-bar h4 {
    margin: 0;
    font-weight: 700;
    color: var(--clr-primary);
    font-size: 1.15rem;
}

/* ── Breadcrumb ── */
.breadcrumb { font-size: .8rem; margin-bottom: .25rem; }
.breadcrumb-item.active { color: var(--clr-muted); }

/* ── Forms ── */
.form-label { font-weight: 600; font-size: .83rem; color: var(--clr-text); margin-bottom: .25rem; }
.form-control, .form-select { font-size: .875rem; border-radius: var(--radius); }
.form-control:focus, .form-select:focus {
    border-color: var(--clr-primary-lt);
    box-shadow: 0 0 0 .2rem rgba(42,82,152,.2);
}

/* ── Buttons ── */
.btn { font-size: .85rem; border-radius: var(--radius); }
.btn-primary   { background: var(--clr-primary);    border-color: var(--clr-primary); }
.btn-primary:hover { background: var(--clr-primary-lt); border-color: var(--clr-primary-lt); }

/* ── Status badges ── */
.badge { font-size: .75rem; font-weight: 600; letter-spacing: .02em; }

/* ── Alert / flash ── */
.alert { border-radius: var(--radius); font-size: .875rem; }

/* ── Sidebar (for future refactor; unused now) ── */
.sidebar { background-color: var(--clr-sidebar-bg); min-height: 100vh; }

/* ── Footer ── */
.footer-bar {
    background: #fff;
    border-top: 1px solid #e2e8f0;
    margin-top: auto;
    font-size: .78rem;
    color: var(--clr-muted);
    padding: .5rem 0;
}

/* ── DataTables overrides ── */
div.dataTables_wrapper div.dataTables_filter input { border-radius: var(--radius); font-size: .85rem; }
div.dataTables_wrapper div.dataTables_length select { border-radius: var(--radius); font-size: .85rem; }

/* ── QR / Barcode print area ── */
@media print {
    nav, .btn, .sidebar, .footer-bar, .no-print { display: none !important; }
    .print-only { display: block !important; }
    body { background: #fff; }
}

/* ── Expiry alert row highlight ── */
.row-danger  { background-color: #fee2e2 !important; }
.row-warning { background-color: #fef3c7 !important; }

/* ── Timeline (asset lifecycle) ── */
.timeline { list-style: none; padding: 0; position: relative; }
.timeline::before {
    content: '';
    position: absolute;
    left: 20px; top: 0; bottom: 0;
    width: 2px;
    background: #e2e8f0;
}
.timeline-item { display: flex; gap: 1rem; margin-bottom: 1.25rem; position: relative; }
.timeline-dot {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
    z-index: 1;
}
.timeline-body { flex: 1; }
.timeline-body .tl-date { font-size: .75rem; color: var(--clr-muted); }
.timeline-body .tl-text { font-size: .875rem; }

/* ── Batch movement map ── */
.batch-map {
    background-color: #e7eef6;
    background-image: radial-gradient(circle at 1px 1px, #d3deea 1px, transparent 0);
    background-size: 16px 16px;
    border-radius: var(--radius);
    padding: 1rem 1rem 1.25rem;
    overflow: auto;
}
.batch-web-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .85rem;
    font-size: .75rem;
    color: var(--clr-muted);
    margin-bottom: .5rem;
}
.batch-swatch {
    display: inline-block;
    width: 1.1rem;
    height: .35rem;
    border-radius: 99px;
    margin-right: .3rem;
    vertical-align: middle;
}
.batch-swatch.is-issue { background: #2a5298; }
.batch-swatch.is-return { background: #c2410c; }
.batch-swatch.is-origin { background: var(--clr-primary); width: .7rem; height: .7rem; }
.batch-web { position: relative; margin: 0 auto; }
.batch-web svg { display: block; }
.batch-web-ring { fill: none; stroke: rgba(26,58,92,.16); stroke-width: 1; }
.batch-web-spoke { stroke: rgba(26,58,92,.14); stroke-width: 1; }
.batch-web-link { fill: none; stroke: #2a5298; stroke-width: 2.25; }
.batch-web-link.is-return { stroke: #c2410c; }
.batch-web-label {
    fill: #1a3a5c;
    font-size: 11px;
    text-anchor: middle;
    stroke: #e7eef6;
    stroke-width: 4px;
    paint-order: stroke;
}
.batch-web-node {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 124px;
    text-align: center;
    text-decoration: none;
    color: var(--clr-text);
    background: #fff;
    border: 1px solid #c9d4e3;
    border-radius: 999px;
    padding: .45rem .4rem;
    box-shadow: var(--shadow-sm);
    z-index: 1;
}
.batch-web-node strong, .batch-web-node span { display: block; line-height: 1.2; }
.batch-web-node span { font-size: .68rem; color: var(--clr-muted); }
.batch-web-node.is-origin {
    background: var(--clr-primary);
    color: #fff;
    border-color: var(--clr-primary);
    width: 138px;
}
.batch-web-node.is-origin span { color: rgba(255,255,255,.8); }
.batch-web-node.is-selected { box-shadow: 0 0 0 3px var(--clr-accent); }
.batch-web-node:hover { color: inherit; border-color: var(--clr-primary-lt); }

/* ── Animations ── */
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
.card, .stat-card, .alert { animation: fadeIn .25s ease both; }
