/* ==========================================================================
   LanguSMS - application shell
   Layered on Bootstrap 5.3: this file owns the shell, cards, tables and forms.
   ========================================================================== */

:root {
    --brand: #D0FE16;
    --brand-2: #131312;
    --ink: #131312;
    --ink-2: #475569;
    --ink-3: #94a3b8;
    --line: #e2e8f0;
    --surface: #ffffff;
    --canvas: #f1f4f9;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
    --shadow: 0 4px 16px rgba(15, 23, 42, .08);
    --sidebar-w: 254px;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

body.app-body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--canvas);
    color: var(--ink);
    font-size: 14.5px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--brand-2);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .22s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.brand-link { display: flex; align-items: center; gap: 11px; color: #fff; }
.brand-link:hover { text-decoration: none; }

.brand-mark {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border-radius: 10px;
    background: var(--brand);
    font-weight: 800; font-size: 18px; color: var(--brand-2);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; letter-spacing: -.01em; }
.brand-text small { font-size: 11px; color: #94a3b8; }

.sidebar-close { color: #94a3b8; background: none; border: none; }

.sidebar-balance {
    margin: 14px;
    padding: 13px 14px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--radius-sm);
}
.sidebar-balance .label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; }
.sidebar-balance .value { display: block; font-size: 26px; font-weight: 700; color: #fff; line-height: 1.25; }
.sidebar-balance.is-low .value { color: #fca5a5; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px 16px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { width: 0; height: 0; display: none; }
.sidebar-footer { padding: 10px; border-top: 1px solid rgba(255, 255, 255, .07); }

.sidebar-nav .nav-item,
.sidebar-footer .nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px;
    border-radius: 9px;
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 500;
}
.sidebar-nav .nav-item:hover,
.sidebar-footer .nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.sidebar-nav .nav-item.active { background: var(--brand); color: var(--brand-2); box-shadow: none; }
.sidebar-nav .nav-item i, .sidebar-footer .nav-item i { font-size: 16px; width: 18px; text-align: center; }

.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 1035;
    display: none;
}
body.sidebar-open .sidebar-backdrop { display: block; }

/* --------------------------------------------------------------------------
   Main column
   -------------------------------------------------------------------------- */
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.app-topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: 14px;
    padding: 14px 24px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.015em; }
.topbar-title p { margin: 1px 0 0; font-size: 13px; color: var(--ink-2); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn-icon { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 6px 10px; }

.badge-low-balance {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 11px; border-radius: 99px;
    background: #fef2f2; color: #b91c1c;
    font-size: 12.5px; font-weight: 600;
}
.badge-low-balance:hover { text-decoration: none; background: #fee2e2; }

.user-chip {
    display: flex; align-items: center; gap: 8px;
    border: 1px solid var(--line); background: #fff;
    border-radius: 99px; padding: 4px 12px 4px 4px;
    font-size: 14px; font-weight: 500;
}
.user-chip .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--brand);
    color: var(--brand-2); font-weight: 700; font-size: 13px;
}

.app-content { flex: 1; padding: 24px; max-width: 1500px; width: 100%; }

.app-footer {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 18px 24px; border-top: 1px solid var(--line);
    color: var(--ink-3); font-size: 12.5px;
}

/* --------------------------------------------------------------------------
   Cards, stats, tables
   -------------------------------------------------------------------------- */
.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
    padding: 15px 18px;
    font-weight: 650;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-body { padding: 18px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 17px 18px;
    box-shadow: var(--shadow-sm);
}
.stat .stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat .stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.stat .stat-icon {
    width: 32px; height: 32px; border-radius: 9px;
    display: grid; place-items: center; font-size: 15px;
    background: rgba(208, 254, 22, .22); color: var(--brand-2);
}
.stat .stat-value { font-size: 27px; font-weight: 700; letter-spacing: -.02em; margin-top: 7px; line-height: 1.15; }
.stat .stat-meta { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.stat.is-good .stat-icon { background: rgba(22, 163, 74, .12); color: #16a34a; }
.stat.is-warn .stat-icon { background: rgba(245, 158, 11, .14); color: #b45309; }
.stat.is-bad  .stat-icon { background: rgba(220, 38, 38, .11); color: #dc2626; }

.table { margin: 0; font-size: 14px; }
.table > :not(caption) > * > * { padding: 11px 14px; }
.table thead th {
    background: #f8fafc;
    font-size: 11.5px; font-weight: 650;
    text-transform: uppercase; letter-spacing: .05em;
    color: var(--ink-2);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table tbody tr:hover { background: #f8fafc; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

/* --------------------------------------------------------------------------
   Status pills
   -------------------------------------------------------------------------- */
.pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 99px;
    font-size: 11.5px; font-weight: 650;
    white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-delivered, .pill-approved, .pill-completed, .pill-active, .pill-sent { background: #ecfdf5; color: #047857; }
.pill-submitted, .pill-queued, .pill-pending, .pill-running, .pill-scheduled { background: #eff6ff; color: #1d4ed8; }
.pill-failed, .pill-rejected, .pill-undelivered, .pill-suspended, .pill-expired { background: #fef2f2; color: #b91c1c; }
.pill-draft, .pill-cancelled, .pill-paused, .pill-skipped, .pill-revoked { background: #f1f5f9; color: #475569; }

/* --------------------------------------------------------------------------
   Forms & buttons
   -------------------------------------------------------------------------- */
.form-label { font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--ink); }
.form-control, .form-select {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 14px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(208, 254, 22, .32);
}
.form-text { font-size: 12.5px; color: var(--ink-3); }

.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; padding: 8px 15px; }
.btn-brand, .btn-primary {
    background: var(--brand); border-color: var(--brand); color: var(--brand-2);
}
.btn-brand:hover, .btn-primary:hover { background: var(--brand); border-color: var(--brand-2); color: var(--brand-2); opacity: .88; }
.btn-outline-secondary { border-color: var(--line); color: var(--ink-2); }
.btn-outline-secondary:hover { background: #f1f5f9; border-color: var(--ink-3); color: var(--ink); }

.code, code.inline {
    font-family: var(--mono);
    font-size: 12.5px;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 5px;
    color: #0f172a;
}

pre.code-block {
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.65;
    background: var(--brand-2);
    color: #e2e8f0;
    padding: 16px 18px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 0;
}
pre.code-block .tok-key { color: #7dd3fc; }
pre.code-block .tok-str { color: #86efac; }
pre.code-block .tok-com { color: #64748b; font-style: italic; }

.empty-state { text-align: center; padding: 46px 20px; color: var(--ink-3); }
.empty-state i { font-size: 34px; display: block; margin-bottom: 10px; opacity: .55; }
.empty-state h6 { color: var(--ink); font-weight: 650; margin-bottom: 4px; }

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */
.toast-stack {
    position: fixed; right: 20px; bottom: 20px;
    display: flex; flex-direction: column; gap: 10px;
    z-index: 1090; max-width: 360px;
}
.toast-msg {
    display: flex; align-items: flex-start; gap: 10px;
    background: #fff; border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 12px 14px; font-size: 14px;
    animation: toast-in .18s ease;
}
.toast-msg.is-success { border-left-color: #16a34a; }
.toast-msg.is-error { border-left-color: #dc2626; }
.toast-msg.is-warn { border-left-color: #f59e0b; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   Auth pages
   -------------------------------------------------------------------------- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside {
    background: var(--brand-2);
    color: #fff; padding: 52px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-aside h2 { font-size: 30px; font-weight: 750; letter-spacing: -.02em; max-width: 15ch; }
.auth-aside p { color: #cbd5e1; max-width: 42ch; }
.auth-aside .feature { display: flex; gap: 11px; margin-bottom: 14px; align-items: flex-start; }
.auth-aside .feature i { color: var(--brand); font-size: 17px; margin-top: 2px; }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; background: #fff; }
.auth-card { width: 100%; max-width: 400px; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    body.sidebar-open .app-sidebar { transform: none; }
    .app-main { margin-left: 0; }
    .app-content { padding: 16px; }
    .app-topbar { padding: 12px 16px; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}
