/* ========================================
   متغيرات الألوان والإعدادات العامة
======================================== */
:root {
    --primary-color: #f57c00;
    --secondary-color: #004d40;
    --success-color: #4caf50;
    --danger-color: #f44336;
    --warning-color: #ff9800;
    --info-color: #2196f3;
    --light-bg: #f5f5f5;
    --white: #ffffff;
    --text-dark: #333333;
    --text-light: #666666;
    --border-color: #e0e0e0;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* ========================================
   إعدادات عامة
======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--light-bg);
    color: var(--text-dark);
    line-height: 1.6;
    direction: rtl;
}

/* ========================================
   Sidebar
======================================== */
.sidebar {
    position: fixed;
    right: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    background: linear-gradient(180deg, var(--secondary-color) 0%, #003832 100%);
    color: var(--white);
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 1000;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
}

.logo-container {
    padding: 30px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-icon {
    width: 70px;
    height: 70px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    box-shadow: 0 4px 15px rgba(245, 124, 0, 0.3);
}

.logo-icon i {
    font-size: 32px;
    color: var(--white);
}

.logo-text {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

.nav-menu {
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    border-right: 3px solid transparent;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border-right-color: var(--primary-color);
}

.nav-item.active {
    background-color: rgba(245, 124, 0, 0.2);
    color: var(--white);
    border-right-color: var(--primary-color);
}

.nav-item i {
    font-size: 20px;
    width: 30px;
    margin-left: 15px;
}

.nav-item span {
    font-size: 16px;
    font-weight: 500;
}

/* ========================================
   Sidebar - Hierarchical Menu (هرمي)
======================================== */
.nav-group {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-parent {
    cursor: pointer;
    user-select: none;
    background-color: rgba(0, 0, 0, 0.15);
    font-weight: 600;
}

.nav-parent .nav-arrow {
    margin-right: auto;
    margin-left: 0;
    font-size: 12px;
    width: auto;
    transition: transform 0.3s ease;
    opacity: 0.7;
}

.nav-group.open .nav-parent .nav-arrow {
    transform: rotate(180deg);
}

.nav-group.open .nav-parent {
    background-color: rgba(245, 124, 0, 0.18);
    color: var(--white);
}

.nav-children {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
    background-color: rgba(0, 0, 0, 0.20);
}

.nav-group.open .nav-children {
    max-height: 800px;
}

.nav-child {
    padding: 11px 25px 11px 25px;
    padding-right: 50px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.75);
    border-right: 3px solid transparent;
}

.nav-child i {
    font-size: 14px;
    width: 22px;
    margin-left: 10px;
}

.nav-child span {
    font-size: 14px;
    font-weight: 400;
}

.nav-child:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--white);
    border-right-color: var(--primary-color);
}

.nav-child.active {
    background-color: rgba(245, 124, 0, 0.25);
    color: var(--white);
    border-right-color: var(--primary-color);
}

.nav-logout {
    margin-top: 15px;
    color: #ff6b6b !important;
}

.nav-logout:hover {
    background-color: rgba(244, 67, 54, 0.15) !important;
    border-right-color: #f44336 !important;
}

/* ========================================
   Main Content
======================================== */
.main-content {
    margin-right: 260px;
    min-height: 100vh;
    transition: margin-right 0.3s ease;
}

/* ========================================
   Header
======================================== */
.header {
    background: var(--white);
    padding: 20px 30px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-dark);
    cursor: pointer;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}
.header-title h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--secondary-color);
}
.btn-open-window {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px 8px;
    font-size: 14px;
    color: #666;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.btn-open-window:hover {
    opacity: 1;
    color: #2196f3;
    border-color: #2196f3;
}

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

.btn-icon {
    position: relative;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--light-bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: var(--primary-color);
    color: var(--white);
}

.btn-icon i {
    font-size: 18px;
}

.btn-icon.btn-success { background: #4caf50; color: #fff; }
.btn-icon.btn-success:hover { background: #388e3c; }
.btn-icon.btn-danger { background: #f44336; color: #fff; }
.btn-icon.btn-danger:hover { background: #d32f2f; }
.btn-icon.btn-warning { background: #ff9800; color: #fff; }
.btn-icon.btn-warning:hover { background: #f57c00; }
.btn-icon.btn-info { background: #2196f3; color: #fff; }
.btn-icon.btn-info:hover { background: #1976d2; }
.btn-icon.btn-secondary { background: #9e9e9e; color: #fff; }
.btn-icon.btn-secondary:hover { background: #757575; }

.badge {
    position: absolute;
    top: 5px;
    left: 5px;
    background: var(--danger-color);
    color: var(--white);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* ========================================
   Content Area
======================================== */
.content {
    padding: 30px;
}

/* ========================================
   Cards
======================================== */
.card {
    background: var(--white);
    border-radius: 10px;
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

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

.card-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title i {
    color: var(--primary-color);
}

/* ========================================
   Stats Cards
======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    border-radius: 10px;
    padding: 25px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--white);
}

.stat-icon.primary {
    background: linear-gradient(135deg, var(--primary-color), #ff9800);
}

.stat-icon.success {
    background: linear-gradient(135deg, var(--success-color), #66bb6a);
}

.stat-icon.danger {
    background: linear-gradient(135deg, var(--danger-color), #e57373);
}

.stat-icon.info {
    background: linear-gradient(135deg, var(--info-color), #64b5f6);
}

.stat-content h3 {
    font-size: 14px;
    color: var(--text-light);
    font-weight: 500;
    margin-bottom: 5px;
}

.stat-content .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-dark);
}

.stat-content .stat-change {
    font-size: 13px;
    margin-top: 5px;
}

.stat-change.positive {
    color: var(--success-color);
}

.stat-change.negative {
    color: var(--danger-color);
}

/* ========================================
   Buttons
======================================== */
.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Cairo', sans-serif;
}

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

.btn-primary:hover {
    background: #e67100;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 124, 0, 0.3);
}

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

.btn-secondary:hover {
    background: #003832;
    transform: translateY(-2px);
}

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

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: var(--white);
}

.btn-warning {
    background: #ff9800;
    color: #fff;
}

.btn-warning:hover {
    background: #f57c00;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.btn-info {
    background: #2196f3;
    color: #fff;
}

.btn-info:hover {
    background: #1976d2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.btn-light {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #e0e0e0;
}

.btn-light:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
}

/* ========================================
   Forms
======================================== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 15px;
    font-family: 'Cairo', sans-serif;
    transition: border-color 0.3s ease;
}

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

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
    width: 100%;
}

/* حقل البيان - عرض كامل */
textarea#invoiceNotes,
textarea#voucherDescription,
textarea#entryDescription,
textarea#returnNotes,
textarea#customerNotes,
textarea#supplierNotes,
textarea#quotationNotes {
    width: 100%;
    min-height: 80px;
}

/* عمود البيان في الجداول - عرض مفتوح */
.table td.description-cell,
.table td:has(.description-field),
td.bayan-cell {
    max-width: none !important;
    white-space: normal !important;
    word-break: break-word !important;
    min-width: 250px;
}

/* تحسين عرض البيان في كشوفات الحساب */
.table th:nth-child(2),
.table td:nth-child(2):has(a[onclick*="show"]) {
    width: auto !important;
    min-width: 250px !important;
    max-width: none !important;
    white-space: normal !important;
    word-break: break-word !important;
}

/* ========================================
   Tables
======================================== */
.table-responsive {
    overflow-x: auto;
    margin-top: 20px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

.table thead {
    background: var(--secondary-color);
    color: var(--white);
}

.table th {
    padding: 15px;
    text-align: right;
    font-weight: 600;
    font-size: 14px;
}

.table td {
    padding: 15px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.table tbody tr:hover {
    background-color: rgba(245, 124, 0, 0.05);
}

/* ========================================
   Action Buttons in Tables
======================================== */
.action-btns {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 4px;
}

.btn-edit {
    background: var(--info-color);
    color: var(--white);
    border: none;
    cursor: pointer;
}

.btn-delete {
    background: var(--danger-color);
    color: var(--white);
    border: none;
    cursor: pointer;
}

.btn-view {
    background: var(--success-color);
    color: var(--white);
    border: none;
    cursor: pointer;
}

.btn-print {
    background: var(--warning-color);
    color: var(--white);
    border: none;
    cursor: pointer;
}

/* ========================================
   Modal
======================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    right: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--white);
    border-radius: 10px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--secondary-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--danger-color);
    color: var(--white);
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 2px solid var(--light-bg);
    display: flex;
    justify-content: flex-start;
    gap: 10px;
}

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

.alert i {
    font-size: 20px;
}

.alert-success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border-right: 4px solid var(--success-color);
}

.alert-danger {
    background-color: #ffebee;
    color: #c62828;
    border-right: 4px solid var(--danger-color);
}

.alert-warning {
    background-color: #fff3e0;
    color: #e65100;
    border-right: 4px solid var(--warning-color);
}

.alert-info {
    background-color: #e3f2fd;
    color: #1565c0;
    border-right: 4px solid var(--info-color);
}

/* ========================================
   Print Styles
======================================== */
@media print {
    .sidebar,
    .header,
    .btn,
    .action-btns {
        display: none !important;
    }

    .main-content {
        margin-right: 0;
    }

    .content {
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
    
    /* ضمان ظهور التفقيط في الطباعة */
    .amount-in-words,
    [style*="المبلغ بالحروف"] {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        page-break-inside: avoid;
    }
    
    /* تحسين عرض الشركة */
    .company-header {
        page-break-after: avoid;
    }
    
    /* تحسين عرض المحتوى */
    body {
        background: white !important;
    }
}

/* ========================================
   Responsive Design
======================================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0;
    }

    .menu-toggle {
        display: block;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .header-title h1 {
        font-size: 18px;
    }

    .content {
        padding: 15px;
    }

    .modal-content {
        width: 95%;
    }
}

/* ========================================
   Utility Classes
======================================== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }

.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }

.d-flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.gap-1 { gap: 10px; }
.gap-2 { gap: 20px; }

.hidden {
    display: none;
}

/* ========================================
   Loading Spinner
======================================== */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--light-bg);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 50px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Company Footer for Prints
======================================== */
.company-header,
.company-footer {
    text-align: center;
    padding: 20px;
    border-bottom: 3px solid var(--primary-color);
}

.company-footer {
    border-bottom: none;
    border-top: 3px solid var(--primary-color);
    margin-top: 30px;
}

.company-logo {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.company-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 5px;
}

.company-subtitle {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 15px;
}

.company-contacts {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-light);
}

.company-contacts i {
    color: var(--primary-color);
    margin-left: 5px;
}
/* ========================================
   أنماط الطباعة الموحدة (السندات والكشوفات)
======================================== */
.doc-print-container {
    max-width: 850px;
    margin: 0 auto;
    background: white;
}

.voucher-band {
    background: var(--secondary-color);
    color: white;
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    padding: 12px;
    border-radius: 8px;
    margin: 15px 0;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.info-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.info-box {
    flex: 1;
    border-radius: 10px;
    padding: 15px 20px;
}

.info-box .lbl {
    font-size: 11px;
    color: #777;
    display: block;
    margin-bottom: 4px;
    text-transform: uppercase;
    font-weight: 600;
}

.info-box .val {
    font-size: 16px;
    font-weight: 700;
    color: #222;
}

.info-box .val-sm {
    font-size: 12px;
    color: #666;
    display: block;
    margin-top: 3px;
}

.box-right {
    background: #f1f8e9;
    border-right: 5px solid var(--success-color);
}

.box-left {
    background: #f5f5f5;
    border-left: 5px solid #9e9e9e;
    text-align: left;
    direction: ltr;
}

.amount-section {
    background: #fff8e1;
    border: 2px solid var(--warning-color);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin: 20px 0;
}

.amount-big {
    font-size: 32px;
    font-weight: 900;
    color: var(--secondary-color);
    margin-bottom: 10px;
}

.tafqit {
    font-size: 15px;
    font-weight: 700;
    color: #5d4037;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    padding: 8px 15px;
    display: inline-block;
}

.signatures {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    text-align: center;
    margin-top: 50px;
}

.sign-line {
    border-top: 2px solid #555;
    padding-top: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

@media print {
    .voucher-band {
        background-color: var(--secondary-color) !important;
        -webkit-print-color-adjust: exact;
    }
    .box-right { background-color: #f1f8e9 !important; -webkit-print-color-adjust: exact; }
    .box-left { background-color: #f5f5f5 !important; -webkit-print-color-adjust: exact; }
    .amount-section { background-color: #fff8e1 !important; -webkit-print-color-adjust: exact; }
}

