@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

:root {
    --primary-color: #0ea5e9;
    --primary-hover: #0284c7;
    --secondary-color: #f8fafc;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --bg-color: #e2e8f0;
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --sidebar-bg: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.85);
    --border-color: #cbd5e1;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border-radius-sm: 8px;
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --table-header: rgba(248, 250, 252, 0.8);
    --input-bg: #ffffff;
}

.dark-theme {
    --secondary-color: #0f172a;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --bg-color: #020617;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #020617 100%);
    --sidebar-bg: #1e293b;
    --card-bg: rgba(30, 41, 59, 0.8);
    --border-color: #334155;
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --table-header: rgba(15, 23, 42, 0.9);
    --input-bg: #1e293b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image: var(--bg-gradient);
    color: var(--text-color);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Auth Pages */
.auth-body {
    align-items: center;
    justify-content: center;
}

.auth-container {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--border-radius-lg);
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-container h1 {
    color: var(--primary-color);
    margin-bottom: 2rem;
    font-weight: 800;
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    top: 0;
    right: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
}

.sidebar-header h2 {
    color: var(--primary-color);
    font-weight: 800;
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-links li {
    margin-bottom: 0.5rem;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.875rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s;
    font-weight: 500;
}

.nav-links a:hover,
.nav-links a.active {
    background-color: var(--primary-color);
    color: white;
}

.nav-links a i {
    font-size: 1.2rem;
    min-width: 24px;
    text-align: center;
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-color);
    cursor: pointer;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-right: 280px;
    padding: 2rem;
    padding-bottom: 2rem;
    transition: margin 0.3s ease, margin-right 0.3s ease;
    width: calc(100% - 280px);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: var(--glass-border);
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-color);
    cursor: pointer;
}

.user-info {
    font-weight: 600;
}

/* Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: var(--glass-border);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.icon-blue {
    background-color: rgba(14, 165, 233, 0.1);
    color: var(--primary-color);
}

.icon-green {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.icon-red {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.icon-yellow {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-details h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-details p {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-color);
}

.content-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: var(--glass-border);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.card-header {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
    text-align: right;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s;
    background-color: var(--input-bg);
    color: var(--text-color);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--table-header);
    font-weight: 700;
    color: var(--text-color);
}

tbody tr {
    transition: background-color 0.2s;
}

tbody tr:hover {
    background-color: rgba(var(--primary-color), 0.05);
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-in {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-out {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.badge-return {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

/* Alerts / Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
}

.toast {
    background: white;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 1rem 1.5rem;
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideIn 0.3s ease-out forwards;
    border-right: 4px solid var(--primary-color);
}

.toast.success {
    border-right-color: var(--success);
}

.toast.error {
    border-right-color: var(--danger);
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Filters */
.filters-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filters-row .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 200px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.5rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Loader */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    visibility: hidden;
    opacity: 0;
    transition: 0.2s;
}

.loader-overlay.active {
    visibility: visible;
    opacity: 1;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
/* Bottom Navigation */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-top: 1px solid var(--border-color);
    z-index: 1001;
    display: none;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    gap: 4px;
    flex: 1;
    height: 100%;
}

.bottom-nav-item i {
    font-size: 1.3rem;
}

.bottom-nav-item.active {
    color: var(--primary-color);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
        right: 0;
        left: auto;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .bottom-nav {
        display: flex;
    }

    .main-content {
        margin-right: 0;
        width: 100%;
        padding: 1rem;
        padding-bottom: 80px;
        /* Space for bottom nav */
    }

    .mobile-toggle {
        display: none;
        /* Hidden because we use 'More' in bottom nav */
    }

    .top-bar {
        padding: 0.75rem 1rem;
        position: sticky;
        top: 0;
        z-index: 997;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        z-index: 998;
        /* Just below sidebar */
        display: none;
        backdrop-filter: blur(4px);
    }

    .sidebar-overlay.active {
        display: block !important;
    }

    .sidebar-close {
        display: block;
    }

    .sidebar {
        z-index: 1000;
    }

    .mobile-toggle {
        display: block;
    }

    .filters-row {
        flex-direction: column;
    }

    .filters-row .form-group {
        width: 100%;
    }

    .filters-row .btn {
        width: 100%;
        margin-top: 0.5rem;
    }

    .invoice-box {
        padding: 15px;
        font-size: 14px;
    }

    .table-responsive table {
        font-size: 0.85rem;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .sidebar,
    .top-bar,
    .filters-row,
    .btn,
    .tabs,
    .mobile-toggle {
        display: none !important;
    }

    .main-content {
        margin: 0;
        padding: 0;
        width: 100%;
    }

    .content-card {
        box-shadow: none;
        border: none;
        padding: 0;
    }

    .card-header h2 {
        font-size: 1.5rem;
        text-align: center;
        width: 100%;
    }

    table {
        border: 1px solid #ccc;
    }

    th,
    td {
        padding: 8px;
        border: 1px solid #ccc;
        font-size: 12pt;
    }

    th {
        background-color: #f3f4f6 !important;
        -webkit-print-color-adjust: exact;
    }

    @page {
        margin: 1cm;
    }
}