@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&display=swap');

:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --primary-dark: #0e2f44;
    --secondary: #e67e22;
    --secondary-light: #f39c12;
    --success: #27ae60;
    --danger: #c0392b;
    --warning: #f1c40f;
    --info: #3498db;
    --light: #f8f9fa;
    --dark: #2c3e50;
    --gray: #95a5a6;
    --gray-light: #ecf0f1;
    --border: #dfe6e9;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
    --radius: 8px;
}

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

body {
    font-family: 'Tajawal', sans-serif;
    background: #f0f2f5;
    color: var(--dark);
    direction: rtl;
    font-size: 14px;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: var(--primary);
}

/* ========== LAYOUT ========== */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #fff;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: all 0.3s;
}

.sidebar-header {
    padding: 20px 15px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 3px;
}

.sidebar-header small {
    font-size: 11px;
    opacity: 0.7;
}

.sidebar-menu {
    list-style: none;
    padding: 10px 0;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    transition: all 0.2s;
    border-right: 3px solid transparent;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-right-color: var(--secondary);
}

.sidebar-menu li a i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.menu-section {
    padding: 12px 20px 5px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    font-weight: 700;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-right: 260px;
    flex: 1;
    min-height: 100vh;
}

.top-bar {
    background: #fff;
    padding: 12px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-dark);
}

.top-bar .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--gray);
}

.top-bar .user-info i {
    font-size: 20px;
    color: var(--primary);
}

.content {
    padding: 25px;
}

/* ========== CARDS ========== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card .icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
}

.stat-card .icon.blue { background: linear-gradient(135deg, var(--info), var(--primary)); }
.stat-card .icon.green { background: linear-gradient(135deg, var(--success), #1abc9c); }
.stat-card .icon.orange { background: linear-gradient(135deg, var(--secondary), var(--secondary-light)); }
.stat-card .icon.red { background: linear-gradient(135deg, var(--danger), #e74c3c); }
.stat-card .icon.purple { background: linear-gradient(135deg, #8e44ad, #9b59b6); }

.stat-card .info h4 {
    font-size: 22px;
    font-weight: 800;
    color: var(--dark);
}

.stat-card .info p {
    font-size: 12px;
    color: var(--gray);
    margin-top: 2px;
}

/* ========== CARD/BOX ========== */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

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

.card-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-dark);
}

.card-body {
    padding: 20px;
}

/* ========== TABLE ========== */
.table-responsive {
    overflow-x: auto;
}

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

table thead th {
    background: var(--light);
    padding: 12px 15px;
    font-weight: 700;
    font-size: 13px;
    color: var(--dark);
    border-bottom: 2px solid var(--border);
    text-align: right;
    white-space: nowrap;
}

table tbody td {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

table tbody tr:hover {
    background: #f8f9fa;
}

/* ========== FORMS ========== */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 13px;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    transition: border-color 0.2s;
    direction: rtl;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41,128,185,0.1);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    padding-left: 30px;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: 6px;
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: var(--dark); }
.btn-info { background: var(--info); color: #fff; }
.btn-secondary { background: var(--gray); color: #fff; }
.btn-orange { background: var(--secondary); color: #fff; }

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

.btn-lg {
    padding: 12px 28px;
    font-size: 16px;
}

/* ========== BADGES ========== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-primary { background: #cce5ff; color: #004085; }

/* ========== ALERTS ========== */
.alert {
    padding: 12px 18px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ========== LOGIN PAGE ========== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}

.login-box {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}

.login-box h1 {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 5px;
}

.login-box .subtitle {
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 30px;
}

.login-box .form-group {
    text-align: right;
}

.login-box .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 16px;
    margin-top: 10px;
}

/* ========== INVOICE PRINT ========== */
.invoice-print {
    background: #fff;
    padding: 30px;
    max-width: 800px;
    margin: 0 auto;
    direction: rtl;
    font-family: 'Tajawal', sans-serif;
}

.invoice-print .header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 3px solid var(--primary);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.invoice-print .header .company-info h2 {
    font-size: 18px;
    color: var(--primary-dark);
}

.invoice-print .header .company-info p {
    font-size: 12px;
    color: var(--gray);
    margin: 2px 0;
}

.invoice-print .invoice-title {
    text-align: center;
    background: var(--primary);
    color: #fff;
    padding: 8px;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 15px;
}

.invoice-print .invoice-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
    font-size: 13px;
}

.invoice-print .meta-box {
    background: var(--light);
    padding: 12px;
    border-radius: 6px;
}

.invoice-print .meta-box .label {
    font-weight: 700;
    color: var(--primary);
    margin-left: 5px;
}

.invoice-print table {
    margin-bottom: 15px;
    border: 1px solid var(--border);
}

.invoice-print table th {
    background: var(--primary);
    color: #fff;
    padding: 10px;
    font-size: 13px;
}

.invoice-print table td {
    padding: 10px;
    text-align: center;
    border: 1px solid var(--border);
}

.invoice-print .totals {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: 15px;
}

.invoice-print .totals-table {
    width: 300px;
}

.invoice-print .totals-table tr td {
    padding: 6px 12px;
    font-size: 13px;
}

.invoice-print .totals-table tr:last-child {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
}

.invoice-print .totals-table tr:last-child td {
    padding: 10px 12px;
}

.invoice-print .amount-words {
    background: var(--light);
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 10px;
}

.invoice-print .footer {
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--gray);
}

/* ========== VOUCHER PRINT ========== */
.voucher-print {
    background: #fff;
    padding: 30px;
    max-width: 700px;
    margin: 0 auto;
    direction: rtl;
    font-family: 'Tajawal', sans-serif;
    border: 2px solid var(--primary);
    border-radius: 10px;
}

.voucher-print .voucher-header {
    text-align: center;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.voucher-print .voucher-type {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
}

.voucher-print .voucher-body {
    font-size: 15px;
    line-height: 2;
}

.voucher-print .voucher-body .amount-box {
    background: var(--light);
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: 6px;
    text-align: center;
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    margin: 15px 0;
}

.voucher-print .signatures {
    display: flex;
    justify-content: space-around;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.voucher-print .signatures div {
    text-align: center;
}

.voucher-print .signatures .line {
    width: 120px;
    border-top: 1px solid var(--dark);
    margin: 30px auto 5px;
}

/* ========== PROFIT REPORT ========== */
.profit-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.profit-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 25px;
    text-align: center;
}

.profit-card .amount {
    font-size: 32px;
    font-weight: 800;
    margin: 10px 0;
}

.profit-card .amount.positive { color: var(--success); }
.profit-card .amount.negative { color: var(--danger); }

/* ========== MODAL ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-box {
    background: #fff;
    border-radius: 12px;
    width: 600px;
    max-width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0,0,0,0.3);
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--gray);
    padding: 0 5px;
}

.modal-body {
    padding: 20px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .sidebar {
        width: 220px;
        transform: translateX(100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-right: 0;
    }
    .stats-row {
        grid-template-columns: 1fr 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .profit-section {
        grid-template-columns: 1fr;
    }
}

/* ========== PRINT STYLES ========== */
@media print {
    .sidebar, .top-bar, .no-print, .btn {
        display: none !important;
    }
    .main-content {
        margin: 0 !important;
    }
    .content {
        padding: 0 !important;
    }
    .card {
        box-shadow: none;
        border: none;
    }
    body {
        background: #fff;
    }
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card, .stat-card {
    animation: fadeIn 0.3s ease;
}

/* ========== ITEMS TABLE (Invoice) ========== */
.items-table input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: 'Tajawal', sans-serif;
    font-size: 13px;
    text-align: center;
}

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

.items-table .remove-row {
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 14px;
}

/* ========== NUMBER TO WORDS HELPER ========== */
.text-muted { color: var(--gray); font-size: 12px; }
.text-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.p-20 { padding: 20px; }
