/* ============================================================
   Tottini SMS — brand stylesheet
   Brand orange #F08200, cream backgrounds, airy layout.
   ============================================================ */

:root {
    --brand:        #F08200;
    --brand-700:    #C66A00;
    --brand-50:     #FFF4E6;
    --brand-100:    #FFE6C7;

    --ink:          #1A1A1A;
    --ink-2:        #3D3D3D;
    --muted:        #7A7A7A;
    --line:         #EFEAE3;
    --line-2:       #E5DFD6;

    --bg:           #FFFBF5;
    --surface:      #FFFFFF;

    --success:      #16A34A;
    --success-50:   #DCFCE7;
    --danger:       #DC2626;
    --danger-50:    #FEE2E2;
    --warning:      #F59E0B;
    --warning-50:   #FEF3C7;
    --info:         #0EA5E9;
    --info-50:      #E0F2FE;

    --shadow-sm:    0 1px 2px rgba(26,26,26,.04), 0 1px 1px rgba(26,26,26,.03);
    --shadow:       0 4px 14px rgba(26,26,26,.06), 0 1px 2px rgba(26,26,26,.04);
    --shadow-lg:    0 18px 40px rgba(26,26,26,.10), 0 4px 8px rgba(26,26,26,.04);

    --radius:       14px;
    --radius-sm:    10px;
}

* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

html, body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-feature-settings: 'cv11', 'ss01';
}

/* ----------- Layout shell ----------- */

.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 28px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Sidebar header: brand + (mobile-only) close button */
.sidebar-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 10px 22px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
}
.sidebar .brand { display: block; }
.sidebar .brand img {
    height: 28px;
    width: auto;
    display: block;
}
.sidebar-close {
    display: none;       /* shown only on mobile */
    background: var(--brand-50);
    color: var(--brand-700);
    border: 0;
    width: 34px; height: 34px;
    border-radius: 10px;
    align-items: center; justify-content: center;
    font-size: 16px;
    cursor: pointer;
}
.sidebar-close:hover { background: var(--brand-100); }

/* ----------- Mobile top bar (hidden on desktop) ----------- */
.mobile-topbar { display: none; }
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(20, 20, 20, .45);
    z-index: 55;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}

.nav-group-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 14px 10px 8px;
}

.sidebar .nav-link {
    display: flex; align-items: center; gap: 10px;
    color: var(--ink-2);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 14px;
    margin: 2px 0;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}
.sidebar .nav-link i { font-size: 17px; opacity: .8; }
.sidebar .nav-link:hover { background: var(--brand-50); color: var(--brand-700); }
.sidebar .nav-link.active {
    background: var(--brand-50);
    color: var(--brand-700);
}
.sidebar .nav-link.active i { opacity: 1; color: var(--brand); }

.sidebar .user-card {
    margin-top: auto;
    padding: 14px;
    background: linear-gradient(135deg, var(--brand-50), #fff);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: flex; align-items: center; gap: 10px;
}
.sidebar .user-card .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700;
    flex: none;
}
.sidebar .user-card .meta { line-height: 1.15; min-width: 0; }
.sidebar .user-card .meta strong { font-size: 13px; display: block; }
.sidebar .user-card .meta a { font-size: 12px; color: var(--muted); text-decoration: none; }
.sidebar .user-card .meta a:hover { color: var(--brand-700); }

.main { padding: 28px 32px 60px; min-width: 0; }

/* Top page header */
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
    margin-bottom: 22px;
}
.page-head h1 {
    font-size: 24px; font-weight: 700; margin: 0;
    letter-spacing: -.01em;
}
.page-head .subtitle { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ----------- Cards & generic surfaces ----------- */

.card-soft {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-soft .card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
    padding: 16px 20px;
    font-weight: 600;
}

/* ----------- Stat cards ----------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    position: relative;
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat .icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: grid; place-items: center;
    font-size: 18px;
    margin-bottom: 12px;
}
.stat .label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.stat .value {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
    margin-top: 4px;
    letter-spacing: -.02em;
}
.stat .accent {
    position: absolute;
    right: -20px; top: -20px;
    width: 90px; height: 90px;
    border-radius: 50%;
    opacity: .08;
}

.stat.--total   .icon { background: var(--brand-50);   color: var(--brand-700); }
.stat.--total   .accent { background: var(--brand); }
.stat.--pending .icon { background: var(--warning-50); color: #B45309; }
.stat.--pending .accent { background: var(--warning); }
.stat.--sent    .icon { background: var(--success-50); color: #166534; }
.stat.--sent    .accent { background: var(--success); }
.stat.--failed  .icon { background: var(--danger-50);  color: #991B1B; }
.stat.--failed  .accent { background: var(--danger); }
.stat.--skipped .icon { background: #F1F5F9;           color: #475569; }
.stat.--skipped .accent { background: #94A3B8; }

/* Hero strip on dashboard */
.hero {
    background: linear-gradient(135deg, var(--brand) 0%, #FF9F33 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 22px 26px;
    margin-bottom: 22px;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 16px;
    position: relative; overflow: hidden;
    box-shadow: 0 18px 30px -18px rgba(240,130,0,.6);
}
.hero h2 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.hero p { margin: 4px 0 0; opacity: .9; font-size: 14px; }
.hero .hero-decor {
    position: absolute; right: -40px; top: -40px;
    width: 220px; height: 220px;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
}
.hero .hero-decor.b {
    right: 60px; top: 80px; width: 90px; height: 90px;
    background: rgba(255,255,255,.10);
}

/* ----------- Tables ----------- */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.table-wrap .table {
    margin: 0;
}
.table-wrap thead th {
    background: #FBF7F1;
    border-bottom: 1px solid var(--line) !important;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 12px 16px;
    white-space: nowrap;
}
.table-wrap tbody td {
    padding: 14px 16px;
    border-color: var(--line);
    vertical-align: middle;
}
.table-wrap tbody tr:hover { background: #FFFAF1; }
.table-wrap tbody tr:last-child td { border-bottom: 0; }

.order-num {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 600;
    color: var(--ink);
}
.cell-customer .name { font-weight: 600; }
.cell-customer .email { font-size: 12px; color: var(--muted); }
.cell-phone { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; }

/* ----------- Status pills ----------- */

.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: capitalize;
}
.pill::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; opacity: .9;
}
.pill.--pending { background: var(--warning-50); color: #B45309; }
.pill.--sent    { background: var(--success-50); color: #166534; }
.pill.--failed  { background: var(--danger-50);  color: #991B1B; }
.pill.--skipped { background: #F1F5F9;           color: #475569; }

/* ----------- Filter chips ----------- */

.chips {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all .15s ease;
}
.chip:hover { border-color: var(--brand-100); color: var(--brand-700); }
.chip .count {
    background: #F2EEE6; color: var(--ink-2);
    border-radius: 999px; padding: 1px 8px;
    font-size: 11px; font-weight: 700;
}
.chip.active {
    background: var(--ink); color: #fff; border-color: var(--ink);
}
.chip.active .count { background: rgba(255,255,255,.15); color: #fff; }

/* ----------- Buttons ----------- */

.btn { font-weight: 500; border-radius: 10px; }
.btn-brand {
    background: var(--brand); color: #fff; border: 1px solid var(--brand);
}
.btn-brand:hover, .btn-brand:focus {
    background: var(--brand-700); border-color: var(--brand-700); color: #fff;
}
.btn-outline-brand {
    color: var(--brand-700); border: 1px solid var(--brand-100); background: var(--surface);
}
.btn-outline-brand:hover { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }

.btn-icon { display: inline-flex; align-items: center; gap: 6px; }

/* ----------- Forms ----------- */

.form-control, .form-select {
    border-radius: 10px;
    border-color: var(--line-2);
    padding: 9px 12px;
    font-size: 14px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-50);
}
.input-icon {
    position: relative;
}
.input-icon .form-control { padding-left: 38px; }
.input-icon i {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

/* ----------- Empty state ----------- */

.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}
.empty .icon-bubble {
    width: 64px; height: 64px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--brand-50);
    color: var(--brand);
    display: grid; place-items: center;
    font-size: 26px;
}
.empty h5 { color: var(--ink); margin-bottom: 4px; font-weight: 600; }

/* ----------- Login page ----------- */

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    background: var(--bg);
}
.login-art {
    background: radial-gradient(120% 120% at 0% 0%, var(--brand) 0%, #FF9F33 50%, #FFB872 100%);
    color: #fff;
    padding: 56px 56px;
    display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
.login-art::before, .login-art::after {
    content: ""; position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
    pointer-events: none;
}
.login-art::before { width: 460px; height: 460px; right: -180px; top: -160px; }
.login-art::after  { width: 220px; height: 220px; right: 80px; bottom: -80px; background: rgba(255,255,255,.08); }
.login-art .badge-soft {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(255,255,255,.18);
    backdrop-filter: blur(6px);
    padding: 6px 12px; border-radius: 999px;
    font-size: 12px; font-weight: 600; letter-spacing: .04em;
}
.login-art h1 {
    font-size: 36px; font-weight: 700; line-height: 1.15;
    margin-top: 22px; max-width: 460px; letter-spacing: -.02em;
}
.login-art p { max-width: 420px; opacity: .92; margin-top: 12px; font-size: 15px; }
.login-art .features { display: grid; gap: 10px; margin-top: 28px; }
.login-art .feature { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.login-art .feature i {
    background: rgba(255,255,255,.2);
    width: 26px; height: 26px; border-radius: 8px;
    display: grid; place-items: center;
    flex: none;
}
.login-art .footer { font-size: 12px; opacity: .7; position: relative; z-index: 2; }

.login-form-wrap {
    display: grid; place-items: center; padding: 40px;
}
.login-form {
    width: 100%; max-width: 380px;
}
.login-form .logo { height: 32px; margin-bottom: 28px; }
.login-form h3 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.login-form .lead { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

/* =========================================================
   Mobile / tablet
   ========================================================= */

@media (max-width: 900px) {
    /* Single-column shell; the sidebar floats as a drawer */
    .app-shell { grid-template-columns: 1fr; }

    /* --- Mobile top bar --- */
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 14px;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        position: sticky; top: 0; z-index: 40;
    }
    .mobile-topbar .menu-btn {
        background: var(--brand-50);
        color: var(--brand-700);
        border: 0;
        width: 40px; height: 40px;
        border-radius: 10px;
        display: grid; place-items: center;
        font-size: 20px;
        cursor: pointer;
        transition: background .15s ease;
    }
    .mobile-topbar .menu-btn:hover,
    .mobile-topbar .menu-btn:active { background: var(--brand-100); }
    .mobile-topbar .topbar-brand img {
        height: 22px;
        display: block;
    }
    .mobile-topbar .topbar-logout {
        margin-left: auto;
        width: 40px; height: 40px;
        border-radius: 10px;
        background: var(--surface);
        border: 1px solid var(--line);
        color: var(--ink-2);
        display: grid; place-items: center;
        font-size: 16px;
        text-decoration: none;
        transition: all .15s ease;
    }
    .mobile-topbar .topbar-logout:hover {
        background: var(--brand-50);
        color: var(--brand-700);
        border-color: var(--brand-100);
    }

    /* --- Sidebar drawer --- */
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100vh;
        width: 280px;
        max-width: 84vw;
        z-index: 60;
        padding: 22px 16px 18px;
        transform: translateX(-100%);
        transition: transform .26s cubic-bezier(.2,.8,.2,1);
        border-right: 1px solid var(--line);
        background: var(--surface);
        box-shadow: 0 0 0 rgba(0,0,0,0);
    }
    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 24px 0 60px rgba(20,20,20,.18);
    }

    /* Show close button only on mobile */
    .sidebar-close { display: inline-flex; }

    /* Backdrop */
    .sidebar-backdrop { display: block; }
    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }
    body.sidebar-open { overflow: hidden; }

    /* Tighten drawer paddings a little on mobile */
    .sidebar-head { padding-bottom: 16px; margin-bottom: 14px; }
    .sidebar .nav-link { padding: 11px 12px; font-size: 14px; }
    .sidebar .user-card { margin-top: 24px; }

    /* --- Main column --- */
    .main { padding: 18px 16px 56px; }

    /* Page header */
    .page-head { margin-bottom: 16px; }
    .page-head h1 { font-size: 20px; }
    .page-head .subtitle { font-size: 13px; }

    /* Stat cards: 2 per row on phones */
    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-bottom: 18px;
    }
    .stat { padding: 14px; }
    .stat .icon { width: 32px; height: 32px; font-size: 15px; margin-bottom: 8px; border-radius: 8px; }
    .stat .label { font-size: 10.5px; letter-spacing: .06em; }
    .stat .value { font-size: 22px; }
    .stat .accent { width: 70px; height: 70px; right: -16px; top: -16px; }

    /* Hero stacks */
    .hero {
        flex-direction: column;
        align-items: stretch;
        padding: 18px;
        gap: 12px;
    }
    .hero h2 { font-size: 18px; }
    .hero p  { font-size: 13px; }
    .hero .btn { width: 100%; justify-content: center; }
    .hero .hero-decor   { width: 160px; height: 160px; right: -50px; top: -50px; }
    .hero .hero-decor.b { display: none; }

    /* Tables scroll horizontally on small screens so action buttons remain reachable */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-wrap .table { min-width: 720px; }
    .table-wrap thead th { padding: 10px 12px; }
    .table-wrap tbody td { padding: 12px; }

    /* Card header on mobile: stack title + button neatly */
    .card-soft .card-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 14px 16px;
    }

    /* Filter chips + search bar on the orders page stack vertically */
    .main > .d-flex.justify-content-between {
        flex-direction: column;
        align-items: stretch !important;
    }
    .main > .d-flex.justify-content-between > form { min-width: 0 !important; width: 100%; }
    .chips { flex-wrap: wrap; }

    /* Row action buttons compact a bit */
    .row-actions .btn { padding: 5px 8px; font-size: 11.5px; }
    .row-actions .btn i { font-size: 13px; }

    /* Pagination compacter */
    .pagination .page-link { padding: 5px 9px; font-size: 12px; }

    /* Login: stacked, less padding, hide the feature list */
    .login-shell { grid-template-columns: 1fr; min-height: auto; }
    .login-art {
        padding: 28px 24px;
        min-height: auto;
    }
    .login-art::before { width: 280px; height: 280px; right: -120px; top: -120px; }
    .login-art::after  { width: 140px; height: 140px; right: 30px; bottom: -60px; }
    .login-art .badge-soft { font-size: 11px; }
    .login-art h1 { font-size: 22px; margin-top: 14px; }
    .login-art p { font-size: 13.5px; margin-top: 8px; }
    .login-art .features { display: none; }
    .login-art .footer { margin-top: 18px; }

    .login-form-wrap { padding: 28px 22px 36px; }
    .login-form { max-width: 100%; }
    .login-form .logo { height: 28px; margin-bottom: 18px; }
    .login-form h3 { font-size: 20px; }
}

/* Extra-small phones */
@media (max-width: 420px) {
    .main { padding: 14px 12px 48px; }

    .sidebar { padding: 8px 10px; }
    .sidebar .nav-link { padding: 6px 10px; font-size: 12.5px; }

    /* Single-column stat cards on the smallest screens */
    .stat-grid { grid-template-columns: 1fr; }

    .chip { padding: 6px 11px; font-size: 12px; }
    .chip .count { font-size: 10.5px; padding: 1px 6px; }

    .pill { font-size: 11px; padding: 3px 8px; }

    .hero { padding: 16px; }
    .hero h2 { font-size: 17px; }
}

/* Action button group in tables — keep on one row, no wrap */
.row-actions {
    display: inline-flex; gap: 6px; flex-wrap: nowrap;
}
.row-actions .btn { padding: 5px 10px; font-size: 12px; }

/* Pagination — brand colors */
.pagination .page-link {
    color: var(--ink-2);
    border-color: var(--line);
    border-radius: 8px !important;
    margin: 0 2px;
    padding: 6px 12px;
    font-size: 13px;
}
.pagination .page-item.active .page-link {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.pagination .page-link:hover { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }

/* Allow hover stat to feel tactile on dark sidebar — better focus rings */
.btn:focus, .form-control:focus, .form-select:focus {
    outline: none;
}
.btn-brand:focus { box-shadow: 0 0 0 3px var(--brand-50); }
