/* Main CSS Variables for Al-Wafa System */
/* Main CSS Variables for Al-Wafa System */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #f59e0b;
    /* Amber for highlights */
    --success-color: #10b981;
    --danger-color: #ef4444;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --sidebar-width: 260px;
    --header-height: 64px;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

[data-theme="dark"] {
    --bg-color: #111827;
    --card-bg: #1f2937;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border-color: #374151;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

/* Ensure inputs and tables look good in dark mode */
[data-theme="dark"] .form-control,
[data-theme="dark"] .table-mobile-cards tbody tr,
[data-theme="dark"] .sidebar,
[data-theme="dark"] .top-bar,
[data-theme="dark"] .bottom-nav {
    background-color: var(--card-bg) !important;
    color: var(--text-main) !important;
    border-color: var(--border-color);
}

[data-theme="dark"] .nav-link,
[data-theme="dark"] .nav-group-header {
    color: var(--text-main);
}

/* Fix theme toggle icon visibility in dark mode */
[data-theme="dark"] #theme-icon {
    color: #ffffff !important;
}

[data-theme="dark"] .nav-link:hover,
[data-theme="dark"] .nav-link.active,
[data-theme="dark"] .nav-group-header:hover {
    background-color: #374151;
    color: var(--primary-color);
}

[data-theme="dark"] .table-mobile-cards tbody td {
    border-bottom-color: var(--border-color);
}

/* RTL Support for Arabic */
body {
    direction: rtl;
    text-align: right;
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
}

* {
    box-sizing: border-box;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0;
    font-weight: 600;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

/* Utilities */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    width: 100% !important;
    margin: 0 !important;
    max-width: 100%;
    clear: both;
}

.table-responsive {
    width: 100% !important;
    margin: 0 !important;
    border: none !important;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Login Page Styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-title {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* Live Search Component */
.search-wrapper {
    position: relative;
    width: 100%;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    display: none;
    /* Hidden by default */
}

.search-results.show {
    display: block;
}

.search-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-item:hover,
.search-item.focused {
    background-color: #eff6ff;
    color: var(--primary-color);
}

.search-item .item-name {
    font-weight: 600;
}

.search-item .item-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Dark Mode Search Overrides */
[data-theme="dark"] .search-results {
    background: var(--card-bg);
    border-color: var(--border-color);
}

[data-theme="dark"] .search-item {
    border-bottom-color: var(--border-color);
    color: var(--text-main);
}

[data-theme="dark"] .search-item:hover,
[data-theme="dark"] .search-item.focused {
    background-color: rgba(37, 99, 235, 0.2);
    color: var(--primary-color);
}

/* Layout Styles */
.layout-container {
    display: block;
    /* Simplified: No flexbox */
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--card-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    /* Fixed prevents scrolling issues and overlay problems */
    height: 100vh;
    right: 0;
    /* Align to right side */
    top: 0;
    z-index: 100;
    /* Ensure it stays above content if needed, but below overlays */
    flex-shrink: 0;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
    padding: 0 1rem;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-menu {
    list-style: none;
    padding: 1rem 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-main);
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    background-color: #eff6ff;
    color: var(--primary-color);
    border-right: 3px solid var(--primary-color);
}

.nav-icon {
    font-size: 1.25rem;
    margin-left: 0.75rem;
}

/* Navigation Groups (Collapsible) */
.nav-group-header {
    padding: 0.75rem 1.5rem;
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.2s;
}

.nav-group-header:hover {
    background-color: #f3f4f6;
}

.nav-group-content {
    display: none;
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .nav-group-content {
    background-color: #1f2937;
    /* Darker than main sidebar or same as card-bg */
}

.nav-group.active .nav-group-content {
    display: block;
}

.nav-group.active .nav-group-header {
    color: var(--primary-color);
}

.nav-group-icon {
    font-size: 1.25rem;
    margin-left: 0.75rem;
    color: var(--text-muted);
}

.nav-group.active .nav-group-icon {
    color: var(--primary-color);
}

.chevron-icon {
    font-size: 1rem;
    transition: transform 0.3s;
}

.nav-group.active .chevron-icon {
    transform: rotate(180deg);
}

.nav-link.sub-link {
    padding-right: 3rem;
    font-size: 0.95em;
}

/* Main Content Styling */
/* Main Content Styling */
/* Main Content Styling */
/* Main Content Styling */
/* Main Content Styling */
/* Main Content Styling */
/* Layout Container */
.layout-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Main Content Styling */
.main-content {
    margin-right: var(--sidebar-width) !important;
    padding: 0;
    flex: 1;
    width: auto;
    min-height: 100vh;
}

/* Dashboard Grids */
.dashboard-grid,
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    width: 100%;
    margin-bottom: 2rem;
}

.panel,
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    width: 100%;
}

/* Child margins reset REMOVED */

.top-bar {
    background: var(--card-bg);
    height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    margin-bottom: 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
    width: 100%;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    font-size: 1.8rem;
    cursor: pointer;
}

/* Mobile Adjustments */
@media (max-width: 768px) {

    /* Hide Side Bar */
    .sidebar {
        display: none;
    }

    /* Reset Content Margin */
    .main-content {
        margin-right: 0 !important;
        /* Override inline styles if any */
        width: 100%;
        padding: 1rem;
    }

    /* Adjust Header */
    .top-bar {
        padding: 0 1rem;
    }

    .top-bar h2 {
        font-size: 1.1rem;
    }

    /* Better Touch Targets */
    .btn,
    .form-control,
    .nav-link {
        min-height: 44px;
        /* Standard touch target size */
    }
}

/* Side Modal / Drawer Style */
.side-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    /* High z-index to stay on top */
    display: none;
    justify-content: flex-end;
    /* Align to right? or left depending on direction */
    /* Check direction: body is RTL, so flex-start is Right. */
    /* Let's force explicit positioning to avoid confusion */
    align-items: flex-start;
    direction: ltr;
    /* Wrapper is LTR so 'right' is right visually */
}

.side-modal-overlay.active {
    display: flex;
}

.side-modal {
    background: var(--card-bg);
    width: 100%;
    max-width: 500px;
    height: 100vh;
    padding: 2rem;
    overflow-y: auto;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    position: relative;
    animation: slideInRight 0.3s ease-out;
    border-right: 1px solid var(--border-color);
    margin-left: auto;
    /* Push to right */
    direction: rtl;
    /* Content inside is RTL again */
}

/* Close Button Position */
.side-modal-close {
    position: absolute;
    top: 1rem;
    left: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    background: transparent;
    border: none;
    color: var(--text-muted);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .side-modal {
        max-width: 100%;
    }
}