/* Cuby Services — Main Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;900&display=swap');

:root {
  --cuby-primary:   #6C3FC5;
  --cuby-secondary: #9B6DFF;
  --cuby-accent:    #FF6B6B;
  --cuby-dark:      #1a1a2e;
  --cuby-card:      #16213e;
  --cuby-border:    rgba(255,255,255,0.08);
  --sidebar-w:      260px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Tajawal', sans-serif;
  background: #0f0f1a;
  color: #e2e8f0;
  direction: rtl;
  margin: 0;
}

/* ── Login Page ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(16px);
  border: 1px solid var(--cuby-border);
  border-radius: 20px;
  padding: 2.5rem;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo h1 {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--cuby-secondary), var(--cuby-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
}

.login-logo p { color: #94a3b8; font-size: .9rem; margin-top: .25rem; }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; right: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--cuby-card);
  border-left: 1px solid var(--cuby-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid var(--cuby-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand h2 {
  font-size: 1.2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--cuby-secondary), var(--cuby-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
  line-height: 1.2;
}

.sidebar-brand span { font-size: .72rem; color: #64748b; display: block; }

.sidebar-nav { flex: 1; padding: 1rem 0; }

.nav-section {
  padding: .25rem 1.25rem .5rem;
  font-size: .7rem;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.25rem;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 0;
  font-size: .95rem;
  transition: all .18s;
  border-right: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(108, 63, 197, .15);
  color: var(--cuby-secondary);
  border-right-color: var(--cuby-secondary);
}

.sidebar-nav a i { font-size: 1.1rem; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--cuby-border);
  font-size: .85rem;
  color: #475569;
}

/* ── Main Content ── */
.main-content {
  margin-right: var(--sidebar-w);
  min-height: 100vh;
  padding: 2rem;
}

.page-header {
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
}

/* ── Cards ── */
.cuby-card {
  background: var(--cuby-card);
  border: 1px solid var(--cuby-border);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.text-muted { color: #94a3b8 !important; }

.stat-card {
  background: linear-gradient(135deg, var(--cuby-card), rgba(108,63,197,.15));
  border: 1px solid var(--cuby-border);
  border-radius: 16px;
  padding: 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 120px; height: 120px;
  background: var(--cuby-primary);
  border-radius: 50%;
  opacity: .08;
}

.stat-value {
  font-size: 2.25rem;
  font-weight: 900;
  color: #fff;
}

.stat-label { font-size: .85rem; color: #64748b; margin-top: .25rem; }

.stat-change { font-size: .8rem; margin-top: .5rem; }

/* ── Tables ── */
.table-dark-cuby {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--cuby-border);
  --bs-table-color: #e2e8f0;
  --bs-table-hover-bg: rgba(108,63,197,.08);
}

.table-dark-cuby th {
  color: #64748b;
  font-weight: 500;
  font-size: .85rem;
  border-bottom: 1px solid var(--cuby-border) !important;
}

/* ── Forms ── */
.form-control, .form-select {
  background: rgba(255,255,255,0.05) !important;
  border: 1px solid var(--cuby-border) !important;
  color: #e2e8f0 !important;
  border-radius: 10px !important;
}

.form-control:focus, .form-select:focus {
  border-color: var(--cuby-primary) !important;
  box-shadow: 0 0 0 3px rgba(108,63,197,.2) !important;
}

.form-control::placeholder { color: #475569 !important; }

.form-label { color: #94a3b8; font-size: .9rem; }

/* ── Buttons ── */
.btn-cuby {
  background: linear-gradient(135deg, var(--cuby-primary), var(--cuby-secondary));
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: 'Tajawal', sans-serif;
  font-weight: 700;
  padding: .6rem 1.5rem;
  transition: opacity .18s, transform .1s;
}

.btn-cuby:hover { opacity: .9; color: #fff; transform: translateY(-1px); }

/* ── Expiry indicators ── */
.expiry-urgent { color: #ef4444; }
.expiry-warn   { color: #f59e0b; }
.expiry-ok     { color: #22c55e; }

/* ── Insight chart area ── */
.chart-wrap {
  position: relative;
  height: 220px;
}

/* ── Portal specific ── */
.portal-hero {
  background: linear-gradient(135deg, var(--cuby-primary), #0f3460);
  border-radius: 20px;
  padding: 2rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.portal-hero img {
  width: 70px; height: 70px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,.3);
}

.portal-hero h2 { margin: 0; font-weight: 700; }
.portal-hero p  { margin: 0; color: rgba(255,255,255,.7); font-size: .9rem; }

.service-pill {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--cuby-border);
  border-radius: 50px;
  padding: .35rem .9rem;
  font-size: .85rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-right: 0; padding: 1rem; }
}

/* ── Bootstrap overrides for dark theme ── */
.badge { font-family: 'Tajawal', sans-serif; }
.alert { border-radius: 12px; }
.modal-content {
  background: var(--cuby-card);
  border: 1px solid var(--cuby-border);
  border-radius: 16px;
}
.modal-header { border-bottom: 1px solid var(--cuby-border); }
.modal-footer { border-top: 1px solid var(--cuby-border); }
select option { background: var(--cuby-card); }

/* ── Logo ── */
.logo-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow:
    0 0 0 1px rgba(155, 109, 255, 0.2),
    0 4px 24px rgba(108, 63, 197, 0.3),
    0 1px 4px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  margin-bottom: .9rem;
  width: 76px;
  height: 76px;
  overflow: hidden;
}

.logo-pill img {
  width: 56px;
  height: 56px;
  max-width: 56px;
  max-height: 56px;
  object-fit: contain;
  display: block;
}

/* Sidebar logo chip */
.sidebar-logo-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 5px;
  box-shadow:
    0 0 0 1px rgba(155, 109, 255, 0.2),
    0 2px 10px rgba(108, 63, 197, 0.25);
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  overflow: hidden;
}

.sidebar-logo-chip img {
  width: 32px;
  height: 32px;
  max-width: 32px;
  max-height: 32px;
  object-fit: contain;
  display: block;
}

/* ── Report Generator ── */
.report-form-section {
  background: var(--cuby-card);
  border: 1px solid var(--cuby-border);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.report-section-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #64748b;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--cuby-border);
}
.report-section-title.shopify { color: #22c55e; border-color: rgba(34,197,94,.2); }
.report-section-title.social  { color: #9B6DFF; border-color: rgba(155,109,255,.2); }

/* ── A4 Report Preview ── */
.a4-wrap {
  display: flex;
  justify-content: center;
  padding: 2rem 0;
}

.a4-page {
  width: 794px;
  min-height: 1123px;
  background: #ffffff;
  color: #1e293b;
  font-family: 'Inter', 'Roboto', Arial, sans-serif;
  font-size: 13px;
  padding: 40px 48px;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
  border-radius: 4px;
  position: relative;
  direction: rtl;
}

/* Report typography */
.rpt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid #1e3a5f;
  padding-bottom: 18px;
  margin-bottom: 22px;
}
.rpt-logo-area { display: flex; align-items: center; gap: 12px; }
.rpt-logo-area img { width: 52px; height: 52px; object-fit: contain; }
.rpt-brand { font-size: 20px; font-weight: 800; color: #1e3a5f; letter-spacing: -.3px; }
.rpt-brand small { display: block; font-size: 11px; font-weight: 400; color: #64748b; }
.rpt-meta { text-align: left; }
.rpt-period { font-size: 16px; font-weight: 700; color: #1e3a5f; }
.rpt-client { font-size: 12px; color: #64748b; margin-top: 2px; }

.rpt-summary {
  background: #f1f5f9;
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 22px;
}
.rpt-summary-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #475569;
  margin-bottom: 12px;
}
.rpt-summary-item {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  align-items: flex-start;
  line-height: 1.5;
}
.rpt-summary-item:last-child { margin-bottom: 0; }
.rpt-bullet {
  min-width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.rpt-bullet-1 { background: #1e3a5f; }
.rpt-bullet-2 { background: #7c3aed; }
.rpt-bullet-3 { background: #0f766e; }
.rpt-summary-text { color: #334155; font-size: 12px; }

.rpt-data-row {
  display: grid;
  gap: 16px;
  margin-bottom: 22px;
}
.rpt-data-row.two-col { grid-template-columns: 1fr 1fr; }
.rpt-data-row.one-col { grid-template-columns: 1fr; }

.rpt-data-block {
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}
.rpt-data-block-header {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rpt-data-block-header.shopify {
  background: #f0fdf4; color: #15803d;
  border-bottom: 1px solid #bbf7d0;
}
.rpt-data-block-header.social {
  background: #f5f3ff; color: #6d28d9;
  border-bottom: 1px solid #ddd6fe;
}
.rpt-table {
  width: 100%;
  border-collapse: collapse;
}
.rpt-table td {
  padding: 7px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
  color: #334155;
}
.rpt-table td:last-child {
  text-align: left;
  font-weight: 700;
  color: #1e293b;
}
.rpt-table tr:last-child td { border-bottom: none; }

.rpt-footer {
  position: absolute;
  bottom: 28px;
  left: 48px; right: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #e2e8f0;
  padding-top: 12px;
  font-size: 10px;
  color: #94a3b8;
}

/* ── Print ── */
@media print {
  @page { size: A4; margin: 0; }

  body * { visibility: hidden !important; }
  .a4-page,
  .a4-page * { visibility: visible !important; }

  .a4-wrap {
    display: block;
    padding: 0;
    margin: 0;
  }
  .a4-page {
    position: fixed;
    top: 0; left: 0;
    width: 210mm;
    min-height: 297mm;
    box-shadow: none;
    border-radius: 0;
    padding: 20mm 22mm;
    font-size: 12pt;
  }
  .print-hide { display: none !important; }
}
