:root {
    --primary-color: #0ea5e9;
    --primary-hover: #0284c7;
    --secondary-color: #f1f5f9;
    --text-color: #1e293b;
    --text-light: #64748b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Noto Nastaliq Urdu', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: 16px;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--text-color);
}

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

a:hover {
    color: var(--primary-hover);
}

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

.sidebar {
    width: 260px;
    background-color: var(--card-bg);
    border-left: 1px solid var(--border-color); /* For RTL */
    padding: 20px 0;
    box-shadow: var(--shadow);
    z-index: 10;
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    text-align: center;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.nav-links {
    list-style: none;
}

.nav-links li a {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: var(--text-color);
    font-weight: 500;
    font-size: 1.1rem;
}

.nav-links li a:hover, .nav-links li a.active {
    background-color: var(--secondary-color);
    color: var(--primary-color);
    border-right: 4px solid var(--primary-color);
}

.main-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-top: 4px solid var(--primary-color);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-card h3 {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-bottom: 10px;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
}

.stat-card.success { border-color: var(--success-color); }
.stat-card.danger { border-color: var(--danger-color); }

/* Forms & Inputs */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

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

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
    font-size: 1rem;
}

input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
    background-color: var(--bg-color);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-align: center;
    transition: var(--transition);
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 6px rgba(14, 165, 233, 0.2);
}

.primary-btn:hover {
    box-shadow: 0 6px 12px rgba(14, 165, 233, 0.3);
    transform: translateY(-2px);
    color: white;
}

.secondary-btn {
    background-color: var(--secondary-color);
    color: var(--text-color);
}

.secondary-btn:hover {
    background-color: #e2e8f0;
}

.btn-block {
    display: block;
    width: 100%;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th, td {
    padding: 16px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--secondary-color);
    font-weight: 600;
    color: var(--text-color);
    font-size: 1.1rem;
}

tbody tr:hover {
    background-color: rgba(14, 165, 233, 0.05);
}

/* Login Page Specific */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.8rem;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert.error {
    background-color: #fef2f2;
    color: var(--danger-color);
    border: 1px solid #fecaca;
}

.alert.success {
    background-color: #ecfdf5;
    color: var(--success-color);
    border: 1px solid #a7f3d0;
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }

.mobile-header {
    display: none;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        background-color: var(--card-bg);
        border-bottom: 1px solid var(--border-color);
        padding: 10px 15px;
        position: sticky;
        top: 0;
        z-index: 99;
        height: 60px;
    }
    
    .mobile-title {
        font-size: 1.2rem;
        font-weight: bold;
        color: var(--primary-color);
    }
    
    .menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 24px;
        height: 18px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        z-index: 100;
    }
    
    .menu-toggle span {
        width: 100%;
        height: 3px;
        background-color: var(--text-color);
        border-radius: 3px;
        transition: all 0.3s linear;
    }
    
    .menu-toggle.open span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .menu-toggle.open span:nth-child(2) {
        opacity: 0;
    }
    
    .menu-toggle.open span:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -6px);
    }
    
    .sidebar {
        position: fixed;
        top: 60px;
        right: 0;
        width: 260px;
        height: calc(100vh - 60px);
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
        z-index: 98;
        box-shadow: -4px 0 10px rgba(0,0,0,0.1);
        display: block;
        border-left: 1px solid var(--border-color);
        padding: 20px 0;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-header {
        display: none;
    }
    
    .nav-links {
        display: block;
        padding: 0;
    }
    
    .nav-links li {
        width: 100%;
    }
    
    .nav-links li a {
        display: block;
        padding: 12px 24px;
        border-right: none;
        border-bottom: none;
        font-size: 1.05rem;
    }
    
    .nav-links li a:hover, .nav-links li a.active {
        border-right: 4px solid var(--primary-color);
        border-bottom: none;
        background-color: var(--secondary-color);
    }
    
    .main-content {
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .card {
        padding: 15px;
    }
    
    /* Make form rows wrap nicely on very small screens */
    form div[style*="display: flex"] {
        flex-direction: column;
        gap: 10px !important;
    }
    
    form div[style*="display: flex"] > div {
        width: 100% !important;
    }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
    direction: ltr;
}
.pagination a, .pagination span {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-weight: 500;
    transition: var(--transition);
}
.pagination a:hover {
    background-color: var(--secondary-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}
.pagination span.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}
