/* =====================================================
   حسابداری صرافی - استایل اصلی
   ===================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --info: #0891b2;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius: 10px;
}

html, body {
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.6;
    min-height: 100vh;
}

/* =====================================================
   هدر
   ===================================================== */
.app-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: white;
    padding: 16px 24px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.app-header h1 {
    font-size: 22px;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* =====================================================
   ساختار اصلی
   ===================================================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.top-section, .bottom-section {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .top-section, .bottom-section {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

/* =====================================================
   لیست مشتری‌ها
   ===================================================== */
.customers-panel {
    height: fit-content;
}

.customers-list {
    max-height: 460px;
    overflow-y: auto;
    padding: 10px;
}

.customer-item {
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 6px;
    border: 1px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.customer-item:hover {
    background: #f8fafc;
}

.customer-item.active {
    background: #dbeafe;
    border-color: var(--primary);
}

.customer-name {
    font-weight: 600;
    font-size: 15px;
}

.customer-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.customer-balance-pill {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #f1f5f9;
    color: var(--text-muted);
}

.customer-balance-pill.has-debt {
    background: #fef3c7;
    color: #92400e;
}

/* =====================================================
   پنل صدا
   ===================================================== */
.voice-panel .selected-customer {
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 999px;
    background: #f1f5f9;
    color: var(--text-muted);
}

.voice-panel .selected-customer.has-customer {
    background: #d1fae5;
    color: #065f46;
}

.voice-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    gap: 12px;
}

.mic-button {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(37,99,235,0.35);
    transition: all 0.2s ease;
}

.mic-button:hover {
    transform: scale(1.05);
}

.mic-button.recording {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 4px 14px rgba(220,38,38,0.4); }
    50% { box-shadow: 0 4px 24px rgba(220,38,38,0.8); }
}

.mic-status {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

.mic-status.error {
    color: var(--danger);
}

.mic-status.success {
    color: var(--success);
}

.transcript-area {
    padding: 0 18px 18px;
}

.transcript-area label {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
    font-weight: 500;
}

.transcript-area textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 14px;
    direction: rtl;
    resize: vertical;
}

.transcript-area textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.parse-preview {
    margin-top: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 13px;
    min-height: 32px;
    display: none;
}

.parse-preview.success {
    display: block;
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.parse-preview.error {
    display: block;
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.action-buttons {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

.examples {
    padding: 0 18px 18px;
    font-size: 13px;
}

.examples summary {
    cursor: pointer;
    padding: 6px 0;
    color: var(--primary);
    font-weight: 500;
}

.examples ul {
    margin: 8px 0 0;
    padding-right: 20px;
}

.examples li {
    margin-bottom: 4px;
    color: var(--text-muted);
}

.examples code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Vazirmatn', monospace;
    direction: rtl;
}

/* =====================================================
   پنل موجودی
   ===================================================== */
.balance-display {
    padding: 16px;
}

.balance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 15px;
    border: 1px solid var(--border);
}

.balance-row.positive {
    background: #fef3c7;
    border-color: #fcd34d;
}

.balance-row.negative {
    background: #dbeafe;
    border-color: #93c5fd;
}

.balance-row.zero {
    background: #f1f5f9;
    color: var(--text-muted);
}

.balance-currency {
    font-weight: 600;
}

.balance-amount {
    font-family: 'Vazirmatn', monospace;
    font-weight: 600;
    direction: ltr;
}

.balance-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 500;
}

.balance-row.positive .balance-status {
    background: #f59e0b;
    color: white;
}

.balance-row.negative .balance-status {
    background: var(--primary);
    color: white;
}

/* =====================================================
   لیست تراکنش‌ها
   ===================================================== */
.transactions-list {
    max-height: 500px;
    overflow-y: auto;
    padding: 10px 16px;
}

.transaction-item {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-info {
    flex: 1;
}

.transaction-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
}

.transaction-type.sell { background: #dbeafe; color: #1e40af; }
.transaction-type.buy { background: #fce7f3; color: #9f1239; }
.transaction-type.receive { background: #d1fae5; color: #065f46; }
.transaction-type.pay { background: #fef3c7; color: #92400e; }
.transaction-type.opening { background: #e9d5ff; color: #6b21a8; font-weight: 700; }

/* =====================================================
   پنل داشبورد صندوق
   ===================================================== */
.cashier-section {
    background: linear-gradient(135deg, #fafafa 0%, #f1f5f9 100%);
}

.cashier-panel-content {
    padding: 16px;
}

.cashier-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

@media (max-width: 900px) {
    .cashier-grid {
        grid-template-columns: 1fr;
    }
}

.cashier-card {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cashier-card h3 {
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.cashier-card.cashier-box h3 { background: #fef3c7; color: #92400e; }
.cashier-card.receivables-box h3 { background: #dcfce7; color: #166534; }
.cashier-card.payables-box h3 { background: #fee2e2; color: #991b1b; }

.cashier-rows {
    padding: 8px;
    flex: 1;
}

.cash-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    font-size: 14px;
    background: #f8fafc;
}

.cash-row.pos {
    background: #ecfdf5;
    color: #064e3b;
    border-right: 3px solid #16a34a;
}

.cash-row.neg {
    background: #fef2f2;
    color: #7f1d1d;
    border-right: 3px solid #dc2626;
}

.cash-row .amount {
    font-family: 'Vazirmatn', monospace;
    font-weight: 600;
    direction: ltr;
}

.transaction-detail {
    font-size: 14px;
    font-weight: 500;
}

.transaction-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.transaction-raw {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 4px;
}

.btn-delete-tx {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
}

/* =====================================================
   خلاصه کلی
   ===================================================== */
.overall-summary {
    padding: 16px;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
}

.summary-table th,
.summary-table td {
    padding: 10px 12px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.summary-table th {
    background: #f8fafc;
    font-weight: 600;
}

.summary-table td.amount {
    font-family: 'Vazirmatn', monospace;
    direction: ltr;
    text-align: left;
}

.summary-table .pos { color: var(--warning); font-weight: 600; }
.summary-table .neg { color: var(--primary); font-weight: 600; }

/* =====================================================
   دکمه‌ها و فرم
   ===================================================== */
.btn {
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #f8fafc;
}

.app-header .btn-secondary {
    background: rgba(255,255,255,0.15);
    color: white;
    border-color: rgba(255,255,255,0.3);
}

.app-header .btn-secondary:hover {
    background: rgba(255,255,255,0.25);
}

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

.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 10px;
    direction: rtl;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
}

/* =====================================================
   مودال
   ===================================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    width: 90%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

/* =====================================================
   حالت خالی و اعلان
   ===================================================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 50%;
    transform: translateX(50%);
    background: var(--text);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2000;
    pointer-events: none;
    font-size: 14px;
}

.toast.show {
    opacity: 1;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }

/* اسکرول‌بار */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ━━━━━━━━━━━━━━ Nav Tabs ━━━━━━━━━━━━━━ */
.nav-tab {
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255,255,255,0.7);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.nav-tab:hover { background: rgba(255,255,255,0.15); color: white; }
.nav-tab.active { background: rgba(255,255,255,0.25); color: white; font-weight: 700; }

/* ━━━━━━━━━━━━━━ Report Tabs ━━━━━━━━━━━━━━ */
.report-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: #64748b;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.report-tab:hover { color: #1d4ed8; }
.report-tab.active { color: #1d4ed8; border-bottom-color: #1d4ed8; font-weight: 700; }

/* ━━━━━━━━━━━━━━ P&L Card ━━━━━━━━━━━━━━ */
.pnl-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 14px;
}
.pnl-income { background: #ecfdf5; color: #065f46; }
.pnl-expense { background: #fef2f2; color: #991b1b; }
.pnl-net-positive { background: linear-gradient(135deg,#ecfdf5,#d1fae5); color: #065f46; font-weight: 800; font-size: 16px; }
.pnl-net-negative { background: linear-gradient(135deg,#fef2f2,#fee2e2); color: #991b1b; font-weight: 800; font-size: 16px; }
.pnl-section-title { font-size: 12px; font-weight: 700; color: #94a3b8; text-transform: uppercase; margin: 16px 0 8px; }

/* ━━━━━━━━━━━━━━ Expense/Service List Items ━━━━━━━━━━━━━━ */
.expense-item, .service-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    transition: background 0.15s;
}
.expense-item:hover, .service-item:hover { background: #f1f5f9; }
