/* ============================================================
   TOYA STORE - تصميم احترافي باستخدام Fixed Layout
   ============================================================ */
* { font-family: 'Cairo', sans-serif; box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    height: 100%;
    background: #f0f2f5;
    font-size: 14px;
    direction: rtl;
    overflow-x: hidden;
}

/* Navbar - ثابت في الأعلى */
.navbar {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    height: 56px;
    position: fixed; top: 0; right: 0; left: 0;
    z-index: 1050;
    display: flex; align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.navbar .container-fluid { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.navbar-brand { font-weight: 700; font-size: 20px; color: #fff !important; text-decoration: none; display: flex; align-items: center; gap: 8px; min-width: 0; }
.navbar-company-logo { width: 30px; height: 30px; object-fit: contain; background: #fff; border-radius: 6px; padding: 3px; flex: 0 0 auto; }
.navbar-program-title {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0;
    white-space: nowrap;
    pointer-events: none;
}

/* School procurement modules */
.app-footer { padding: 20px 0 4px; text-align: center; color: #7a8695; font-size: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: #fff; border-radius: 15px; padding: 20px; box-shadow: 0 2px 10px rgba(0,0,0,.08); border-right: 4px solid #2a5298; }
.stat span { display: block; color: #687386; font-size: 12px; font-weight: 600; }
.stat strong { display: block; margin-top: 8px; color: #1e3c72; font-size: 26px; }
.workflow { display: flex; flex-wrap: wrap; gap: 8px; }
.workflow span { padding: 8px 12px; border-radius: 8px; background: #e8f0fe; color: #1e3c72; font-size: 12px; font-weight: 600; }
.required:after { content: " *"; color: #dc3545; }
.badge { padding: 6px 9px; }
.table > :not(caption) > * > * { padding: 11px 10px; vertical-align: middle; }
.table thead th { color: #1e3c72; background: #f7f9fc; white-space: nowrap; }
[dir="ltr"] .sidebar { right: auto; left: 0; }
[dir="ltr"] .main-content { margin-right: 0 !important; margin-left: 260px !important; }
[dir="ltr"] .sidebar.collapsed { right: auto; left: -260px; }
[dir="ltr"] .main-content.sidebar-collapsed { margin-left: 0 !important; }

@media (max-width: 900px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .navbar-program-title { display: none; }
}
@media (max-width: 560px) {
    .stat-grid { grid-template-columns: 1fr; }
    .page-header { align-items: flex-start !important; gap: 12px; flex-direction: column; }
    .page-header .btn { margin-top: 4px; }
}
.navbar .btn-link { color: #fff !important; background: none; border: none; padding: 0; text-decoration: none; }

/* Sidebar - ثابت على اليمين */
.sidebar {
    position: fixed; top: 56px; right: 0; bottom: 0;
    width: 260px;
    background: #fff;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 1040;
    overflow-y: auto;
    transition: right 0.3s ease;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 56px 0 0 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1035;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }

.sidebar-header {
    padding: 20px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #fff;
    text-align: center;
}
.user-avatar-lg {
    width: 60px; height: 60px;
    margin: 0 auto 10px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
}
.sidebar-company-logo,
.sidebar-profile-image {
    width: 72px;
    height: 72px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 14px;
    overflow: hidden;
    font-size: 34px;
}
.sidebar-company-logo img,
.sidebar-profile-image img { width: 100%; height: 100%; background: #fff; }
.sidebar-profile-image.has-user-avatar img { object-fit: cover; padding: 0; }
.sidebar-company-logo img,
.sidebar-profile-image.has-company-logo img { object-fit: contain; padding: 6px; }
.sidebar-company-name,
.sidebar-profile-name { font-size: 16px; font-weight: 700; line-height: 1.35; margin: 0 0 8px; }

.sidebar-menu { padding: 10px 0; }
.sidebar-menu .nav-item { width: 100%; list-style: none; }
.sidebar-menu .nav-link {
    color: #555; padding: 12px 20px;
    border-right: 3px solid transparent;
    font-weight: 500; cursor: pointer;
    display: block; text-decoration: none; font-size: 14px;
    transition: all 0.3s;
}
.sidebar-menu .nav-link:hover { background: #f0f2f5; color: #1e3c72; border-right-color: #1e3c72; }
.sidebar-menu .nav-link.active { background: #e8f0fe; color: #1e3c72; border-right-color: #1e3c72; }
.menu-arrow { transition: transform 0.3s; }

.sub-menu {
    list-style: none; padding: 0; margin: 0;
    max-height: 0; overflow: hidden;
    transition: max-height 0.3s ease;
    background: #f9f9f9;
}
.sub-menu.show { max-height: 500px; }
.sub-menu li a {
    display: block; padding: 10px 40px;
    color: #666; text-decoration: none; font-size: 13px;
    transition: all 0.3s;
}
.sub-menu li a:hover { background: #e8f0fe; color: #1e3c72; padding-right: 45px; }
.sub-menu li a i { width: 20px; }

/* Main Content */
.main-content {
    margin-right: 260px !important;
    margin-top: 56px !important;
    padding: 20px !important;
    min-height: calc(100vh - 56px);
    transition: margin-right 0.3s ease;
    width: auto !important;
    max-width: none !important;
    float: none !important;
}
.sidebar.collapsed { right: -260px; }
.main-content.sidebar-collapsed { margin-right: 0 !important; }

/* Page Header */
.page-header {
    background: #fff; padding: 15px 20px;
    border-radius: 15px; margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.page-header h4 { margin: 0; font-weight: 700; color: #1e3c72; }
.page-header .breadcrumb { margin: 5px 0 0 0; background: transparent; padding: 0; }

/* Cards */
.card { border-radius: 15px; border: none; box-shadow: 0 2px 10px rgba(0,0,0,0.08); margin-bottom: 20px; background: #fff; }
.card-header { background: #fff; border-bottom: 2px solid #f0f2f5; padding: 15px 20px; border-radius: 15px 15px 0 0 !important; font-weight: 600; }
.card-body { padding: 20px; }

/* Stat Cards */
.stat-card { border-radius: 15px; border: none; background: #fff; margin-bottom: 0; }

/* Buttons */
.btn { border-radius: 8px; padding: 8px 20px; font-weight: 600; font-size: 13px; display: inline-block; border: none; text-decoration: none; cursor: pointer; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 30px; font-size: 16px; }
.btn-primary { background: linear-gradient(135deg, #1e3c72, #2a5298); color: #fff; }
.btn-success { background: linear-gradient(135deg, #28a745, #20c997); color: #fff; }
.btn-danger { background: linear-gradient(135deg, #dc3545, #e74c3c); color: #fff; }
.btn-info { background: linear-gradient(135deg, #17a2b8, #0dcaf0); color: #fff; }
.btn-warning { background: linear-gradient(135deg, #ffc107, #fd7e14); color: #fff; }
.btn-secondary { background: #6c757d; color: #fff; }

/* Forms */
.form-control, .form-select {
    border-radius: 8px; border: 2px solid #e0e0e0;
    padding: 8px 12px; font-size: 13px; width: 100%;
}
.form-control:focus, .form-select:focus { border-color: #1e3c72; box-shadow: 0 0 0 0.2rem rgba(30,60,114,0.15); outline: none; }
.form-label { font-weight: 600; color: #555; font-size: 13px; margin-bottom: 5px; display: block; }
.form-control-sm { padding: 5px 8px; font-size: 12px; }

.smart-input-wrap {
    position: relative;
    width: 100%;
}

.smart-typing-input {
    min-height: 42px;
    padding-right: 42px !important;
    padding-left: 42px !important;
    border: 1px solid #d8e0ea !important;
    border-radius: 8px !important;
    background: #fff !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.smart-typing-input:focus {
    border-color: #1e3c72 !important;
    box-shadow: 0 0 0 0.2rem rgba(30,60,114,0.12) !important;
}

.smart-input-icon,
.smart-input-clear {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    color: #6c757d;
}

.smart-input-icon {
    right: 14px;
}

.smart-input-clear {
    left: 8px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    opacity: 0;
    pointer-events: none;
}

.smart-input-wrap.has-value .smart-input-clear {
    opacity: 1;
    pointer-events: auto;
}

.smart-input-clear:hover {
    background: #eef2f7;
    color: #1e3c72;
}

.smart-suggestions {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    z-index: 1060;
    display: none;
    max-height: 280px;
    overflow-y: auto;
    background: #1f1f1f;
    border: 1px solid #343a40;
    border-radius: 8px;
    box-shadow: 0 16px 34px rgba(0,0,0,0.22);
    padding: 6px;
}

.smart-suggestions.show {
    display: block;
}

.smart-suggestion-item {
    width: 100%;
    display: block;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #fff;
    text-align: right;
    padding: 10px 12px;
    font-weight: 600;
    line-height: 1.5;
}

.smart-suggestion-item:hover,
.smart-suggestion-item:focus {
    background: #2f65b8;
    color: #fff;
    outline: none;
}

.modern-table-search label {
    position: relative;
    display: block;
    margin-bottom: 12px;
}

.modern-table-search input[type="search"] {
    width: min(420px, 100%) !important;
    min-height: 42px;
    padding-right: 42px;
    padding-left: 42px;
    border: 1px solid #d8e0ea;
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.modern-table-search input[type="search"]:focus {
    border-color: #1e3c72;
    box-shadow: 0 0 0 0.2rem rgba(30,60,114,0.12);
}

.modern-table-search .table-search-icon,
.modern-table-search .table-search-clear {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    color: #6c757d;
}

.modern-table-search .table-search-icon {
    right: 14px;
}

.modern-table-search .table-search-clear {
    left: 8px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    opacity: 0;
    pointer-events: none;
}

.modern-table-search.has-value .table-search-clear {
    opacity: 1;
    pointer-events: auto;
}

.modern-table-search .table-search-clear:hover {
    background: #eef2f7;
    color: #1e3c72;
}

/* Tables */
.table-responsive { overflow-x: auto; border-radius: 8px; }
.table { width: 100%; font-size: 13px; border-collapse: collapse; }
.table thead th { background: #f8f9fa; border-bottom: 2px solid #dee2e6; color: #495057; font-weight: 600; font-size: 12px; white-space: nowrap; padding: 10px; text-align: right; }
.table td { padding: 10px; vertical-align: middle; border-bottom: 1px solid #f0f0f0; }
.table-hover tbody tr:hover { background: #f0f2f5; }
.table-bordered { border: 1px solid #dee2e6; }
.table-bordered th, .table-bordered td { border: 1px solid #dee2e6; }

/* Badges */
.badge { font-weight: 600; padding: 5px 10px; border-radius: 8px; font-size: 12px; display: inline-block; }
.bg-success { background: #28a745; color: #fff; }
.bg-danger { background: #dc3545; color: #fff; }
.bg-warning { background: #ffc107; color: #000; }
.bg-info { background: #17a2b8; color: #fff; }
.bg-primary { background: #1e3c72; color: #fff; }
.bg-secondary { background: #6c757d; color: #fff; }

/* Alerts */
.alert { border-radius: 10px; border: none; padding: 12px 20px; margin-bottom: 20px; }
.alert-success { background: #d4edda; color: #155724; }
.alert-danger { background: #f8d7da; color: #721c24; }
.alert-warning { background: #fff3cd; color: #856404; }
.alert-info { background: #d1ecf1; color: #0c5460; }

/* Invoice */
.invoice-total { background: #f8f9fa; padding: 20px; border-radius: 10px; }
.invoice-total table { width: 100%; }
.invoice-total table td { padding: 8px 10px; border: none; }
.invoice-total .grand-total { border-top: 2px solid #dee2e6; }

/* Quick Actions */
.quick-action-btn {
    display: block; padding: 15px;
    border-radius: 12px; border: 2px dashed #dee2e6;
    background: #fff; text-align: center;
    text-decoration: none; color: #555;
}
.quick-action-btn:hover { border-color: #1e3c72; background: #e8f0fe; color: #1e3c72; }
.quick-action-btn i { font-size: 30px; display: block; margin-bottom: 8px; }

/* Low Stock */
.low-stock { border-right: 4px solid #dc3545 !important; }

/* Modal */
.modal-content { border-radius: 15px; border: none; }
.modal-header { background: linear-gradient(135deg, #1e3c72, #2a5298); color: #fff; border-radius: 15px 15px 0 0; padding: 15px 20px; }
.modal-header .btn-close { filter: brightness(0) invert(1); }
.modal-body { padding: 20px; }
.modal-footer { padding: 15px 20px; border-top: 1px solid #dee2e6; }

/* Pagination */
.pagination { display: flex; justify-content: center; list-style: none; padding: 0; gap: 5px; }
.page-item .page-link { padding: 8px 15px; border-radius: 8px; border: 1px solid #dee2e6; color: #1e3c72; text-decoration: none; }
.page-item.active .page-link { background: linear-gradient(135deg, #1e3c72, #2a5298); color: #fff; border-color: #1e3c72; }
.page-item.disabled .page-link { color: #999; pointer-events: none; }

/* Dropdown */
.dropdown-menu { border-radius: 10px; border: none; box-shadow: 0 5px 30px rgba(0,0,0,0.15); padding: 10px 0; }
.dropdown-item { padding: 8px 20px; font-size: 13px; color: #555; text-decoration: none; display: block; }
.dropdown-item:hover { background: #f0f2f5; color: #1e3c72; }
.dropdown-divider { border-top: 1px solid #e0e0e0; margin: 5px 0; }

/* Responsive */
@media (max-width: 768px) {
    html, body { font-size: 13px; }
    body.sidebar-open { overflow: hidden; }
    .navbar { padding: 0 12px; }
    .navbar-brand { font-size: 16px; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .navbar-program-title { display: none; }
    .sidebar { right: -280px; width: 280px; }
    .sidebar.show { right: 0; }
    body.sidebar-open .sidebar-overlay { display: block; }
    .main-content {
        margin-right: 0 !important;
        margin-top: 56px !important;
        padding: 12px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .page-header {
        padding: 12px;
        border-radius: 10px;
        display: block !important;
    }
    .page-header h4 { font-size: 17px; line-height: 1.5; }
    .page-header .btn,
    .page-header a.btn,
    .page-header button { margin-top: 10px; width: 100%; }
    .card { border-radius: 10px; margin-bottom: 12px; }
    .card-body { padding: 12px; }
    .card-header { padding: 12px; border-radius: 10px 10px 0 0 !important; }
    .row { margin-right: -6px; margin-left: -6px; }
    [class*="col-"] { padding-right: 6px; padding-left: 6px; }
    .btn { padding: 8px 12px; white-space: normal; }
    .btn-lg { width: 100%; margin-bottom: 8px; }
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border: 1px solid #e9ecef;
    }
    .table { min-width: 760px; font-size: 12px; }
    .table td, .table th { padding: 8px; }
    .modal-dialog { margin: 8px; max-width: calc(100% - 16px); }
    .modal-body { padding: 12px; max-height: calc(100vh - 150px); overflow-y: auto; }
    .invoice-total { padding: 12px; }
    .dataTables_wrapper .row { gap: 8px; }
    .dataTables_filter input,
    .dataTables_length select { width: 100% !important; margin-top: 6px; }
    .modern-table-search input[type="search"] { width: 100% !important; }
}

@media (max-width: 480px) {
    .navbar-brand { max-width: 135px; }
    .quick-action-btn { padding: 12px 8px; }
    .stat-card h3, .stat-value { font-size: 20px; }
}

/* Print */
.system-print-header,
.system-print-audit { display: none; }

@media print {
    @page { size: A4 landscape; margin: 8mm; }
    * {
        color: #111 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    body {
        background: #fff !important;
        font-size: 11px;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
    }
    .system-print-header {
        display: flex !important;
        align-items: center;
        gap: 12px;
        padding-bottom: 10px;
        margin-bottom: 12px;
        border-bottom: 2px solid #222;
    }
    .system-print-header img {
        width: 54px;
        height: 54px;
        object-fit: contain;
    }
    .system-print-header h2 {
        font-size: 18px !important;
        font-weight: 700 !important;
        margin: 0 0 3px !important;
    }
    .system-print-header p {
        font-size: 12px !important;
        margin: 0 !important;
        color: #555 !important;
    }
    .system-print-audit {
        display: block !important;
        position: static !important;
        padding-top: 5px;
        margin-top: 10px;
        border-top: 1px solid #555;
        background: #fff !important;
        color: #111 !important;
        font-size: 10px;
        text-align: center;
    }
    .sidebar,
    .navbar,
    nav.navbar,
    #sidebar,
    #sidebarOverlay,
    #sidebarToggle,
    .sidebar-overlay,
    .no-print,
    form.row,
    .card-header .btn,
    .btn,
    .pagination,
    .dataTables_filter,
    .dataTables_length,
    .dataTables_info,
    .dataTables_paginate {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        min-width: 0 !important;
        min-height: 0 !important;
        max-width: 0 !important;
        max-height: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        inset: auto !important;
    }
    body > :not(.system-print-header):not(.system-print-audit):not(.main-content) {
        display: none !important;
        visibility: hidden !important;
    }
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: none !important;
        transform: none !important;
        position: static !important;
    }
    .page-header {
        border: 0 !important;
        padding: 0 0 8px !important;
        margin-bottom: 8px !important;
        background: #fff !important;
    }
    .page-header h4 {
        font-size: 18px !important;
        margin: 0 !important;
    }
    .breadcrumb { display: none !important; }
    .card {
        box-shadow: none !important;
        border: 0 !important;
        break-inside: avoid;
        margin-bottom: 8px !important;
    }
    .card-body,
    .card-header {
        padding: 0 !important;
        background: #fff !important;
        border: 0 !important;
    }
    .alert {
        border: 1px solid #ccc !important;
        background: #fff !important;
        padding: 6px !important;
        margin-bottom: 6px !important;
    }
    .table-responsive {
        overflow: visible !important;
        border: 0 !important;
    }
    table,
    .table {
        width: 100% !important;
        min-width: 0 !important;
        border-collapse: collapse !important;
        font-size: 10px !important;
    }
    .table th,
    .table td {
        border: 1px solid #999 !important;
        padding: 4px 5px !important;
        vertical-align: middle !important;
    }
    .table thead th,
    .table tfoot th {
        background: #f1f1f1 !important;
        font-weight: 700 !important;
    }
    a {
        color: #111 !important;
        text-decoration: none !important;
    }
    .badge {
        border: 1px solid #999 !important;
        background: #fff !important;
        padding: 2px 4px !important;
    }
}

/* Utility classes */
.text-primary { color: #1e3c72 !important; }
.text-success { color: #28a745 !important; }
.text-danger { color: #dc3545 !important; }
.text-warning { color: #ffc107 !important; }
.text-info { color: #17a2b8 !important; }
.text-muted { color: #888 !important; }
.text-center { text-align: center !important; }
.text-start { text-align: right !important; }
.text-end { text-align: left !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 5px !important; }
.mb-2 { margin-bottom: 10px !important; }
.mb-3 { margin-bottom: 15px !important; }
.mb-4 { margin-bottom: 20px !important; }
.mt-1 { margin-top: 5px !important; }
.mt-2 { margin-top: 10px !important; }
.mt-3 { margin-top: 15px !important; }
.mt-4 { margin-top: 20px !important; }
.me-1 { margin-left: 5px !important; }
.me-2 { margin-left: 10px !important; }
.me-3 { margin-left: 15px !important; }
.ms-1 { margin-right: 5px !important; }
.ms-2 { margin-right: 10px !important; }
.p-0 { padding: 0 !important; }
.px-0 { padding-right: 0 !important; padding-left: 0 !important; }
.px-4 { padding-right: 20px !important; padding-left: 20px !important; }
.px-5 { padding-right: 30px !important; padding-left: 30px !important; }
.d-flex { display: flex !important; }
.d-inline-block { display: inline-block !important; }
.flex-column { flex-direction: column !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-between { justify-content: space-between !important; }
.align-items-center { align-items: center !important; }
.w-100 { width: 100% !important; }
.shadow { box-shadow: 0 5px 30px rgba(0,0,0,0.15) !important; }
.position-relative { position: relative; }
.float-start { float: left !important; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.login-card { width: min(450px, 100%); padding: 30px; overflow: hidden; border-radius: 20px; background: #fff; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card h1 { color: #1e3c72; font-size: 26px; font-weight: 700; }
.login-card .btn-primary { width: 100%; padding: 12px; background: linear-gradient(135deg, #667eea, #764ba2); }
.supplier-shell { min-height: 100vh; background: #f0f2f5; }
.supplier-header { min-height: 64px; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; color: #fff; background: linear-gradient(135deg, #1e3c72, #2a5298); box-shadow: 0 2px 10px rgba(0,0,0,.1); }
.supplier-header a { color: #fff; }
.supplier-shell > .container { padding-top: 24px; padding-bottom: 24px; }
