/* ─── Fonts ────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Variables ────────────────────────────────────────── */
:root {
  --bg-deep:      #0a0c10;
  --bg-panel:     #12151c;
  --bg-card:      #181c26;
  --bg-card-hover:#1e2330;
  --bg-input:     #1a1e28;
  --border:       #252a36;
  --border-focus: #d4a853;
  --text-primary: #e8e6e1;
  --text-secondary:#8d8e96;
  --text-muted:   #5c5e66;
  --accent:       #d4a853;
  --accent-glow:  rgba(212,168,83,.15);
  --accent-bright:#f0c96e;
  --success:      #4ade80;
  --success-bg:   rgba(74,222,128,.08);
  --danger:       #f87171;
  --danger-bg:    rgba(248,113,113,.08);
  --warning:      #fbbf24;
  --info:         #60a5fa;
  --info-bg:      rgba(96,165,250,.08);
  --radius:       12px;
  --radius-sm:    8px;
  --radius-xs:    6px;
  --shadow-card:  0 2px 12px rgba(0,0,0,.35);
  --shadow-float: 0 8px 40px rgba(0,0,0,.5);
  --transition:   .25s cubic-bezier(.4,0,.2,1);
  --font:         'DM Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', monospace;
}

/* ─── Reset ────────────────────────────────────────────── */
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ─── Background texture ───────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(212,168,83,.04) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(96,165,250,.03) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ─── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Loading Screen ───────────────────────────────────── */
#loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity .5s ease, visibility .5s ease;
}
#loading-screen.hidden { opacity: 0; visibility: hidden; }
.loader-ring {
  width: 44px; height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Screens ──────────────────────────────────────────── */
.screen {
  display: none;
  position: relative;
  z-index: 1;
}
.screen.active {
  display: block;
  animation: fadeUp .45s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── LOGIN ────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px 40px;
  box-shadow: var(--shadow-float);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright), var(--accent));
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo .icon {
  width: 52px; height: 52px;
  background: var(--accent-glow);
  border: 1px solid rgba(212,168,83,.2);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.login-logo .icon svg { color: var(--accent); }
.login-logo h1 {
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--text-primary);
}
.login-logo p {
  color: var(--text-secondary);
  font-size: .88rem;
  margin-top: 6px;
}

.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 7px;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.form-group input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font);
  font-size: .95rem;
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-group input::placeholder { color: var(--text-muted); }
.form-group input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: .92rem;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  text-decoration: none;
  line-height: 1;
}
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #c49a40);
  color: #0a0c10;
  padding: 14px 24px;
  font-size: .95rem;
  letter-spacing: .01em;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.btn-save {
  background: linear-gradient(135deg, var(--accent), #c49a40);
  color: #0a0c10;
  padding: 11px 28px;
}
.btn-save:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-save:disabled { opacity: .5; cursor: not-allowed; transform: none; filter: none; }

.btn-select-all, .btn-deselect-all {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 16px;
  font-size: .8rem;
}
.btn-select-all:hover {
  background: rgba(var(--accent-rgb, 212,175,55), .15);
  border-color: var(--accent);
  color: var(--accent);
}
.btn-deselect-all:hover {
  background: rgba(255,90,90,.1);
  border-color: #e55;
  color: #e55;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 9px 18px;
  font-size: .82rem;
}
.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.login-error {
  background: var(--danger-bg);
  border: 1px solid rgba(248,113,113,.2);
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: .85rem;
  color: var(--danger);
  display: none;
  animation: fadeUp .3s ease;
}
.login-error.show { display: block; }

/* ─── DASHBOARD ────────────────────────────────────────── */
.dashboard {
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-brand .brand-icon {
  width: 38px; height: 38px;
  background: var(--accent-glow);
  border: 1px solid rgba(212,168,83,.18);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topbar-brand .brand-icon svg { color: var(--accent); width: 20px; height: 20px; }
.topbar-brand h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -.01em;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-user {
  font-size: .85rem;
  color: var(--text-secondary);
}
.topbar-user strong {
  color: var(--accent);
  font-weight: 500;
}

/* Status badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 4px 10px;
  border-radius: 20px;
}
.badge-active   { background: var(--success-bg); color: var(--success); border: 1px solid rgba(74,222,128,.15); }
.badge-expired  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(248,113,113,.15); }
.badge-banned   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(248,113,113,.15); }
.badge-disabled { background: rgba(255,255,255,.04); color: var(--text-muted); border: 1px solid var(--border); }
.badge-trial    { background: var(--info-bg);     color: var(--info);    border: 1px solid rgba(96,165,250,.15); }

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  border-color: rgba(212,168,83,.15);
  background: var(--bg-card-hover);
}
.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.stat-card-label {
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 500;
}
.stat-card-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-card-icon svg { width: 17px; height: 17px; }
.stat-card-icon.amber  { background: var(--accent-glow); color: var(--accent); }
.stat-card-icon.green  { background: var(--success-bg);  color: var(--success); }
.stat-card-icon.red    { background: var(--danger-bg);   color: var(--danger); }
.stat-card-icon.blue   { background: var(--info-bg);     color: var(--info); }

.stat-card-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-card-sub {
  font-size: .78rem;
  color: var(--text-muted);
}

/* Section */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.section-title h3 {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title h3 svg { color: var(--accent); width: 20px; height: 20px; }

/* Bouquet Grid */
.bouquets-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.bouquets-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.bouquets-count {
  font-size: .82rem;
  color: var(--text-muted);
}

/* Bouquets Search */
.bouquets-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 0 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.bouquets-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.bouquets-search svg {
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: .6;
}
.bouquets-search:focus-within svg {
  color: var(--primary);
  opacity: 1;
}
.bouquets-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: .88rem;
  padding: 11px 0;
  font-family: inherit;
}
.bouquets-search input::placeholder {
  color: var(--text-muted);
  opacity: .6;
}
.search-count {
  font-size: .75rem;
  color: var(--text-muted);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .2s ease;
}
.search-count.visible {
  opacity: 1;
}

/* Totals Bar */
.bouquets-totals {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding: 12px 16px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.total-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,.03);
  border-radius: 8px;
  transition: all .25s ease;
}
.total-item svg {
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: .7;
}
.total-item span {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
}
.total-item label {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 500;
}
.total-item.total-all {
  background: rgba(99,102,241,.1);
  border: 1px solid rgba(99,102,241,.2);
}
.total-item.total-all svg {
  color: var(--primary);
  opacity: 1;
}
.total-item.total-all span {
  color: var(--accent-bright);
}
.total-item.total-all label {
  color: var(--accent);
}

.bouquets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 18px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.bouquet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.bouquet-item:hover {
  background: var(--bg-panel);
  border-color: var(--text-muted);
}
.bouquet-item.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.bouquet-item.selected .bouquet-check {
  background: var(--accent);
  border-color: var(--accent);
}
.bouquet-item.selected .bouquet-check svg { opacity: 1; }

.bouquet-check {
  width: 22px; height: 22px;
  min-width: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.bouquet-check svg {
  width: 13px; height: 13px;
  color: var(--bg-deep);
  opacity: 0;
  transition: opacity var(--transition);
}

.bouquet-name {
  font-size: .88rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bouquet-id {
  font-size: .72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-size: .88rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-float);
  z-index: 5000;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(100px);
  opacity: 0;
  transition: all .35s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }

/* Refresh indicator */
.refreshing .stat-card-value,
.refreshing .bouquet-name {
  opacity: .4;
  transition: opacity .2s;
}

/* Account info row */
.info-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px 28px;
}
.info-item label {
  display: block;
  font-size: .72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 500;
  margin-bottom: 4px;
}
.info-item span {
  font-size: .92rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.info-item span.highlight {
  color: var(--accent);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 12px; opacity: .3; }
.empty-state p { font-size: .9rem; }

/* ─── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .dashboard { padding: 16px 14px 40px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .login-card { padding: 36px 24px 28px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .bouquets-grid { grid-template-columns: 1fr; }
  .info-panel { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card-value { font-size: 1.3rem; }
  .bouquets-totals { flex-wrap: wrap; }
  .total-item { flex: 1 1 40%; min-width: 0; }
}

@media (max-width: 480px) {
  html { font-size: 14px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .info-panel { grid-template-columns: 1fr 1fr; }
  .bouquets-actions { flex-direction: column; align-items: flex-start; }
  .bouquets-totals { gap: 6px; padding: 10px 12px; }
  .total-item { padding: 6px 10px; }
  .total-item span { font-size: 1rem; }
  .total-item label { font-size: .68rem; }
}

/* ─── Animations ───────────────────────────────────────── */
.stagger-1 { animation-delay: .05s; }
.stagger-2 { animation-delay: .10s; }
.stagger-3 { animation-delay: .15s; }
.stagger-4 { animation-delay: .20s; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-in {
  animation: slideIn .4s ease both;
}

/* ─── Language Toggle ──────────────────────────────────── */
.lang-toggle {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,.08);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid rgba(255,255,255,.06);
}
.login-card .lang-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0,0,0,.15);
  border-color: rgba(255,255,255,.08);
}
.lang-btn {
  background: transparent;
  color: rgba(255,255,255,.5);
  border: none;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
  letter-spacing: .02em;
}
.lang-btn:hover {
  color: rgba(255,255,255,.8);
  background: rgba(255,255,255,.08);
}
.lang-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,.35);
}

/* ─── RTL Support ──────────────────────────────────────── */
[dir="rtl"] {
  font-family: 'Segoe UI', Tahoma, 'Cairo', 'Noto Sans Arabic', Arial, sans-serif;
}
[dir="rtl"] .login-card .lang-toggle {
  right: auto;
  left: 16px;
}
[dir="rtl"] .topbar {
  flex-direction: row-reverse;
}
[dir="rtl"] .topbar-brand {
  flex-direction: row-reverse;
}
[dir="rtl"] .topbar-right {
  flex-direction: row-reverse;
}
[dir="rtl"] .topbar-user {
  flex-direction: row-reverse;
}
[dir="rtl"] .bouquet-item {
  direction: ltr;
  text-align: left;
}
[dir="rtl"] .bouquets-panel {
  direction: ltr;
}
[dir="rtl"] .bouquets-panel .section-title {
  direction: ltr;
  flex-direction: row;
}
[dir="rtl"] .bouquets-panel .section-title h3 {
  flex-direction: row;
}
[dir="rtl"] .bouquets-panel .bouquets-actions {
  flex-direction: row;
}
[dir="rtl"] .bouquets-panel .bouquets-count {
  direction: ltr;
}
[dir="rtl"] .bouquets-panel .bouquets-search {
  direction: ltr;
}
[dir="rtl"] .bouquets-panel .bouquets-search input {
  direction: ltr;
  text-align: left;
}
[dir="rtl"] .info-item {
  text-align: right;
}
[dir="rtl"] .section-title h3 {
  flex-direction: row-reverse;
}
[dir="rtl"] .stat-card-header {
  flex-direction: row-reverse;
}
[dir="rtl"] .stat-card {
  text-align: right;
}
[dir="rtl"] .btn svg {
  margin-left: 6px;
  margin-right: 0;
}
[dir="rtl"] .badge-dot {
  margin-left: 6px;
  margin-right: 0;
}
[dir="rtl"] .login-error {
  text-align: right;
}
[dir="rtl"] .form-group {
  text-align: right;
}
[dir="rtl"] input[type="text"],
[dir="rtl"] input[type="password"] {
  text-align: right;
  direction: rtl;
}
[dir="rtl"] .empty-state {
  direction: rtl;
}
[dir="rtl"] .toast {
  direction: rtl;
}
