/* =====================================================================
   rofofi Merchant Portal — /portal
   Shares the admin.css design tokens (colors, radii, fonts) but is a
   self-contained stylesheet so the portal never depends on admin markup.
   ===================================================================== */

:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --title: #0f172a;
    --text: #334155;
    --muted: #94a3b8;
    --border: #eef2f7;
    --border-strong: #e2e8f0;

    --brand: #f97316;
    --brand-dark: #ea580c;
    --brand-soft: #fff7ed;

    --green: #16a34a;
    --green-soft: #dcfce7;
    --blue: #2563eb;
    --blue-soft: #dbeafe;
    --amber: #d97706;
    --amber-soft: #fef3c7;
    --red: #dc2626;
    --red-soft: #fee2e2;
    --slate: #64748b;
    --slate-soft: #f1f5f9;
    --purple: #7e22ce;
    --purple-soft: #f3e8ff;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 10px 30px -14px rgba(15, 23, 42, 0.20);
    --shadow-sm: 0 2px 8px -2px rgba(15, 23, 42, 0.10);
    --font: 'Tajawal', 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.err { color: var(--red); margin-top: 12px; font-size: .86rem; text-align: center; min-height: 1em; }

/* =================== Login =================== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(circle at 50% 0%, #fff7ed, var(--bg)); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px 32px; }
.login-card .logo { text-align: center; font-size: 40px; margin-bottom: 4px; }
.login-card h1 { text-align: center; color: var(--title); font-size: 1.5rem; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: .92rem; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; color: var(--text); margin-bottom: 6px; font-weight: 700; }
.input {
    width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
    background: var(--surface-2); color: var(--title); font-size: 15px; font-family: inherit; transition: border-color .15s, box-shadow .15s; resize: vertical;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input.ltr { direction: ltr; text-align: left; }
.login-foot { display: flex; justify-content: center; gap: 10px; margin-top: 18px; font-size: .84rem; color: var(--muted); }
.login-foot a { color: var(--slate); }

/* =================== Buttons =================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer; transition: background .15s, border-color .15s, opacity .15s; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-block { width: 100%; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover:not(:disabled) { filter: brightness(.93); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover:not(:disabled) { filter: brightness(.93); }

/* =================== App shell =================== */
.app { min-height: 100vh; }
.topbar {
    position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border); padding: 14px 28px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.topbar .brand { display: flex; align-items: center; gap: 8px; }
.topbar .brand .mark { font-size: 24px; }
.topbar .brand-name { font-weight: 800; color: var(--title); font-size: 1.1rem; }
.topbar .spacer { flex: 1; }
.topbar .op { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: .9rem; font-weight: 700; }
.topbar .op .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: flex; align-items: center; justify-content: center; font-weight: 800; }

.content { max-width: 980px; margin: 0 auto; padding: 28px 24px 60px; }

/* =================== Banner =================== */
.banner { border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; font-weight: 700; font-size: .92rem; display: flex; align-items: center; gap: 10px; }
.banner.warn { background: var(--amber-soft); color: #92400e; }
.banner.danger { background: var(--red-soft); color: #991b1b; }
.banner.info { background: var(--blue-soft); color: #1e40af; }
.banner.ok { background: var(--green-soft); color: #166534; }

/* =================== Subscription card =================== */
.sub-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border); overflow: hidden; margin-bottom: 28px; }
.sub-card-head { padding: 24px 26px; display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; background: linear-gradient(135deg, var(--brand-soft), var(--surface)); border-bottom: 1px solid var(--border); }
.eyebrow { font-size: .74rem; color: var(--brand-dark); font-weight: 800; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; }
.plan-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.plan-row h2 { font-size: 1.9rem; color: var(--title); font-weight: 800; }
.plan-price { font-size: 1.05rem; font-weight: 800; color: var(--green); }
.plan-tagline { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.status-block { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.plan-features { columns: 2; gap: 18px; max-width: 360px; }
.plan-features li { list-style: none; font-size: .82rem; color: var(--text); padding: 2px 0; padding-right: 18px; position: relative; }
.plan-features li::before { content: '✓'; position: absolute; right: 0; color: var(--green); font-weight: 800; }

/* Remaining */
.remain { padding: 22px 26px; display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.remain-num { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 120px; }
.remain-days { font-size: 3rem; font-weight: 800; color: var(--title); line-height: 1; }
.remain-days.crit { color: var(--red); }
.remain-days.warn { color: var(--amber); }
.remain-days.expired { color: var(--muted); }
.remain-unit { font-size: .82rem; color: var(--muted); font-weight: 700; margin-top: 4px; }
.remain-bar-wrap { flex: 1; min-width: 220px; }
.remain-bar { height: 12px; background: var(--slate-soft); border-radius: 20px; overflow: hidden; }
.remain-fill { height: 100%; background: linear-gradient(90deg, var(--green), #22c55e); border-radius: 20px; transition: width .4s ease; }
.remain-fill.warn { background: linear-gradient(90deg, var(--amber), #f59e0b); }
.remain-fill.crit { background: linear-gradient(90deg, var(--red), #ef4444); }
.remain-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: .78rem; color: var(--muted); font-weight: 700; }

/* =================== Pending upgrade =================== */
.pending-upgrade { background: var(--amber-soft); color: #92400e; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 28px; font-size: .9rem; font-weight: 700; display: flex; gap: 10px; align-items: center; }

/* =================== Section heads =================== */
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.section-head h3 { font-size: 1.2rem; color: var(--title); font-weight: 800; }
.section-head p { color: var(--muted); font-size: .86rem; flex: 1; }
section { margin-bottom: 30px; }

/* =================== Upgrade grid =================== */
.upgrade-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.upg-card { background: var(--surface); border-radius: var(--radius); border: 2px solid var(--border); padding: 24px; display: flex; flex-direction: column; transition: border-color .15s, transform .15s, box-shadow .15s; position: relative; }
.upg-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.upg-card.featured { border-color: var(--brand); }
.upg-card.featured::after { content: 'الأكثر شيوعاً'; position: absolute; top: -11px; right: 16px; background: var(--brand); color: #fff; font-size: .68rem; font-weight: 800; padding: 3px 10px; border-radius: 20px; }
.upg-card .upg-name { font-size: 1.3rem; font-weight: 800; color: var(--title); }
.upg-card .upg-price { font-size: 1.6rem; font-weight: 800; color: var(--green); margin: 6px 0 2px; }
.upg-card .upg-price small { font-size: .8rem; color: var(--muted); font-weight: 700; }
.upg-card .upg-tag { color: var(--muted); font-size: .82rem; margin-bottom: 12px; }
.upg-card ul { list-style: none; flex: 1; margin-bottom: 16px; }
.upg-card li { font-size: .84rem; color: var(--text); padding: 3px 0; padding-right: 18px; position: relative; }
.upg-card li::before { content: '✓'; position: absolute; right: 0; color: var(--green); font-weight: 800; }
.upg-card .upg-new { display: inline-block; font-size: .68rem; font-weight: 800; color: var(--brand-dark); background: var(--brand-soft); padding: 2px 7px; border-radius: 6px; margin-right: 4px; }

/* =================== Tables =================== */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.table-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tbl th { text-align: right; padding: 12px 16px; color: var(--muted); font-weight: 800; font-size: .76rem; border-bottom: 1px solid var(--border-strong); white-space: nowrap; background: var(--surface-2); }
table.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: .76rem; font-weight: 800; white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-trialing { background: var(--amber-soft); color: var(--amber); }
.b-active { background: var(--green-soft); color: var(--green); }
.b-suspended { background: var(--red-soft); color: var(--red); }
.b-past_due { background: #ffedd5; color: #c2410c; }
.b-approved { background: var(--green-soft); color: var(--green); }
.b-pending { background: var(--amber-soft); color: var(--amber); }
.b-rejected { background: var(--red-soft); color: var(--red); }
.b-basic { background: var(--slate-soft); color: var(--slate); }
.b-pro { background: var(--blue-soft); color: var(--blue); }
.b-enterprise { background: var(--purple-soft); color: var(--purple); }

/* =================== Empty / loading =================== */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; background: var(--surface); border-radius: var(--radius); border: 1px dashed var(--border-strong); }
.empty .em-ic { font-size: 36px; margin-bottom: 8px; opacity: .6; }
.loading { text-align: center; padding: 40px; color: var(--muted); }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border-strong); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =================== Drawer (upgrade) =================== */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s; }
.overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(520px, 100%); background: var(--surface); z-index: 60;
    transform: translateX(-105%); transition: transform .28s cubic-bezier(.4,0,.2,1); display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.drawer.open { transform: none; }
.drawer-head { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 12px; }
.drawer-head .dh-title { font-size: 1.2rem; font-weight: 800; color: var(--title); }
.drawer-head .dh-sub { font-size: .84rem; color: var(--muted); }
.drawer-head .x { background: none; border: none; font-size: 22px; color: var(--muted); cursor: pointer; padding: 4px; line-height: 1; margin-right: auto; }
.drawer-head .x:hover { color: var(--title); }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px 24px; }
.drawer-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

.upgrade-compare { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 18px; }
.uc-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: .9rem; }
.uc-row:last-child { border-bottom: none; }
.uc-row .uc-from { color: var(--muted); }
.uc-row .uc-to { color: var(--green); font-weight: 800; }
.uc-row .uc-amount { font-weight: 800; color: var(--title); }

.pay-notice { background: var(--blue-soft); color: #1e40af; padding: 14px; border-radius: var(--radius-sm); font-size: .84rem; line-height: 1.7; margin-bottom: 18px; }

/* =================== Toast =================== */
.toast-wrap { position: fixed; bottom: 24px; left: 24px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--title); color: #fff; padding: 13px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: .9rem; font-weight: 700; animation: slidein .25s ease; max-width: 360px; }
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }
@keyframes slidein { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* =================== Mobile =================== */
@media (max-width: 720px) {
    .content { padding: 18px 14px 50px; }
    .plan-features { columns: 1; }
    .remain { flex-direction: column; align-items: stretch; }
    .remain-num { flex-direction: row; gap: 12px; justify-content: center; }
    .topbar { padding: 12px 16px; }
    .topbar .op span#p-business { display: none; }
}
