/**
 * assets/css/style.css - الأنماط الرئيسية
 * @version 6.0
 */

:root {
    --bg-primary: #071810;
    --bg-secondary: #0e2419;
    --bg-tertiary: #14392c;
    --bg-card: #0c2016;
    --border: #1d3d2e;
    --text-primary: #f6f7f9;
    --text-secondary: #c3cdc7;
    --text-muted: #7c9186;
    --gold: #c9a84c;
    --gold-light: #ddc06e;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --primary: #14392c;
    --primary-dark: #0a2218;
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 14px;
    --transition: 0.25s cubic-bezier(.4,0,.2,1);
}

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

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    direction: rtl;
    min-height: 100vh;
}

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

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    padding: 20px;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    right: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    z-index: 1000;
    padding: 20px 0;
    transition: transform var(--transition);
}
.sidebar-brand {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 15px;
    text-align: center;
}
.sidebar-brand h2 {
    color: var(--gold);
    font-size: 18px;
}
.sidebar-brand small {
    color: var(--text-muted);
    font-size: 12px;
}
.sidebar-menu {
    list-style: none;
    padding: 0;
}
.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-secondary);
    transition: all var(--transition);
    border-right: 3px solid transparent;
    font-size: 14px;
}
.sidebar-menu li a:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-right-color: var(--primary);
}
.sidebar-menu li a.active {
    background: var(--bg-tertiary);
    color: var(--primary);
    border-right-color: var(--primary);
}
.sidebar-menu .menu-label {
    padding: 12px 20px 6px;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
}

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    border-radius: var(--radius);
    flex-wrap: wrap;
}
.topbar .page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}
.topbar .page-title i {
    color: var(--gold);
    margin-left: 10px;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}
.card-header h3 {
    font-size: 16px;
    color: var(--text-primary);
}
.card-header h3 i {
    color: var(--gold);
    margin-left: 8px;
}
.card-body {
    padding: 20px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #0284c7; transform: translateY(-2px); box-shadow: 0 4px 15px rgba(14,165,233,0.3); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-secondary); }
.btn-secondary:hover { background: var(--border); color: var(--text-primary); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 8px; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-info { background: rgba(14,165,233,0.15); color: var(--info); }
.badge-primary { background: rgba(14,165,233,0.15); color: var(--primary); }
.badge-secondary { background: rgba(100,116,139,0.15); color: var(--text-muted); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    transition: all var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14,165,233,0.1);
}
.form-group .ltr-input { direction: ltr; text-align: left; }
.form-group .text-muted {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Tables */
.table-wrapper { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th {
    padding: 12px 16px;
    text-align: right;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}
.data-table tr:hover td { background: var(--bg-secondary); }
.data-table .ltr-num { direction: ltr; text-align: right; }

/* Expiry */
.expiry-danger { color: var(--danger) !important; font-weight: 600; }
.expiry-warning { color: var(--warning) !important; font-weight: 600; }
.expiry-expired { color: var(--danger) !important; font-weight: 700; text-decoration: line-through; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 56px; opacity: 0.3; margin-bottom: 20px; }
.empty-state h3 { font-size: 20px; color: var(--text-secondary); margin-bottom: 10px; }

/* Spinner */
.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 8px; padding: 15px; border-top: 1px solid var(--border); }
.pagination button {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
}
.pagination button:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    padding: 14px 20px;
    border-radius: var(--radius);
    color: #fff;
    font-size: 14px;
    min-width: 250px;
    animation: slideInRight 0.3s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Loading Overlay */
#loadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10,14,23,0.7);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}
#loadingOverlay .spinner {
    width: 50px;
    height: 50px;
    border-width: 4px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: var(--bg-card);
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}
.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header .close {
    font-size: 28px;
    cursor: pointer;
}
.modal-body { padding: 20px; }

/* Responsive */
@media (max-width: 992px) {
    .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-right: 0; }
    .topbar { padding: 12px 16px; }
}
@media (max-width: 576px) {
    .topbar .page-title { font-size: 16px; }
    .card-header { flex-direction: column; align-items: flex-start; }
    .data-table th, .data-table td { padding: 8px 10px; font-size: 12px; }
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp 0.4s ease; }

/* Chat */
.chat-item:hover { background: var(--bg-secondary); }
.message { animation: fadeInUp 0.3s ease; }
.message.sent { border-bottom-left-radius: 4px; align-self: flex-end; background: var(--primary); color: #fff; }
.message.received { border-bottom-right-radius: 4px; align-self: flex-start; background: var(--bg-secondary); }

/* Calendar */
.calendar-day:hover { background: var(--bg-secondary) !important; }
.calendar-grid { direction: rtl; }

/* Signature Canvas */
#signatureCanvas {
    width: 100%;
    height: 200px;
    background: #fff;
    border-radius: 8px;
    border: 2px solid var(--border);
    cursor: crosshair;
    touch-action: none;
}
