/* COD Calculator Pro - Styles */
:root {
    --bg: #050506; --bg-card: #0c0c0e; --bg-card-alt: #111114; --bg-input: #0a0a0c;
    --border: #1e1e23; --border-light: #2a2a32; --text: #f4f4f5; --text-secondary: #a1a1aa; --text-muted: #63637a;
    --accent: #10b981; --accent-light: #34d399; --accent-dim: rgba(16, 185, 129, 0.12);
    --purple: #8b5cf6; --purple-dim: rgba(139, 92, 246, 0.12);
    --blue: #3b82f6; --blue-dim: rgba(59, 130, 246, 0.12);
    --orange: #f59e0b; --orange-dim: rgba(245, 158, 11, 0.12);
    --danger: #ef4444; --danger-dim: rgba(239, 68, 68, 0.12);
    --radius: 16px; --radius-sm: 10px;
}
[data-theme="light"] {
    --bg: #f5f5f7; --bg-card: #ffffff; --bg-card-alt: #f9fafb; --bg-input: #f3f4f6;
    --border: #e5e7eb; --border-light: #d1d5db; --text: #111827; --text-secondary: #4b5563; --text-muted: #6b7280;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.5; }
[data-lang="ar"] { direction: rtl; }
[data-lang="ar"] body, [data-lang="ar"] input, [data-lang="ar"] select, [data-lang="ar"] button { font-family: 'Tajawal', sans-serif; }

.bg-gradient { position: fixed; top: 0; left: 0; right: 0; height: 600px; background: radial-gradient(ellipse at 50% 0%, rgba(16, 185, 129, 0.08) 0%, transparent 60%); pointer-events: none; z-index: 0; }

/* Auth */
.auth-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(8px); z-index: 1000; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: all 0.3s; }
.auth-overlay.active { opacity: 1; visibility: visible; }
.auth-modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 420px; padding: 40px; }
.auth-header { text-align: center; margin-bottom: 32px; }
.auth-logo { width: 56px; height: 56px; background: linear-gradient(135deg, var(--accent), #059669); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; color: #fff; margin: 0 auto 16px; }
.auth-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.auth-subtitle { color: var(--text-muted); font-size: 14px; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg-input); padding: 4px; border-radius: 50px; margin-bottom: 24px; }
.auth-tab { flex: 1; padding: 12px; border: none; background: transparent; color: var(--text-muted); font-family: inherit; font-size: 14px; font-weight: 500; cursor: pointer; border-radius: 50px; transition: all 0.2s; }
.auth-tab.active { background: var(--accent); color: #000; }
.auth-form { display: none; flex-direction: column; gap: 16px; }
.auth-form.active { display: flex; }
.auth-input-group { display: flex; flex-direction: column; gap: 6px; }
.auth-input-group label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.auth-input { padding: 14px 16px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: inherit; font-size: 14px; }
.auth-input:focus { outline: none; border-color: var(--accent); }
.auth-btn { padding: 14px 24px; background: var(--accent); border: none; border-radius: var(--radius-sm); color: #000; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.auth-btn:hover { background: var(--accent-light); }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-error { background: var(--danger-dim); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--danger); padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; display: none; }
.auth-error.show { display: block; }

/* Navbar */
.navbar { position: fixed; top: 0; left: 0; right: 0; height: 64px; background: rgba(12, 12, 14, 0.9); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); z-index: 100; display: flex; align-items: center; padding: 0 24px; }
[data-theme="light"] .navbar { background: rgba(255, 255, 255, 0.9); }
.nav-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.nav-logo { width: 36px; height: 36px; background: linear-gradient(135deg, var(--accent), #059669); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; color: #fff; }
.nav-title { font-size: 16px; font-weight: 600; }
.nav-links { display: flex; gap: 4px; margin-left: 40px; }
[data-lang="ar"] .nav-links { margin-left: 0; margin-right: 40px; }
.nav-link { padding: 8px 16px; border-radius: 8px; text-decoration: none; color: var(--text-muted); font-size: 14px; font-weight: 500; }
.nav-link:hover { color: var(--text); background: var(--bg-card-alt); }
.nav-link.active { color: var(--accent); background: var(--accent-dim); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
[data-lang="ar"] .nav-right { margin-left: 0; margin-right: auto; }
.toggle-group { display: flex; background: var(--bg-card); border: 1px solid var(--border); border-radius: 50px; padding: 3px; }
.toggle-btn { padding: 6px 12px; border: none; background: transparent; color: var(--text-muted); font-size: 12px; font-weight: 500; cursor: pointer; border-radius: 50px; font-family: inherit; display: flex; align-items: center; }
.toggle-btn.active { background: var(--accent); color: #000; }
.toggle-btn svg { width: 14px; height: 14px; }

/* User Menu */
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 50px; cursor: pointer; font-family: inherit; color: var(--text); }
.user-avatar { width: 32px; height: 32px; background: linear-gradient(135deg, var(--accent), var(--purple)); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; color: #fff; }
.user-name { font-size: 13px; font-weight: 500; }
.user-dropdown { position: absolute; top: calc(100% + 8px); right: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; min-width: 200px; opacity: 0; visibility: hidden; transform: translateY(-10px); transition: all 0.2s; z-index: 101; }
.user-dropdown.show { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; font-size: 13px; color: var(--text-secondary); cursor: pointer; border: none; background: none; width: 100%; text-align: left; font-family: inherit; text-decoration: none; }
.dropdown-item:hover { background: var(--bg-card-alt); color: var(--text); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-dim); }
.dropdown-divider { height: 1px; background: var(--border); margin: 8px 0; }
.dropdown-header { padding: 10px 12px; font-size: 12px; color: var(--text-muted); }

/* Container */
.container { max-width: 1400px; margin: 0 auto; padding: 88px 24px 40px; position: relative; z-index: 1; }
header { text-align: center; margin-bottom: 48px; }
.logo { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 12px; }
.logo-icon { width: 48px; height: 48px; background: linear-gradient(135deg, var(--accent), #059669); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: #fff; }
h1 { font-size: 32px; font-weight: 700; }
header p { color: var(--text-muted); font-size: 15px; }

/* Stats */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.stat-card.profit::before { background: var(--accent); }
.stat-card.revenue::before { background: var(--blue); }
.stat-card.orders::before { background: var(--purple); }
.stat-card.roi::before { background: var(--orange); }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.stat-card.profit .stat-icon { background: var(--accent-dim); color: var(--accent); }
.stat-card.revenue .stat-icon { background: var(--blue-dim); color: var(--blue); }
.stat-card.orders .stat-icon { background: var(--purple-dim); color: var(--purple); }
.stat-card.roi .stat-icon { background: var(--orange-dim); color: var(--orange); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-family: 'JetBrains Mono', monospace; font-size: 24px; font-weight: 700; }
.stat-value.positive { color: var(--accent); }
.stat-value.negative { color: var(--danger); }

/* Grid & Cards */
.main-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.card-title { font-size: 15px; font-weight: 600; }
.card-icon { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.card-body { padding: 24px; }

/* Forms */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group.full { grid-column: span 2; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-select { padding: 14px 16px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: inherit; font-size: 14px; width: 100%; }
.form-input:focus, .form-select:focus { outline: none; border-color: var(--accent); }
.slider-container { display: flex; align-items: center; gap: 12px; }
.slider-container input[type="range"] { flex: 1; height: 6px; -webkit-appearance: none; background: var(--border); border-radius: 3px; }
.slider-container input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; background: var(--accent); border-radius: 50%; cursor: pointer; }
.slider-value { min-width: 50px; text-align: right; font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 600; color: var(--accent); }

/* Funnel */
.funnel-container { padding: 8px 0; }
.funnel-step { margin-bottom: 12px; display: flex; align-items: center; }
.funnel-bar { display: flex; align-items: center; padding: 12px 16px; border-radius: 8px; min-height: 44px; transition: width 0.5s ease; }
.funnel-bar.leads { background: linear-gradient(90deg, var(--blue), #2563eb); width: 100%; }
.funnel-bar.confirmed { background: linear-gradient(90deg, var(--purple), #7c3aed); }
.funnel-bar.delivered { background: linear-gradient(90deg, var(--accent), #059669); }
.funnel-bar.returned { background: linear-gradient(90deg, var(--danger), #dc2626); }
.funnel-label { font-size: 12px; font-weight: 500; color: #fff; }
.funnel-value { margin-left: auto; font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 600; color: #fff; }
.funnel-percent { min-width: 50px; text-align: right; font-size: 12px; color: var(--text-muted); margin-left: 12px; }

/* Cost List */
.cost-list { display: flex; flex-direction: column; gap: 10px; }
.cost-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--bg-card-alt); border-radius: 8px; border: 1px solid var(--border); }
.cost-dot { width: 10px; height: 10px; border-radius: 50%; }
.cost-dot.ads { background: var(--blue); }
.cost-dot.product { background: var(--purple); }
.cost-dot.delivery { background: var(--accent); }
.cost-dot.returns { background: var(--orange); }
.cost-dot.total { background: var(--danger); }
.cost-label { flex: 1; font-size: 13px; color: var(--text-secondary); }
.cost-value { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 600; }
.cost-item.total { background: var(--accent-dim); border-color: rgba(16, 185, 129, 0.3); }
.cost-item.total .cost-label { font-weight: 600; color: var(--text); }
.cost-item.total .cost-value { color: var(--accent); }

/* Chart */
.chart-wrapper { height: 220px; }

/* Save Button */
.save-product-btn { width: 100%; padding: 14px 24px; background: linear-gradient(135deg, var(--accent), #059669); border: none; border-radius: var(--radius-sm); color: #fff; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; }
.save-product-btn:hover { opacity: 0.9; }
.save-product-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; padding: 12px 24px; border-radius: 8px; font-size: 14px; font-weight: 500; z-index: 1001; opacity: 0; transition: opacity 0.3s; }
.toast.show { opacity: 1; }

/* Spinner */
.spinner { width: 18px; height: 18px; border: 2px solid transparent; border-top-color: currentColor; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Mobile Nav */
.mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-card); border-top: 1px solid var(--border); padding: 8px 0; padding-bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 100; }
.mobile-nav-items { display: flex; justify-content: space-around; }
.mobile-nav-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 16px; color: var(--text-muted); text-decoration: none; font-size: 10px; font-weight: 500; border-radius: 8px; }
.mobile-nav-item:hover, .mobile-nav-item.active { color: var(--accent); background: var(--accent-dim); }
.mobile-nav-item svg { width: 22px; height: 22px; }

/* App Content */
.app-content { display: none; }
.app-content.visible { display: block; }

/* Responsive */
@media (max-width: 1200px) { .main-grid { grid-template-columns: 1fr; } }
@media (max-width: 992px) { .nav-links { display: none; } .stats-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) { 
    .navbar { padding: 0 16px; height: 60px; }
    .nav-title { display: none; }
    .user-name { display: none; }
    .container { padding: 76px 16px 100px; }
    .stats-row { gap: 10px; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 20px; }
    .form-row { grid-template-columns: 1fr; }
    .form-group.full { grid-column: span 1; }
    .mobile-nav { display: block; }
}
@media (max-width: 480px) { 
    .stats-row { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 14px 12px; }
    .stat-value { font-size: 18px; }
    h1 { font-size: 24px; }
}
