:root {
    --primary-color: #1e3a5f;
    --primary-light: #2c5282;
    --primary-dark: #152a4a;
    --secondary-color: #4a5568;
    --success-color: #38a169;
    --warning-color: #d69e2e;
    --danger-color: #e53e3e;
    --info-color: #3182ce;
    --light-bg: #f7fafc;
    --border-color: #e2e8f0;
    --sidebar-bg: #1e3a5f;
    --sidebar-hover: #2c5282;
    --sidebar-active: #152a4a;
}

body {
    font-family: 'Cairo', 'Tajawal', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    min-height: 100vh;
    font-weight: 400;
    line-height: 1.6;
}

#wrapper {
    min-height: 100vh;
}

#sidebar-wrapper {
    height: 100vh;
    width: 250px;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--primary-dark) 100%);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

#wrapper.toggled #sidebar-wrapper {
    margin-right: -250px;
}

#page-content-wrapper {
    min-width: calc(100% - 250px);
    margin-right: 250px;
    transition: all 0.3s ease;
}

/* Custom scrollbar for sidebar */
#sidebar-wrapper::-webkit-scrollbar {
    width: 8px;
}

#sidebar-wrapper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

#sidebar-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

#sidebar-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

#sidebar-wrapper::-webkit-scrollbar-thumb:active {
    background: rgba(255, 255, 255, 0.4);
}

/* Firefox scrollbar */
#sidebar-wrapper,
.list-group {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.05);
}

/* Custom scrollbar for list-group */
.list-group::-webkit-scrollbar {
    width: 8px;
}

.list-group::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.list-group::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.list-group::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.list-group::-webkit-scrollbar-thumb:active {
    background: rgba(255, 255, 255, 0.4);
}

#wrapper.toggled #page-content-wrapper {
    margin-right: 0;
    min-width: 100%;
}

.sidebar-heading {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-color) 100%);
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    font-weight: 700;
    font-family: 'Cairo', sans-serif;
    color: white;
    flex-shrink: 0;
}

.list-group {
    flex: 1;
    overflow-y: auto;
    max-height: calc(100vh - 80px);
    padding: 10px 0;
}

#sidebar-wrapper .list-group-item {
    background: transparent !important;
    border: none !important;
    color: rgba(255, 255, 255, 0.9) !important;
    padding: 12px 20px;
    margin: 2px 10px;
    border-radius: 8px !important;
    transition: all 0.3s ease;
    font-family: 'Cairo', sans-serif;
    font-weight: 500;
    font-size: 15px;
}

#sidebar-wrapper .list-group-item:hover {
    background: var(--sidebar-hover) !important;
    color: white !important;
    transform: translateX(-5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#sidebar-wrapper .list-group-item.active {
    background: var(--sidebar-active) !important;
    color: white !important;
    border-right: 4px solid #fff !important;
    font-weight: 600;
}

#sidebar-wrapper .list-group-item i {
    width: 20px;
    text-align: center;
    margin-left: 8px;
}

.list-group-item.disabled {
    opacity: 0.6;
    cursor: default;
    background: rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.7) !important;
    font-weight: 600;
    font-size: 0.9rem;
    pointer-events: none;
}

/* Loading Indicator for SPA */
#page-content-wrapper.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

#page-content-wrapper.loading::after {
    content: "";
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 9999;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Smooth transitions */
#page-content-wrapper {
    transition: opacity 0.3s ease;
}

.list-group {
    scroll-behavior: smooth;
}

/* Prisoner Search Styles */
.prisoner-result {
    transition: background-color 0.2s ease;
}

.prisoner-result:hover {
    background-color: #f8f9fa !important;
}

.prisoner-result:last-child {
    border-bottom: none !important;
}

#selectedPrisonerInfo {
    transition: all 0.3s ease;
}

#prisonerSearchResults {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#prisonerSearch:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* تحسين الخطوط والعناوين */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    font-weight: 700;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2rem;
    color: var(--primary-color);
}

h2 {
    font-size: 1.75rem;
    color: var(--primary-color);
}

h3 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

h4 {
    font-size: 1.25rem;
    color: var(--primary-color);
}

h5 {
    font-size: 1.1rem;
    color: var(--primary-color);
}

h6 {
    font-size: 1rem;
    color: var(--primary-color);
}

/* تحسين النصوص والفقرات */
p, span, div, td, th, label, input, textarea, select {
    font-family: 'Cairo', 'Tajawal', sans-serif;
}

/* تحسين العناوين في البطاقات */
.card-header {
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-color) 100%);
    color: white;
    border: none;
}

/* تحسين الأزرار */
.btn {
    font-family: 'Cairo', sans-serif;
    font-weight: 500;
    border-radius: 6px;
    padding: 8px 16px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-color) 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* تحسين الجداول */
.table {
    font-family: 'Cairo', sans-serif;
}

.table th {
    font-weight: 600;
    background-color: var(--light-bg);
    border-bottom: 2px solid var(--border-color);
}

/* تحسين النماذج */
.form-control, .form-select {
    font-family: 'Cairo', sans-serif;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(30, 58, 95, 0.25);
}

.form-label {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* تحسين التنبيهات */
.alert {
    font-family: 'Cairo', sans-serif;
    border-radius: 8px;
    border: none;
}

/* تحسين الصفحة الرئيسية */
.page-header {
    background: linear-gradient(135deg, var(--light-bg) 0%, white 100%);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.page-header h1 {
    margin: 0;
    font-size: 1.8rem;
}

.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
}

.card-header {
    background-color: white;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.stat-card {
    border-radius: 15px;
    padding: 1.5rem;
}

.stat-card .stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-card .stat-label {
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-light);
}

.table {
    background-color: white;
    border-radius: 10px;
    overflow: hidden;
}

.table thead th {
    background-color: var(--light-bg);
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    color: var(--secondary-color);
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

.badge {
    font-weight: 500;
    padding: 0.5em 0.8em;
}

.page-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.page-header h1 {
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 0;
}

.nav-tabs .nav-link {
    color: var(--secondary-color);
    border: none;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
}

.nav-tabs .nav-link.active {
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
    background-color: transparent;
}

.nav-tabs .nav-link:hover {
    border-color: transparent;
    color: var(--primary-color);
}

.timeline {
    position: relative;
    padding: 0;
    list-style: none;
}

.timeline::before {
    content: '';
    position: absolute;
    right: 20px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item {
    position: relative;
    padding-right: 50px;
    padding-bottom: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    right: 14px;
    top: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: var(--primary-color);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.timeline-item.primary::before { background-color: var(--primary-color); box-shadow: 0 0 0 2px var(--primary-color); }
.timeline-item.success::before { background-color: var(--success-color); box-shadow: 0 0 0 2px var(--success-color); }
.timeline-item.warning::before { background-color: var(--warning-color); box-shadow: 0 0 0 2px var(--warning-color); }
.timeline-item.danger::before { background-color: var(--danger-color); box-shadow: 0 0 0 2px var(--danger-color); }
.timeline-item.info::before { background-color: var(--info-color); box-shadow: 0 0 0 2px var(--info-color); }

.progress {
    height: 10px;
    border-radius: 5px;
    background-color: #e9ecef;
}

.progress-bar {
    border-radius: 5px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(30, 58, 95, 0.15);
}

.pagination .page-link {
    color: var(--primary-color);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.alert-card {
    border-right: 4px solid;
    border-radius: 8px;
}

.alert-card.urgent { border-right-color: var(--danger-color); }
.alert-card.high { border-right-color: var(--warning-color); }
.alert-card.normal { border-right-color: var(--info-color); }

.search-box {
    position: relative;
}

.search-box .form-control {
    padding-right: 2.5rem;
}

.search-box .search-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary-color);
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--secondary-color);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

@media (max-width: 768px) {
    #sidebar-wrapper {
        margin-right: -250px;
    }
    
    #wrapper.toggled #sidebar-wrapper {
        margin-right: 0;
    }
    
    #page-content-wrapper {
        margin-right: 0;
        min-width: 100%;
    }
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
}

.login-card {
    max-width: 400px;
    width: 100%;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo i {
    font-size: 4rem;
    color: var(--primary-color);
}

/* Prisoner Photo Styles */
.prisoner-photo-wrapper {
    position: relative;
    display: inline-block;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-color) 100%);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.prisoner-photo-wrapper:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 8px 20px rgba(30, 58, 95, 0.3);
}

.prisoner-photo-wrapper img {
    border: 2px solid white;
    object-fit: cover;
}

.prisoner-photo-md {
    width: 50px;
    height: 50px;
}

.prisoner-photo-lg {
    width: 150px;
    height: 150px;
}

.photo-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(30, 58, 95, 0.1);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
}

.prisoner-photo-wrapper:hover .photo-overlay {
    opacity: 1;
}

/* Image Modal */
.image-zoom-modal .modal-content {
    background: transparent;
    border: none;
}

.image-zoom-modal .modal-body {
    padding: 0;
    text-align: center;
}

.image-zoom-modal img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    border: 5px solid white;
}
