/* ============================================================
   FlowX ERP Design System
   Professional logistics operations console
   ============================================================ */

/* --- Design tokens --- */
:root {
    --fx-primary:       #1e40af;
    --fx-primary-dark:  #1e3a8a;
    --fx-primary-light: #3b82f6;
    --fx-teal:          #0d9488;
    --fx-teal-light:    #14b8a6;
    --fx-ink:           #0f172a;
    --fx-body:          #1e293b;
    --fx-muted:         #64748b;
    --fx-subtle:        #94a3b8;
    --fx-border:        #e2e8f0;
    --fx-divider:       #cbd5e1;
    --fx-surface:       #ffffff;
    --fx-surface-2:     #f8fafc;
    --fx-surface-3:     #f1f5f9;
    --fx-danger:        #dc2626;
    --fx-warning:       #d97706;
    --fx-success:       #059669;
    --fx-info:          #0284c7;
    --fx-page-bg:       #f1f5f9;
    --fx-nav-bg:        #0f172a;
    --fx-nav-text:      #94a3b8;
    --fx-nav-active:    #ffffff;
    --fx-nav-hover-bg:  rgba(255,255,255,0.08);
    --fx-nav-border:    rgba(255,255,255,0.06);
    --fx-ribbon-bg:     #1e3a8a;
    --fx-shadow-sm:     0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
    --fx-shadow:        0 4px 12px rgba(15,23,42,0.08), 0 1px 3px rgba(15,23,42,0.04);
    --fx-shadow-md:     0 8px 24px rgba(15,23,42,0.1);
    --fx-shadow-lg:     0 16px 40px rgba(15,23,42,0.12);
    --fx-page-header-bg: linear-gradient(135deg, #1e3a8a 0%, #1e40af 55%, #0d9488 100%);
}

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

body {
    min-height: 100vh;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--fx-body);
    background-color: var(--fx-page-bg);
    transition: background-color 0.2s ease, color 0.2s ease;
}

a { color: var(--fx-primary); text-decoration: none; }
a:hover, a:focus { color: var(--fx-primary-dark); text-decoration: underline; }

/* Page transitions */
body.has-page-transitions .page-shell { transition: opacity 0.18s ease, transform 0.18s ease; }
body.has-page-transitions.page-entering .page-shell { opacity: 0; transform: translateY(6px); }
body.has-page-transitions.page-leaving .page-shell  { opacity: 0; transform: translateY(8px); pointer-events: none; }

/* ---- Top ribbon ---- */
.top-ribbon {
    background: var(--fx-ribbon-bg);
    padding: 0.35rem 0;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.65);
    letter-spacing: 0.01em;
}

/* ---- Navigation shell ---- */
.brand-shell {
    background: var(--fx-nav-bg);
    border-bottom: 1px solid var(--fx-nav-border);
    box-shadow: var(--fx-shadow-md);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.navbar { padding-top: 0; padding-bottom: 0; }

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    padding: 0.85rem 0;
    flex-shrink: 0;
}
.brand-lockup:hover, .brand-lockup:focus { text-decoration: none; }

.brand-logo { width: auto; height: 44px; }

.brand-name { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name strong { font-size: 1.1rem; font-weight: 700; color: #ffffff; letter-spacing: -0.01em; }
.brand-name span   { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--fx-teal); }

.navbar-nav { gap: 0; align-items: stretch; }

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--fx-nav-text) !important;
    padding: 0 0.9rem !important;
    font-size: 0.84rem;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    height: 56px;
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
    text-decoration: none;
}
.nav-link:hover, .nav-link:focus { color: #ffffff !important; background: var(--fx-nav-hover-bg); text-decoration: none; }
.nav-link.active { color: #ffffff !important; border-bottom-color: var(--fx-teal); background: var(--fx-nav-hover-bg); }

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.85);
    font-size: 0.8rem;
    font-weight: 600;
}

.btn-flowx-primary {
    background: var(--fx-teal);
    border: 1px solid var(--fx-teal);
    color: #fff; font-size: 0.82rem; font-weight: 600;
    padding: 0.35rem 0.85rem; border-radius: 4px;
    transition: background 0.15s ease;
}
.btn-flowx-primary:hover, .btn-flowx-primary:focus { background: #0f766e; border-color: #0f766e; color: #fff; }

.btn-flowx-outline {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.8);
    font-size: 0.82rem; font-weight: 600;
    padding: 0.35rem 0.85rem; border-radius: 4px;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-flowx-outline:hover, .btn-flowx-outline:focus { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.35); color: #ffffff; }

.navbar-toggler { border-color: rgba(255,255,255,0.2); padding: 0.4rem 0.6rem; }
.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255,255,255,0.75)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ---- Bootstrap overrides ---- */
.btn-primary {
    background-color: var(--fx-primary);
    border-color: var(--fx-primary);
    color: #ffffff; font-weight: 600; border-radius: 5px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--fx-primary-dark) !important;
    border-color: var(--fx-primary-dark) !important;
    color: #ffffff !important; box-shadow: none !important;
}

.btn-outline-primary {
    color: var(--fx-primary); border-color: var(--fx-primary);
    background: transparent; font-weight: 600; border-radius: 5px;
    transition: background-color 0.15s ease;
}
.btn-outline-primary:hover, .btn-outline-primary:focus, .btn-outline-primary:active {
    background-color: var(--fx-primary) !important;
    border-color: var(--fx-primary) !important;
    color: #ffffff !important; box-shadow: none !important;
}

.btn-outline-secondary { border-radius: 5px; font-weight: 600; }
.btn-outline-danger    { border-radius: 5px; font-weight: 600; }
.btn-outline-success   { border-radius: 5px; font-weight: 600; }
.btn-outline-dark      { border-radius: 5px; font-weight: 600; }

.btn-light {
    background: var(--fx-surface);
    border: 1px solid var(--fx-border);
    color: var(--fx-body); font-weight: 600; border-radius: 5px;
}
.btn-light:hover, .btn-light:focus { background: var(--fx-surface-3); border-color: var(--fx-divider); color: var(--fx-ink); }

.btn-check:checked + .btn-outline-primary, .btn-outline-primary.active {
    background-color: var(--fx-primary); border-color: var(--fx-primary); color: #ffffff;
}

.btn:focus-visible, .form-control:focus, .form-select:focus {
    outline: 2px solid var(--fx-primary); outline-offset: 1px; box-shadow: none;
}

.text-primary  { color: var(--fx-primary) !important; }
.bg-primary    { background-color: var(--fx-primary) !important; }
.border-primary { border-color: var(--fx-primary) !important; }

.alert-primary { background: #eff6ff; border-color: #bfdbfe; color: var(--fx-primary-dark); }

.badge {
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: 4px;
    padding: 0.3em 0.6em;
}

/* ---- Tables ---- */
.table {
    --bs-table-hover-bg: var(--fx-surface-2);
    font-size: 0.875rem;
    color: var(--fx-body);
}
.table th {
    font-size: 0.75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--fx-muted);
    padding-top: 0.75rem; padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--fx-border);
    background-color: var(--fx-surface-2);
}
.table td { padding-top: 0.7rem; padding-bottom: 0.7rem; border-color: var(--fx-border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }

/* ---- Form controls ---- */
.form-label { font-size: 0.83rem; font-weight: 600; color: var(--fx-body); margin-bottom: 0.35rem; }
.form-control, .form-select {
    border-color: var(--fx-border); border-radius: 5px;
    font-size: 0.9rem; color: var(--fx-ink);
    background-color: var(--fx-surface); min-height: 40px;
    transition: border-color 0.15s ease;
}
.form-control:focus, .form-select:focus { border-color: var(--fx-primary); box-shadow: none; outline: none; }
.form-control::placeholder { color: var(--fx-subtle); }
.form-text { font-size: 0.78rem; color: var(--fx-muted); }
.form-check-input:checked { background-color: var(--fx-primary); border-color: var(--fx-primary); }

/* ---- Shell backdrop off ---- */
.shell-backdrop { display: none; }

/* ---- Page layout ---- */
.page-shell { padding-top: 1.5rem; padding-bottom: 3rem; max-width: 1400px; }
.message-stack { margin-bottom: 1rem; }
.message-stack .alert { border-radius: 5px; font-size: 0.875rem; }

/* ---- Page header ---- */
.page-header {
    background: var(--fx-page-header-bg);
    border-radius: 8px;
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.25rem;
    color: #ffffff;
    border: 0;
    box-shadow: var(--fx-shadow-md);
}
.page-header p { color: rgba(255,255,255,0.78); font-size: 0.875rem; margin-bottom: 0; margin-top: 0.35rem; }

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.25rem 0.65rem;
    border-radius: 3px;
    font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
    background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.92);
    border: 1px solid rgba(255,255,255,0.18);
}

.page-title {
    font-size: clamp(1.35rem, 2.2vw, 1.9rem);
    font-weight: 700; color: #ffffff;
    margin-top: 0.75rem; margin-bottom: 0; line-height: 1.25;
}

.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* ---- App panel ---- */
.app-panel {
    background: var(--fx-surface);
    border: 1px solid var(--fx-border);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--fx-shadow-sm);
}
.app-panel .panel-title {
    font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--fx-muted);
    margin-bottom: 1rem; padding-bottom: 0.6rem;
    border-bottom: 2px solid var(--fx-border);
}
.app-panel h6.text-uppercase {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.1em; color: var(--fx-muted);
    margin-bottom: 0.75rem; padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--fx-border);
}
.app-panel form .form-control,
.app-panel form .form-select { border-radius: 5px; min-height: 40px; border-color: var(--fx-border); }
.app-panel form textarea.form-control { min-height: 88px; }
.app-panel form select[multiple]      { min-height: 160px; }
.app-panel form hr { border-color: var(--fx-border); opacity: 1; margin: 1.25rem 0; }
.app-panel form .btn { border-radius: 5px; font-weight: 600; font-size: 0.875rem; }
.app-panel form .text-danger.small { font-size: 0.78rem; font-weight: 600; }

/* ---- App table ---- */
.app-table {
    background: var(--fx-surface);
    border: 1px solid var(--fx-border);
    border-radius: 8px; overflow: hidden;
    box-shadow: var(--fx-shadow-sm);
}
.app-table .table { margin-bottom: 0; }

.table-shell-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--fx-border);
    background: var(--fx-surface);
}

.table-shell-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fx-muted);
}

.subpanel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--fx-border);
}

/* ---- Action buttons ---- */
.action-cluster { display: inline-flex; align-items: center; gap: 0.35rem; }
.action-btn {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 5px; font-size: 0.85rem; padding: 0;
    transition: background-color 0.12s ease, color 0.12s ease;
}

/* ---- Stat cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem; margin-bottom: 1.25rem;
}
.stat-card {
    padding: 1.1rem 1.25rem;
    border-radius: 8px;
    background: var(--fx-surface);
    border: 1px solid var(--fx-border);
    box-shadow: var(--fx-shadow-sm);
}
.stat-card .label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fx-muted); margin-bottom: 0.4rem; }
.stat-card .value { font-size: 1.75rem; font-weight: 700; color: var(--fx-ink); line-height: 1.1; }
.stat-card .meta  { font-size: 0.75rem; color: var(--fx-muted); margin-top: 0.3rem; }
.stat-card.accent-blue    { border-left: 4px solid var(--fx-primary); }
.stat-card.accent-teal    { border-left: 4px solid var(--fx-teal); }
.stat-card.accent-warn    { border-left: 4px solid var(--fx-warning); }
.stat-card.accent-danger  { border-left: 4px solid var(--fx-danger); }
.stat-card.accent-success { border-left: 4px solid var(--fx-success); }

/* ---- Info grid (detail view) ---- */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; }
.info-item {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    background: var(--fx-surface-2);
    border: 1px solid var(--fx-border);
}
.info-item span {
    display: block; font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--fx-muted); margin-bottom: 0.3rem;
}

/* ---- Status chips ---- */
.status-chip {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.25rem 0.6rem; border-radius: 4px;
    font-size: 0.75rem; font-weight: 700; letter-spacing: 0.03em;
}
.status-chip.serviceable     { background: #d1fae5; color: #065f46; }
.status-chip.oda             { background: #fef3c7; color: #92400e; }
.status-chip.non-serviceable { background: #fee2e2; color: #991b1b; }

/* ---- Timeline ---- */
.timeline-stack {
    display: flex; flex-direction: column; gap: 0;
    position: relative;
}
.timeline-stack::before {
    content: ""; position: absolute;
    left: 0.9rem; top: 1.5rem; bottom: 1.5rem;
    width: 2px; background: var(--fx-border); z-index: 0;
}
.timeline-card {
    position: relative;
    padding: 1rem 1rem 1rem 2.75rem;
    border-radius: 6px;
    border: 1px solid var(--fx-border);
    background: var(--fx-surface);
    margin-bottom: 0.6rem;
    box-shadow: var(--fx-shadow-sm);
}
.timeline-card::before {
    content: ""; position: absolute;
    left: 0.525rem; top: 1.2rem;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--fx-primary);
    border: 2px solid var(--fx-surface);
    z-index: 1;
}

/* ---- App hero (public pages) ---- */
.app-hero {
    background: var(--fx-surface);
    border: 1px solid var(--fx-border);
    border-radius: 8px;
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--fx-shadow-sm);
}

/* ---- Utility card ---- */
.utility-card {
    padding: 1.5rem; border-radius: 8px;
    border: 1px solid var(--fx-border);
    background: var(--fx-surface);
    box-shadow: var(--fx-shadow-sm);
}

/* ---- Summary / app card ---- */
.summary-card, .app-card {
    background: var(--fx-surface);
    border: 1px solid var(--fx-border);
    border-radius: 8px;
    box-shadow: var(--fx-shadow-sm);
    overflow: hidden;
}

/* ---- Reveal animations ---- */
.reveal-on-scroll { opacity: 0; transform: translateY(8px); transition: opacity 0.3s ease, transform 0.3s ease; }
.reveal-on-scroll.revealed { opacity: 1; transform: translateY(0); }
.reveal-delay-1 { transition-delay: 0.03s; }
.reveal-delay-2 { transition-delay: 0.06s; }
.reveal-delay-3 { transition-delay: 0.09s; }
.reveal-delay-4 { transition-delay: 0.12s; }
.reveal-delay-5 { transition-delay: 0.15s; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
    .reveal-on-scroll { opacity: 1; transform: none; }
}

/* ---- Responsive ---- */
@media (max-width: 1199.98px) {
    .navbar-collapse {
        background: var(--fx-nav-bg);
        padding: 0.5rem 0 1rem;
        border-top: 1px solid var(--fx-nav-border);
    }
    .navbar-nav .nav-link { height: auto; padding: 0.6rem 1rem !important; border-bottom: 0; border-left: 3px solid transparent; }
    .navbar-nav .nav-link.active { border-left-color: var(--fx-teal); border-bottom: 0; }
    .nav-actions { padding: 0.5rem 1rem 0; flex-wrap: wrap; gap: 0.5rem; }
    .nav-actions .btn, .nav-actions .user-pill, .nav-actions form { flex: 1 1 calc(50% - 0.5rem); }
    .nav-actions form .btn { width: 100%; }
    .modal-dialog.modal-lg { max-width: 96vw; }
}

@media (max-width: 767.98px) {
    .brand-logo { height: 38px; }
    .brand-name strong { font-size: 0.95rem; }
    .page-header { padding: 1.25rem; }
    .app-panel   { padding: 1.1rem; }
    .nav-actions .btn, .nav-actions .user-pill, .nav-actions form { flex: 1 1 100%; }
    .stats-grid    { grid-template-columns: 1fr 1fr; }
    .info-grid     { grid-template-columns: 1fr 1fr; }
    .app-panel form .d-flex.gap-2 { flex-direction: column; }
    .app-panel form .d-flex.gap-2 .btn { width: 100%; }
}

@media (max-width: 479.98px) {
    .stats-grid    { grid-template-columns: 1fr; }
    .info-grid     { grid-template-columns: 1fr; }
}
