/* ========================================
   Faktoor — Modern Minimal RTL Design
   Inspired by VRoute clean aesthetic
   ======================================== */

:root {
    --primary:        #0EA5C9;
    --primary-light:  #38BDF8;
    --primary-dark:   #0284A8;
    --primary-muted:  #E0F6FD;
    --primary-glow:   rgba(14,165,201,0.15);

    --accent:         #6366F1;
    --accent-light:   #818CF8;
    --accent-muted:   #EEF2FF;

    --success:        #10B981;
    --success-muted:  #D1FAE5;
    --success-text:   #065F46;
    --danger:         #EF4444;
    --danger-muted:   #FEE2E2;
    --danger-text:    #991B1B;
    --warning:        #F59E0B;
    --warning-muted:  #FEF3C7;
    --warning-text:   #92400E;

    --bg:         #F0F4F8;
    --surface:    #FFFFFF;
    --surface-2:  #F8FAFC;
    --surface-3:  #EFF8FC;

    --border:      #E2E8F0;
    --border-soft: #F1F5F9;

    --text:        #0F172A;
    --text-2:      #334155;
    --text-muted:  #64748B;
    --text-light:  #94A3B8;
    --text-xlight: #CBD5E1;

    --radius:    14px;
    --radius-sm: 10px;
    --radius-xs: 7px;
    --radius-lg: 20px;
    --radius-full: 999px;

    --shadow-xs: 0 1px 3px rgba(15,23,42,0.05);
    --shadow:    0 4px 16px rgba(15,23,42,0.06), 0 1px 4px rgba(15,23,42,0.04);
    --shadow-md: 0 8px 32px rgba(15,23,42,0.08), 0 2px 8px rgba(15,23,42,0.04);
    --shadow-lg: 0 20px 48px rgba(15,23,42,0.12);
    --shadow-primary: 0 4px 20px rgba(14,165,201,0.3);

    --font: 'Vazirmatn', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { font-weight: 700; line-height: 1.3; color: var(--text); }
h1 { font-size: 2.2rem; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.2rem; }
p  { color: var(--text-2); }

.container { max-width: 1180px; margin: 0 auto; padding: 0 28px; }
.site-main  { flex: 1; }

/* ====== HEADER ====== */
.site-header {
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-soft);
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-xs);
}
.header-inner {
    display: flex; align-items: center; gap: 24px; height: 62px;
}
.logo {
    display: flex; align-items: center; gap: 9px;
    text-decoration: none; font-size: 1.15rem; font-weight: 800; color: var(--text); flex-shrink: 0;
}
.logo-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-xs); display: flex; align-items: center; justify-content: center;
    color: white; font-size: 0.95rem; box-shadow: var(--shadow-primary);
}
.logo-text strong { color: var(--primary); }
.main-nav { display: flex; gap: 2px; margin-right: auto; }
.main-nav a {
    text-decoration: none; color: var(--text-muted); font-size: 0.875rem; font-weight: 500;
    padding: 6px 13px; border-radius: var(--radius-xs); transition: all 0.18s;
}
.main-nav a:hover { color: var(--text); background: var(--border-soft); }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* ====== BUTTONS ====== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 20px; border-radius: var(--radius-sm); font-family: var(--font);
    font-size: 0.875rem; font-weight: 600; cursor: pointer; text-decoration: none;
    border: 1.5px solid transparent; transition: all 0.18s cubic-bezier(0.4,0,0.2,1);
    white-space: nowrap; line-height: 1;
}
.btn:active { transform: scale(0.97) !important; }

.btn-primary {
    background: var(--primary); color: white; border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(14,165,201,0.2);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); box-shadow: var(--shadow-primary); transform: translateY(-1px); }

.btn-accent {
    background: var(--accent); color: white; border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(99,102,241,0.2);
}
.btn-accent:hover { background: #4F46E5; transform: translateY(-1px); }

.btn-outline {
    background: var(--surface); color: var(--text-2); border-color: var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-muted); }

.btn-ghost {
    background: transparent; color: var(--text-muted); border-color: transparent;
}
.btn-ghost:hover { background: var(--border-soft); color: var(--text); }

.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-danger  { background: var(--danger); color: white; border-color: var(--danger); }

.btn-lg { padding: 12px 28px; font-size: 0.95rem; border-radius: var(--radius); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; border-radius: var(--radius-xs); }
.btn-xs { padding: 4px 10px; font-size: 0.75rem; border-radius: var(--radius-xs); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none; }

/* ====== FORMS ====== */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-2);
    margin-bottom: 6px; letter-spacing: 0.01em;
}
.form-control {
    width: 100%; padding: 9px 13px; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); font-family: var(--font); font-size: 0.9rem;
    color: var(--text); background: var(--surface);
    transition: border-color 0.18s, box-shadow 0.18s; direction: rtl;
}
.form-control:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-control:hover:not(:focus) { border-color: var(--text-light); }
.form-control::placeholder { color: var(--text-xlight); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 88px; }

/* ====== CARDS ====== */
.card {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border-soft);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-header h3 { font-size: 0.92rem; font-weight: 700; margin: 0; }
.card-body  { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border-soft); background: var(--surface-2); }

/* ====== FLASH ====== */
.flash {
    padding: 11px 16px; margin: 12px auto; max-width: 1180px;
    border-radius: var(--radius-sm); font-weight: 500; font-size: 0.875rem;
}
.flash-success { background: var(--success-muted); color: var(--success-text); border: 1px solid #6EE7B7; }
.flash-error   { background: var(--danger-muted); color: var(--danger-text); border: 1px solid #FCA5A5; }

/* ====== HERO ====== */
.hero {
    background: linear-gradient(140deg, #0F172A 0%, #0C3049 50%, #075985 100%);
    padding: 90px 0 115px; text-align: center; position: relative; overflow: hidden;
}
.hero::before {
    content: ''; position: absolute; width: 600px; height: 600px; border-radius: 50%;
    background: radial-gradient(circle, rgba(14,165,201,0.35) 0%, transparent 65%);
    top: -150px; right: -100px; pointer-events: none;
}
.hero::after {
    content: ''; position: absolute; width: 400px; height: 400px; border-radius: 50%;
    background: radial-gradient(circle, rgba(99,102,241,0.2) 0%, transparent 65%);
    bottom: -80px; left: 10%; pointer-events: none;
}
.hero-content { position: relative; z-index: 1; }
.hero-badge {
    display: inline-flex; align-items: center; gap: 7px;
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-full); padding: 5px 16px; color: rgba(255,255,255,0.75);
    font-size: 0.8rem; font-weight: 600; margin-bottom: 22px; backdrop-filter: blur(8px);
}
.hero-badge-dot {
    width: 6px; height: 6px; border-radius: 50%; background: var(--primary-light);
    animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%,100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.6); }
}
.hero h1 {
    color: white; font-size: 3rem; font-weight: 800; margin-bottom: 20px;
    letter-spacing: -0.025em; line-height: 1.15;
}
.hero h1 span {
    background: linear-gradient(90deg, var(--primary-light), #67E8F9);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero p { color: rgba(255,255,255,0.68); font-size: 1.1rem; max-width: 500px; margin: 0 auto 38px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ====== FEATURES ====== */
.features { padding: 88px 0; }
.section-header { text-align: center; margin-bottom: 52px; }
.section-tag {
    display: inline-block; background: var(--primary-muted); color: var(--primary-dark);
    font-size: 0.75rem; font-weight: 700; padding: 4px 14px; border-radius: var(--radius-full);
    margin-bottom: 14px; letter-spacing: 0.06em; text-transform: uppercase;
}
.section-header h2 { margin-bottom: 12px; letter-spacing: -0.01em; }
.section-header p  { color: var(--text-muted); max-width: 480px; margin: 0 auto; font-size: 0.92rem; }

.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .features-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 520px)  { .features-grid { grid-template-columns: 1fr; } }

.feature-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 28px 22px; transition: all 0.22s cubic-bezier(0.4,0,0.2,1); position: relative; overflow: hidden;
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: rgba(14,165,201,0.3); }
.feature-icon-wrap {
    width: 44px; height: 44px; background: var(--primary-muted); border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; margin-bottom: 16px; font-size: 1.25rem;
}
.feature-card h3 { font-size: 0.97rem; margin-bottom: 8px; }
.feature-card p  { font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; }

/* ====== BUILDER ====== */
.invoice-builder-page { padding: 36px 0 80px; }
.invoice-builder-page .page-header { margin-bottom: 26px; }
.invoice-builder-page .page-header h1 { font-size: 1.65rem; letter-spacing: -0.01em; }
.invoice-builder-page .page-header p  { color: var(--text-muted); margin-top: 5px; font-size: 0.875rem; }

.builder-layout { display: grid; grid-template-columns: 1fr 390px; gap: 22px; align-items: start; }
@media (max-width: 960px) { .builder-layout { grid-template-columns: 1fr; } }

.builder-section-title {
    font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.08em; padding-bottom: 11px; border-bottom: 1.5px solid var(--border-soft);
    margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}

.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 13px; }
@media (max-width: 600px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }

.items-table { width: 100%; border-collapse: collapse; margin-bottom: 13px; }
.items-table thead th {
    background: var(--surface-2); padding: 8px 10px; font-size: 0.72rem; font-weight: 700;
    color: var(--text-muted); text-align: right; border-bottom: 1.5px solid var(--border);
    letter-spacing: 0.05em; text-transform: uppercase;
}
.items-table tbody td { padding: 5px 7px; vertical-align: middle; }
.items-table tbody tr { border-bottom: 1px solid var(--border-soft); }
.items-table tbody tr:hover td { background: var(--surface-2); }
.items-table .form-control { padding: 7px 9px; font-size: 0.83rem; }
.btn-remove-row {
    background: none; border: none; cursor: pointer; color: var(--text-light); font-size: 0.9rem;
    width: 27px; height: 27px; border-radius: var(--radius-xs);
    display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.btn-remove-row:hover { background: var(--danger-muted); color: var(--danger); }

.invoice-summary {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 16px; margin-top: 12px;
}
.summary-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; font-size: 0.85rem; color: var(--text-muted);
}
.summary-row + .summary-row { border-top: 1px dashed var(--border); }
.summary-total {
    font-size: 0.97rem; font-weight: 800; color: var(--primary);
    border-top: 1.5px solid var(--border) !important; margin-top: 6px; padding-top: 11px !important;
}

.invoice-preview {
    background: white; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 26px; box-shadow: var(--shadow-md); position: sticky; top: 78px; font-size: 0.83rem;
}
.preview-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 18px; padding-bottom: 14px; border-bottom: 2px solid var(--primary);
}
.preview-logo { font-size: 1.1rem; font-weight: 800; color: var(--primary); }
.preview-invoice-num { text-align: left; }
.preview-invoice-num strong { display: block; color: var(--text); font-size: 0.97rem; margin-bottom: 3px; }
.preview-invoice-num span { color: var(--text-muted); font-size: 0.75rem; }
.preview-parties {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px;
    background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm);
}
.preview-party h4 { font-size: 0.68rem; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.preview-party p  { font-size: 0.8rem; color: var(--text); }
.preview-items table { width: 100%; border-collapse: collapse; }
.preview-items th {
    background: var(--primary); color: white; padding: 6px 8px; font-size: 0.7rem; text-align: right;
}
.preview-items td { padding: 5px 8px; border-bottom: 1px solid var(--border-soft); font-size: 0.75rem; }
.preview-total { text-align: left; margin-top: 12px; font-size: 0.9rem; font-weight: 800; color: var(--primary); direction: ltr; }
.watermark-badge {
    text-align: center; margin-top: 16px; padding-top: 12px;
    border-top: 1px dashed var(--border); font-size: 0.68rem; color: var(--text-xlight);
}

.action-bar {
    background: rgba(255,255,255,0.94); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding: 13px 0;
    position: sticky; bottom: 0; z-index: 50; box-shadow: 0 -4px 20px rgba(15,23,42,0.06);
}
.action-bar-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.action-bar-tip { font-size: 0.8rem; color: var(--text-muted); }
.action-bar-tip strong { color: var(--success); }
.action-bar-buttons { display: flex; gap: 9px; }

/* ====== STATS ====== */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 26px; }
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 480px)  { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px 18px; box-shadow: var(--shadow); transition: all 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon {
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
    flex-shrink: 0; margin-bottom: 14px;
}
.stat-icon.blue   { background: var(--primary-muted); }
.stat-icon.green  { background: var(--success-muted); }
.stat-icon.orange { background: var(--warning-muted); }
.stat-icon.red    { background: var(--danger-muted); }
.stat-value { font-size: 1.65rem; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -0.02em; margin-bottom: 4px; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }

/* ====== BADGES ====== */
.badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
    border-radius: var(--radius-full); font-size: 0.73rem; font-weight: 600;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.badge-draft     { background: var(--border-soft); color: var(--text-muted); }
.badge-sent      { background: var(--primary-muted); color: var(--primary-dark); }
.badge-paid      { background: var(--success-muted); color: var(--success-text); }
.badge-cancelled { background: var(--danger-muted); color: var(--danger-text); }

/* ====== TABLES ====== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 10px 16px; font-size: 0.75rem; font-weight: 700; color: var(--text-muted);
    text-align: right; border-bottom: 1.5px solid var(--border);
    background: var(--surface-2); text-transform: uppercase; letter-spacing: 0.05em;
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-soft); font-size: 0.875rem; color: var(--text-2); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.12s; }
.data-table tbody tr:hover td { background: var(--surface-2); }

/* ====== FOOTER ====== */
.site-footer { background: #0F172A; color: rgba(255,255,255,0.45); padding: 28px 0; margin-top: auto; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
.footer-copy { font-size: 0.83rem; }
.footer-nav { display: flex; gap: 20px; }
.footer-nav a { color: rgba(255,255,255,0.4); text-decoration: none; font-size: 0.83rem; transition: color 0.2s; }
.footer-nav a:hover { color: white; }

/* ====== AUTH ====== */
.auth-page {
    min-height: calc(100vh - 62px - 84px);
    display: flex; align-items: center; justify-content: center; padding: 40px 24px;
}
.auth-card { width: 100%; max-width: 420px; }
.auth-card .card-header { text-align: center; display: block; padding: 28px 24px 20px; }
.auth-card .card-header h2 { font-size: 1.4rem; margin-bottom: 6px; }
.auth-card .card-header p  { color: var(--text-muted); font-size: 0.875rem; }

/* ====== DIVIDER ====== */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ====== UTILITIES ====== */
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-primary { color: var(--primary) !important; }
.fw-700 { font-weight: 700; } .fw-800 { font-weight: 800; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; } .align-center { align-items: center; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    h1 { font-size: 1.7rem; }
    .hero { padding: 56px 0 72px; }
    .hero h1 { font-size: 2rem; }
    .main-nav { display: none; }
    .invoice-preview { display: none; }
}

/* ====== PRINT ====== */
@media print {
    .site-header, .site-footer, .action-bar, .no-print { display: none !important; }
    body { background: white; }
}

/* ====== ANIMATIONS ====== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp 0.35s cubic-bezier(0.4,0,0.2,1) both; }
.delay-1 { animation-delay: 0.08s; } .delay-2 { animation-delay: 0.16s; } .delay-3 { animation-delay: 0.24s; }
