/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

:root {
    --primary: #1e3a8a;
    /* Dark Blue */
    --primary-light: #3b82f6;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 0.5rem;
}

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

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--background);
    color: var(--text);
    direction: rtl;
    text-align: right;
    height: 100vh;
    overflow-x: hidden;
}

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

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--background);
}

.page-content {
    padding: 2rem;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    height: 100%;
}

.sidebar-header {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 2rem;
    text-align: center;
    border-bottom: 2px solid var(--border);
    padding-bottom: 1rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
    background-color: var(--primary);
    color: white;
}

.nav-link i {
    margin-left: 0.75rem;
}

.sidebar-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

.sidebar-section-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 0.5rem 1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Navbar */
.top-navbar {
    height: 64px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.user-profile {
    display: flex;
    align-items: center;
    font-weight: 600;
}

/* Auth Page */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, #1e293b 100%);
}

.auth-card {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

/* Components */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--primary-light);
}

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

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

.form-group {
    margin-bottom: 1rem;
    text-align: right;
}

.label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    outline: none;
}

.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

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

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.table th,
.table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: right;
}

.table th {
    background-color: #f8fafc;
    font-weight: 600;
}

/* Grid System helper */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .main-content {
        width: 100%;
    }

    /* Sidebar Mobile Styles */
    .sidebar {
        position: fixed;
        right: 0;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 1000;
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
        display: flex;
        overflow-y: auto;
        /* Override display: none from previous if exists */
    }

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

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }

    .sidebar-overlay.visible {
        display: block;
    }

    .sidebar-close-btn {
        display: block !important;
        position: absolute;
        left: 1rem;
        top: 1.5rem;
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text-muted);
        cursor: pointer;
    }

    /* Toggle Button */
    .mobile-toggle {
        display: inline-flex !important;
        background: none;
        border: none;
        font-size: 1.25rem;
        color: var(--text);
        cursor: pointer;
        padding: 0.5rem;
        margin-left: 0.5rem;
    }

    /* Navbar adjustments */
    .top-navbar {
        padding: 0 1rem;
    }

    /* Grids */
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    /* Page Content */
    .page-content {
        padding: 1rem;
    }

    /* Adjust cards for mobile */
    .card {
        padding: 1rem;
    }
}

/* Base styles for elements hidden on desktop */
.mobile-toggle {
    display: none;
}

.sidebar-close-btn {
    display: none;
}

.sidebar-overlay {
    display: none;
}