/* ════════════════════════════════════════════════════
   Escadesk — design system ported from VPA Stock App
════════════════════════════════════════════════════ */

:root {
    --sidebar-w:        260px;
    --sidebar-bg:       #0f172a;
    --sidebar-hover:    #1e293b;
    --sidebar-active:   #1d4ed8;
    --sidebar-border:   rgba(255,255,255,.07);
    --body-bg:          #f1f5f9;
    --card-bg:          #ffffff;
    --card-border:      #e2e8f0;
    --card-shadow:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --text:             #0f172a;
    --text-muted:       #64748b;
    --radius:           12px;
    --accent:           #1d4ed8;
    --accent-dark:      #1e40af;
    --accent-rgb:       29, 78, 216;
    --brand-gradient:   linear-gradient(135deg, #1d4ed8, #7c3aed);
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--body-bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Bootstrap accent alignment */
.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-dark);
    --bs-btn-hover-border-color: var(--accent-dark);
    --bs-btn-active-bg: var(--accent-dark);
    --bs-btn-active-border-color: var(--accent-dark);
    --bs-btn-disabled-bg: var(--accent);
    --bs-btn-disabled-border-color: var(--accent);
}

.btn-outline-primary {
    --bs-btn-color: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent);
    --bs-btn-hover-border-color: var(--accent);
    --bs-btn-active-bg: var(--accent-dark);
    --bs-btn-active-border-color: var(--accent-dark);
}

.pagination {
    --bs-pagination-active-bg: var(--accent);
    --bs-pagination-active-border-color: var(--accent);
    --bs-pagination-color: var(--accent);
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.25rem rgba(var(--accent-rgb), 0.15);
}

a { color: var(--accent); }

/* ── App shell (admin): fixed sidebar + main ── */
body.app-shell {
    margin: 0;
    font-size: 14px;
    display: flex;
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 20px 16px 18px;
    border-bottom: 1px solid var(--sidebar-border);
    text-decoration: none;
}
.sidebar-brand-icon {
    width: 38px; height: 38px;
    background: var(--brand-gradient);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 19px; flex-shrink: 0;
}
.sidebar-brand-name   { color: #f1f5f9; font-size: 15px; font-weight: 700; display: block; line-height: 1.2; }
.sidebar-brand-sub    { color: #64748b; font-size: 11px; }

.sidebar-section      { padding: 20px 10px 6px; }
.sidebar-label        { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #334155; padding: 0 8px; margin-bottom: 4px; }

.sidebar-nav          { list-style: none; margin: 0; padding: 0; }
.sidebar-nav li a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px;
    color: #94a3b8; font-size: 13.5px; font-weight: 500;
    text-decoration: none; transition: background .15s, color .15s;
    margin-bottom: 2px;
}
.sidebar-nav li a i { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-nav li a:hover  { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar-nav li a.active { background: var(--sidebar-active); color: #fff; }

.sidebar-footer {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid var(--sidebar-border);
}
.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 10px; border-radius: 8px;
    background: rgba(255,255,255,.04); margin-bottom: 8px;
}
.sidebar-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--brand-gradient);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.sidebar-user-name  { font-size: 12px; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { font-size: 11px; color: #475569; }
.sidebar-signout {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%; padding: 7px 12px; border-radius: 8px;
    border: 1px solid rgba(255,255,255,.12); background: transparent;
    color: #64748b; font-size: 12.5px; text-decoration: none;
    transition: background .15s, color .15s;
}
.sidebar-signout:hover { background: rgba(255,255,255,.06); color: #94a3b8; }

/* ── Layout main ─────────────────────────────── */
.layout-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ── Page header ─────────────────────────────── */
.page-header {
    padding: 28px 32px 0;
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.page-header-left h1 { font-size: 20px; font-weight: 700; margin: 0 0 2px; }
.page-header-left p  { font-size: 13px; color: var(--text-muted); margin: 0; }

.page-body { padding: 20px 32px 40px; }

/* Small screens: sidebar becomes a top bar */
@media (max-width: 991.98px) {
    body.app-shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .sidebar-section { padding: 10px 10px 2px; }
    .sidebar-nav { display: flex; flex-wrap: wrap; gap: 2px; }
    .sidebar-footer { padding: 10px; }
    .page-header { padding: 20px 16px 0; }
    .page-body { padding: 14px 16px 28px; }
}

/* ── Cards ───────────────────────────────────── */
.app-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}
.app-card + .app-card { margin-top: 16px; }

.app-card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--card-border);
    background: #fafafa;
}
.app-card-title { font-size: 13px; font-weight: 600; margin: 0; }
.app-card-body  { padding: 20px; }

/* ── Filter bar ──────────────────────────────── */
.filter-bar {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    padding: 16px 20px;
    margin-bottom: 16px;
}

/* ── Table ───────────────────────────────────── */
.app-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.app-table thead th {
    background: #f8fafc; color: #475569;
    font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    padding: 10px 14px; border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
}
.app-table tbody tr:hover td { background: #f8fafc; }
.app-table td {
    padding: 11px 14px; border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.app-table tbody tr:last-child td { border-bottom: none; }

/* ── Pill badges (VPA rec-badge system) ──────── */
.rec-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill-success { background: #dcfce7; color: #15803d; }
.pill-info    { background: #dbeafe; color: #1d4ed8; }
.pill-neutral { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.pill-warn    { background: #fef3c7; color: #b45309; }
.pill-danger  { background: #fee2e2; color: #b91c1c; }
.pill-purple  { background: #ede9fe; color: #6d28d9; }

/* ── Empty state ─────────────────────────────── */
.empty-state { text-align: center; padding: 60px 24px; color: var(--text-muted); }
.empty-state i { font-size: 40px; opacity: .3; display: block; margin-bottom: 12px; }
.empty-state strong { display: block; font-size: 15px; color: #334155; margin-bottom: 4px; }

/* ── Auth pages ──────────────────────────────── */
body.auth-page {
    margin: 0;
    display: flex;
    justify-content: center; align-items: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
}
.auth-wrapper { width: 100%; max-width: 420px; padding: 1.25rem; }
.auth-wrapper.auth-wide { max-width: 560px; }
.auth-card    { background: #fff; border-radius: 16px; padding: 40px; box-shadow: 0 24px 64px rgba(0,0,0,.3); }
.auth-logo    { text-align: center; margin-bottom: 28px; }
.auth-logo .brand-icon {
    width: 52px; height: 52px;
    background: var(--brand-gradient);
    border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 26px; margin-bottom: 12px;
}
.auth-logo h5     { font-size: 18px; font-weight: 700; margin: 0 0 2px; }
.auth-logo small  { color: var(--text-muted); font-size: 12px; }

/* ── Live Component / Turbo loading indicators ── */
.live-component { position: relative; }

.live-loading-bar {
    display: none;
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    overflow: hidden;
    background: rgba(29, 78, 216, .12);
    border-radius: 3px 3px 0 0;
    z-index: 20;
}
.live-loading-bar.is-loading { display: block; }
.live-loading-bar::before {
    content: "";
    position: absolute;
    inset: 0;
    width: 40%;
    background: var(--brand-gradient);
    border-radius: inherit;
    animation: live-bar-slide 1s ease-in-out infinite;
}
@keyframes live-bar-slide {
    0%   { transform: translateX(-110%); }
    100% { transform: translateX(360%); }
}

.live-busy { opacity: .55; pointer-events: none; transition: opacity .15s ease; }

/* Auto-hiding alerts (autohide Stimulus controller) */
.esc-fade-out { opacity: 0; transition: opacity .4s ease; }

.esc-btn-close-sm { font-size: .7rem; padding: .4rem; }

.turbo-progress-bar { height: 3px; background: var(--brand-gradient); }

/* ════════════════════════════════════════════════════
   Storefront (public shop)
════════════════════════════════════════════════════ */

body.storefront {
    display: flex;
    flex-direction: column;
}

body.storefront main { flex: 1 0 auto; }

/* Sticky translucent navbar */
.esc-navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.esc-navbar .navbar-brand { font-weight: 700; letter-spacing: -0.02em; }
.esc-navbar .nav-link { font-weight: 500; }

/* ── Navbar dropdowns (menu + account) ───────── */
.esc-navbar .dropdown-menu {
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: 0 12px 28px rgba(15, 23, 42, .16);
    padding: 6px;
    min-width: 230px;
    margin-top: .4rem;
}

.esc-navbar .dropdown-menu.show,
.esc-navbar .dropdown-menu[data-bs-popper] {
    animation: esc-dropdown-in .15s ease;
}

@keyframes esc-dropdown-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.esc-navbar .dropdown-item {
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
}

.esc-navbar .dropdown-item:hover,
.esc-navbar .dropdown-item:focus {
    background: rgba(var(--accent-rgb), .08);
    color: var(--accent-dark);
}

/* Split caret: the label navigates, the caret opens the submenu */
.esc-caret {
    background: none;
    border: 0;
    padding: .5rem .4rem .5rem 0;
    color: rgba(255, 255, 255, .55);
    line-height: 1;
    transition: color .15s;
}
.esc-caret:hover { color: #fff; }
.esc-caret i { display: inline-block; font-size: .7rem; transition: transform .15s ease; }
.esc-caret[aria-expanded="true"] i { transform: rotate(180deg); }

/* Desktop: submenus also open on hover; the parent link stays clickable */
@media (min-width: 992px) {
    .esc-nav-dropdown:hover > .dropdown-menu {
        display: block;
        animation: esc-dropdown-in .15s ease;
    }
    .esc-nav-dropdown > .dropdown-menu { margin-top: 0; }
    .esc-nav-dropdown:hover .esc-caret i { transform: rotate(180deg); }
}

/* Collapsed (mobile) navbar: render the submenu inline, card-style */
@media (max-width: 991.98px) {
    .esc-navbar .esc-nav-dropdown .dropdown-menu {
        background: rgba(255, 255, 255, .06);
        border: 0;
        box-shadow: none;
        margin: 0 0 .5rem .75rem;
    }
    .esc-navbar .esc-nav-dropdown .dropdown-item { color: rgba(255, 255, 255, .8); }
    .esc-navbar .esc-nav-dropdown .dropdown-item:hover { background: rgba(255, 255, 255, .1); color: #fff; }
}

/* Hero */
.esc-hero {
    background:
        radial-gradient(1200px 400px at 85% -10%, rgba(var(--accent-rgb), 0.35), transparent 60%),
        radial-gradient(800px 300px at 10% 110%, rgba(124, 58, 237, 0.25), transparent 60%),
        #0f172a;
    color: #fff;
    border-radius: 1.25rem;
}
.esc-hero h1 { font-weight: 800; letter-spacing: -0.03em; }
.esc-hero .lead { color: rgba(255, 255, 255, 0.75); }

/* Product cards */
.esc-product-card {
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.esc-product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}
.esc-product-thumb {
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    background: linear-gradient(135deg, #eff6ff 0%, #ede9fe 100%);
}
.esc-price { font-weight: 700; color: var(--text); }

/* Product detail modal gallery */
.esc-gallery-main { aspect-ratio: 1 / 1; }
.esc-gallery-thumb {
    width: 64px;
    height: 64px;
    padding: 0;
    border: 2px solid var(--card-border);
    border-radius: 0.5rem;
    overflow: hidden;
    background: none;
    opacity: 0.7;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}
.esc-gallery-thumb:hover { opacity: 1; }
.esc-gallery-thumb.active {
    border-color: var(--bs-primary, #0d6efd);
    opacity: 1;
}
.esc-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Search input */
.esc-search { position: relative; }
.esc-search .form-control {
    border-radius: 999px;
    padding-left: 2.75rem;
    box-shadow: var(--card-shadow);
    border-color: var(--card-border);
}
.esc-search .esc-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
    z-index: 5;
}

/* Hero slideshow */
.esc-slideshow {
    border-radius: 1.25rem;
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.esc-slide-img {
    aspect-ratio: 8 / 3;
    object-fit: cover;
}

.esc-slide-caption {
    left: 6%;
    right: auto;
    bottom: 12%;
    max-width: 60%;
    padding: 1rem 1.4rem;
    border-radius: var(--radius);
    background: rgba(15, 23, 42, .35);
}

.esc-slide-title {
    font-size: clamp(1.1rem, 2.6vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0;
    text-shadow: 0 1px 3px rgba(15, 23, 42, .45);
}

.esc-slide-sub {
    font-size: clamp(.8rem, 1.6vw, 1rem);
    color: rgba(255, 255, 255, .9);
    text-shadow: 0 1px 2px rgba(15, 23, 42, .45);
}

@media (max-width: 767.98px) {
    .esc-slide-img { aspect-ratio: 16 / 9; }
    .esc-slide-caption { max-width: 85%; bottom: 8%; }
}

/* Feature strip */
.esc-feature {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
}
.esc-feature svg { color: var(--accent); }

/* Trix rich-text editor */
trix-editor.form-control {
    min-height: 12rem;
    height: auto;
    background: #fff;
}
trix-toolbar .trix-button-group { background: #fff; }

/* Footer */
.esc-footer { background: #0f172a; color: #94a3b8; }
.esc-footer a { color: #cbd5e1; text-decoration: none; }
.esc-footer a:hover { color: #fff; }
