/* ===================================================================
   Ros Smart Developers — Admin
   Shared shell, components and layout for every page under /admin.
   =================================================================== */

:root {
    --orange: #FF5C00;
    --orange-dark: #e65200;
    --orange-soft: #fff1e8;
    --navy: #0D1530;
    --navy-soft: #1b2749;
    --line: #e6e8ee;
    --muted: #6b7280;
    --bg: #f4f5f7;
    --white: #fff;
    --green: #15803d;
    --green-bg: #dcfce7;
    --red: #b91c1c;
    --red-bg: #fee2e2;
    --amber: #b45309;
    --amber-bg: #fef3c7;
    --blue: #1d4ed8;
    --blue-bg: #dbeafe;
    --sidebar: 240px;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(13, 21, 48, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--navy);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.sub { font-size: 12.5px; color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------- app shell */

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar);
    background: linear-gradient(180deg, #131e42 0%, var(--navy) 55%, #0a1027 100%);
    color: rgba(255, 255, 255, .72);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    transition: transform .22s ease;
    border-right: 1px solid rgba(255, 255, 255, .07);
}

/* The logo is dark navy artwork, so it needs a light plate to read against
   the dark sidebar. */
.sidebar-brand { padding: 18px 16px 16px; }
.brand-mark {
    display: flex; align-items: center; justify-content: center;
    background: #fff; border-radius: 14px; padding: 14px 16px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
    transition: transform .15s ease, box-shadow .15s ease;
}
.brand-mark:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(0, 0, 0, .38); }
.brand-mark img { width: 100%; max-height: 54px; object-fit: contain; display: block; }
.brand-caption {
    text-align: center; margin-top: 11px;
    font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
    color: rgba(255, 255, 255, .45);
}

.nav-label {
    font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
    color: rgba(255, 255, 255, .32); padding: 4px 12px 8px;
}

.sidebar-nav { padding: 10px 12px; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.sidebar-nav a {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    padding: 11px 13px; border-radius: 10px;
    font-weight: 600; font-size: 14px; color: rgba(255, 255, 255, .74);
    transition: background .15s, color .15s;
}
.sidebar-nav a i { width: 18px; text-align: center; font-size: 14px; opacity: .85; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar-nav a:hover i { opacity: 1; }
.sidebar-nav a.active {
    background: linear-gradient(90deg, var(--orange), #ff7a29);
    color: #fff;
    box-shadow: 0 6px 16px rgba(255, 92, 0, .32);
}
.sidebar-nav a.active i { opacity: 1; }
.sidebar-nav a .count {
    margin-left: auto; background: rgba(255, 255, 255, .16);
    border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; color: #fff;
}
.sidebar-nav a.active .count { background: rgba(0, 0, 0, .22); }
.sidebar-nav a .count.alert { background: #dc2626; color: #fff; }

.sidebar-foot {
    padding: 14px 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, .09);
}
.sidebar-foot a {
    display: flex; align-items: center; gap: 11px;
    color: rgba(255, 255, 255, .6); font-size: 13px; font-weight: 500;
    padding: 8px 13px; border-radius: 9px;
}
.sidebar-foot a i { width: 18px; text-align: center; }
.sidebar-foot a i.tiny { margin-left: auto; font-size: 10px; opacity: .55; width: auto; }
.sidebar-foot a:hover { color: #fff; background: rgba(255, 255, 255, .07); }

.main { flex: 1; margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    padding: 0 26px;
    height: 62px;
    display: flex; align-items: center; gap: 16px;
    position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 17px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar-user { position: relative; }
.menu-toggle { display: none; }

/* Account menu — our own, in place of Clerk's mounted button */
.user-btn {
    display: flex; align-items: center; gap: 9px;
    background: none; color: var(--navy); padding: 5px 10px 5px 5px;
    border-radius: 999px; font-weight: 600;
}
.user-btn:hover { background: #f2f3f6; }
.user-btn .uname { font-size: 13.5px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .user-btn .uname { display: none; } }

.avatar {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--orange); color: #fff;
    font-size: 12px; font-weight: 700; letter-spacing: .02em;
    object-fit: cover;
}
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }

.user-menu {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 70;
    min-width: 250px; background: #fff;
    border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 12px 34px rgba(13, 21, 48, .16);
    padding: 6px; display: none;
}
.user-menu.open { display: block; }
.user-menu-head {
    display: flex; gap: 11px; align-items: center;
    padding: 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px;
}
.user-menu-head strong { display: block; font-size: 13.5px; }
.user-menu button {
    width: 100%; justify-content: flex-start; gap: 10px;
    background: none; color: var(--navy); font-weight: 600; padding: 10px 12px; border-radius: 8px;
}
.user-menu button:hover { background: #f2f3f6; }
.user-menu button i { width: 16px; color: var(--muted); }

.content { padding: 26px; flex: 1; max-width: 1440px; width: 100%; }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: 4px 0 24px rgba(0,0,0,.2); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .content { padding: 18px 14px; }
    .topbar { padding: 0 14px; }
}

/* ------------------------------------------------------------ buttons */

button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 16px; border: none; border-radius: 9px;
    background: var(--orange); color: #fff;
    font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: .15s;
}
button:hover, .btn:hover { background: var(--orange-dark); }
button.ghost, .btn.ghost { background: #eef0f4; color: var(--navy); }
button.ghost:hover, .btn.ghost:hover { background: #e2e5ea; }
button.outline, .btn.outline { background: transparent; border: 1px solid var(--line); color: var(--navy); }
button.outline:hover { background: #f7f8fa; }
button.danger, .btn.danger { background: var(--red-bg); color: var(--red); }
button.danger:hover { background: #fecaca; }
button.sm, .btn.sm { padding: 6px 12px; font-size: 13px; }
button.icon { padding: 7px 10px; background: none; color: var(--muted); }
button.icon:hover { background: #f2f3f6; color: var(--navy); }
button:disabled { opacity: .45; cursor: not-allowed; }

/* ------------------------------------------------------------- inputs */

input, select, textarea {
    width: 100%; padding: 9px 12px;
    border: 1px solid #d7dae0; border-radius: 9px;
    font: inherit; background: var(--white); color: var(--navy);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--orange); outline-offset: -1px; }
label.field { display: block; }
label.field > span {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--muted); margin-bottom: 5px;
}

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

.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-head {
    padding: 16px 18px; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-head h2 { font-size: 15px; font-weight: 700; }
.card-body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-main { grid-template-columns: 1.6fr 1fr; align-items: start; }
@media (max-width: 1000px) { .grid-main, .grid-2 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- KPI */

.kpi {
    background: var(--white); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 2px;
}
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi .kpi-icon {
    width: 32px; height: 32px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    background: var(--orange-soft); color: var(--orange); font-size: 14px;
}
.kpi .kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 8px; }
.kpi .kpi-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.kpi .kpi-foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.kpi.alert { border-color: #fca5a5; background: #fff6f6; }
.kpi.alert .kpi-value { color: #dc2626; }
.kpi.alert .kpi-icon { background: var(--red-bg); color: var(--red); }
.kpi.good .kpi-icon { background: var(--green-bg); color: var(--green); }

/* -------------------------------------------------------------- table */

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid #f0f1f4; vertical-align: top; }
th {
    font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); background: #fafbfc; font-weight: 700;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
tbody tr.clickable { cursor: pointer; }
tbody tr.selected { background: var(--orange-soft); }

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

.pill {
    display: inline-block; padding: 3px 9px; border-radius: 999px;
    font-size: 11px; font-weight: 700; text-transform: capitalize; white-space: nowrap;
}
.pill.paid, .pill.confirmed, .pill.published, .pill.sent { background: var(--green-bg); color: var(--green); }
.pill.pending, .pill.no_show, .pill.ongoing { background: var(--amber-bg); color: var(--amber); }
.pill.failed, .pill.cancelled, .pill.abandoned, .pill.unsent, .pill.draft { background: var(--red-bg); color: var(--red); }
.pill.new { background: var(--blue-bg); color: var(--blue); }
.pill.completed { background: #e5e7eb; color: #374151; }
.pill.emailed { background: #e0e7ff; color: #4338ca; }

.ref { font-family: ui-monospace, 'Courier New', monospace; font-size: 11px; }

/* ------------------------------------------------------------ notices */

.msg { padding: 12px 15px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.msg.error { background: var(--red-bg); color: var(--red); }
.msg.ok { background: var(--green-bg); color: var(--green); }
.msg.warn { background: var(--amber-bg); color: var(--amber); }

.banner {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; border-radius: var(--radius); margin-bottom: 18px;
    background: #fff6f6; border: 1px solid #fca5a5; color: var(--red);
}
.banner i { font-size: 18px; }
.banner .grow { flex: 1; }

.empty { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty i { font-size: 28px; opacity: .35; display: block; margin-bottom: 10px; }
.footer-bar { padding: 14px; text-align: center; border-top: 1px solid #f0f1f4; }

/* -------------------------------------------------------------- lists */

.list-item {
    display: flex; align-items: center; gap: 14px;
    padding: 13px 18px; border-bottom: 1px solid #f0f1f4;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: #fafbfc; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item strong { display: block; font-size: 14px; }
.date-chip {
    width: 48px; flex-shrink: 0; text-align: center;
    background: var(--orange-soft); color: var(--orange);
    border-radius: 9px; padding: 6px 0; font-weight: 800; line-height: 1.1;
}
.date-chip span { display: block; font-size: 10px; text-transform: uppercase; font-weight: 700; }

/* -------------------------------------------------------------- chart */

.chart { width: 100%; height: 190px; display: block; }
.chart .bar { fill: var(--orange); opacity: .85; transition: opacity .15s; }
.chart .bar:hover { opacity: 1; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-label { font-size: 10px; fill: var(--muted); }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.chart-legend span::before {
    content: ''; display: inline-block; width: 9px; height: 9px;
    border-radius: 2px; background: var(--orange); margin-right: 6px;
}

/* ------------------------------------------------------- drawer/modal */

.scrim { position: fixed; inset: 0; background: rgba(13, 21, 48, .45); z-index: 90; display: none; }
.scrim.open { display: block; }

.drawer {
    position: fixed; top: 0; right: 0; height: 100%;
    width: 470px; max-width: 100%; background: var(--white);
    z-index: 100; box-shadow: -6px 0 30px rgba(0, 0, 0, .14);
    transform: translateX(100%); transition: transform .22s ease;
    display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
    padding: 18px 20px; border-bottom: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.drawer-head h3 { font-size: 17px; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }

.modal {
    position: fixed; inset: 0; z-index: 100; display: none;
    align-items: flex-start; justify-content: center;
    padding: 36px 16px; overflow-y: auto; background: rgba(13, 21, 48, .45);
}
.modal.open { display: flex; }
.modal-card {
    background: var(--white); border-radius: 14px;
    width: 100%; max-width: 730px; box-shadow: 0 24px 70px rgba(0, 0, 0, .25);
}
.modal-head {
    padding: 18px 22px; border-bottom: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 22px; }
.modal-foot {
    padding: 16px 22px; border-top: 1px solid var(--line);
    display: flex; justify-content: space-between; gap: 10px; align-items: center;
}

.section { margin-bottom: 22px; }
.section > h4 {
    font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); margin-bottom: 10px; padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
}
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 5px 0; }
.kv dt { color: var(--muted); flex-shrink: 0; }
.kv dd { text-align: right; word-break: break-word; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 11px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.history { font-size: 12px; color: var(--muted); list-style: none; }
.history li { padding: 4px 0; }

/* ----------------------------------------------------------- toolbars */

.toolbar {
    background: var(--white); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 14px 16px; margin-bottom: 16px;
    display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; gap: 10px; align-items: end;
}
@media (max-width: 1000px) { .toolbar { grid-template-columns: 1fr 1fr; } }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; overflow-x: auto; }
.tab {
    padding: 8px 14px; border-radius: 9px; border: none; background: none;
    font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tab:hover { background: #eaecf0; }
.tab.active { background: var(--orange-soft); color: var(--orange); }
.tab .badge {
    display: inline-block; background: #dc2626; color: #fff;
    border-radius: 999px; font-size: 11px; padding: 1px 6px; margin-left: 5px;
}

/* ----------------------------------------------------------- projects */

.proj-row { display: flex; gap: 15px; padding: 14px 18px; border-bottom: 1px solid #f0f1f4; align-items: center; }
.proj-row:last-child { border-bottom: none; }
.proj-row:hover { background: #fafbfc; }
.proj-row .grow { flex: 1; min-width: 0; }
.proj-row h3 { font-size: 14.5px; margin-bottom: 2px; }
.thumb {
    width: 96px; height: 70px; border-radius: 9px; overflow: hidden;
    background: #eef0f4; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.order-btns { display: flex; flex-direction: column; gap: 3px; }
.order-btns button { padding: 2px 8px; font-size: 11px; background: #eef0f4; color: var(--navy); }
.order-btns button:hover { background: #dde0e6; }

.dropzone {
    border: 2px dashed #d7dae0; border-radius: var(--radius);
    padding: 26px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--orange); background: #fff8f4; color: var(--orange); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; margin-top: 12px; }
.media-item { position: relative; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: #eef0f4; }
.media-item.cover { border-color: var(--orange); }
.media-item img, .media-item video { width: 100%; height: 84px; object-fit: cover; display: block; }
.media-tools { display: flex; justify-content: center; gap: 2px; padding: 4px; background: var(--white); }
.media-tools button { padding: 3px 7px; font-size: 11px; background: #eef0f4; color: var(--navy); }
.media-tools button.on { background: var(--orange); color: #fff; }
.cover-tag {
    position: absolute; top: 4px; left: 4px; background: var(--orange); color: #fff;
    font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
}
.vid-tag {
    position: absolute; top: 4px; right: 4px; background: rgba(13, 21, 48, .75); color: #fff;
    font-size: 10px; padding: 2px 6px; border-radius: 4px;
}

/* ------------------------------------------------------------ sign in */

.signin-screen {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background: var(--bg);
    background-image:
        radial-gradient(circle at 12% 18%, rgba(255, 92, 0, .09), transparent 42%),
        radial-gradient(circle at 88% 88%, rgba(13, 21, 48, .07), transparent 45%);
}
.signin-screen .msg { width: 100%; }

/* ------------------------------------------------------------- status */

.status-row {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 18px; border-bottom: 1px solid #f0f1f4;
}
.status-row:last-child { border-bottom: none; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.status-dot.on { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }
.status-dot.off { background: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .18); }
.status-dot.warn { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
