/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

:root {
    --primary-color: #0f172a;      /* Slate 900 */
    --primary-light: #1e293b;    /* Slate 800 */
    --secondary-color: #3b82f6;    /* Blue 500 */
    --secondary-hover: #2563eb;    /* Blue 600 */
    --accent-color: #10b981;       /* Emerald 500 */
    --bg-color: #f1f5f9;           /* Slate 100 */
    --text-color: #334155;         /* Slate 700 */
    --sidebar-width: 280px;
    --header-height: 75px;
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --transition-speed: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Cairo', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    direction: rtl;
    /* Arabic support */
    text-align: right;
    display: flex;
    /* Required for sidebar layout */
    flex-direction: column;
    /* Default to column for mobile/login */
}

/* Sidebar Layout (Desktop) */
@media (min-width: 769px) {
    body.dashboard-body {
        flex-direction: row;
        /* Sidebar next to content */
    }
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    height: 100vh;
    position: fixed;
    right: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 100;
    transition: transform var(--transition-speed);
    overflow-y: auto;
}

.sidebar-header {
    height: var(--header-height);
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.02);
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1rem;
}

.sidebar-menu ul {
    list-style: none;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 5px;
    color: #cbd5e1;
    text-decoration: none;
    transition: var(--transition-speed);
    font-weight: 600;
    border-radius: 10px;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--secondary-color);
}

.sidebar-menu a.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0) 100%);
    border-right: 4px solid var(--secondary-color);
}

.sidebar-menu .menu-heading {
    color: #64748b !important;
    font-size: 0.75rem !important;
    font-weight: 700;
    margin-top: 1.5rem !important;
    margin-bottom: 0.5rem;
    padding-right: 15px !important;
}

.sidebar-menu i {
    margin-left: 10px;
    width: 20px;
    text-align: center;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-right var(--transition-speed);
}

@media (min-width: 769px) {
    .main-content {
        margin-right: var(--sidebar-width);
    }
}

/* Header */
header {
    height: var(--header-height);
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 90;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

/* Content Wrapper */
.content-wrapper {
    padding: 2rem;
    flex: 1;
    /* Pushes footer down */
}

/* Dashboard Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    background-color: rgba(237, 137, 54, 0.1);
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-info h3 {
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 0.5rem;
}

.stat-info p {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Forms */
.form-container,
.card {
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 600;
}

.form-control,
select.form-control,
textarea.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    background-color: #fff;
}

.form-control:focus {
    border-color: var(--secondary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(237, 137, 54, 0.2);
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    text-decoration: none;
    display: inline-block;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #2d3748;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #dd6b20;
}

.btn-danger {
    background-color: #e53e3e;
    color: white;
}

.btn-danger:hover {
    background-color: #c53030;
}

/* Tables */
.table-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 1rem;
    margin-bottom: 2rem;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
    /* Prevent wrapping on small screens */
}

th,
td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background-color: #f7fafc;
    color: var(--primary-color);
    font-weight: 700;
}

tr:hover {
    background-color: #f8f9fa;
}

/* Login Page (Auth) */
body.auth-body {
    background-color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    flex-direction: column;
}

.auth-page {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.auth-card {
    background: white;
    padding: 3rem;
    border-radius: 16px;
    width: 100%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.auth-header {
    margin-bottom: 2rem;
}

.auth-header h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* Footer */
.main-footer {
    padding: 1rem;
    background: #fff;
    width: 100%;
    margin-top: auto;
    /* Sticky footer */
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
        /* Hide sidebar */
        right: 0;
    }

    .sidebar.active {
        transform: translateX(0);
        /* Show sidebar */
    }

    .main-content {
        margin-right: 0;
    }

    header {
        padding: 0 1rem;
    }

    #sidebarToggle {
        display: block !important;
        background: none;
        color: var(--primary-color);
        font-size: 1.5rem;
        cursor: pointer;
        border: none;
    }

    .content-wrapper {
        padding: 1rem;
    }

    .stat-card {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
}

/* Print Styles */
@media print {

    .no-print,
    .sidebar,
    #sidebarToggle,
    header,
    .btn,
    .btn-sm,
    .btn-primary,
    .btn-secondary,
    .btn-danger,
    button {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
    }

    .main-footer {
        position: fixed;
        bottom: 0;
        width: 100%;
        border-top: 1px solid #000;
    }

    body {
        background: #fff;
        color: #000;
    }

    .card,
    .table-container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}