/**
 * منارات الفرص - ستايل لوحة التحكم
 * Admin Panel Stylesheet
 */

/* ============================================
   Variables
   ============================================ */
:root {
    --primary: #002A28;
    --primary-light: #004C48;
    --gold: #AE9357;
    --gold-light: #C4A86A;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #343a40;
    --white: #ffffff;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --sidebar-width: 260px;
    --topbar-height: 65px;
    --transition: 0.3s ease;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 5px 25px rgba(0, 0, 0, 0.15);
    --radius: 10px;
    --radius-sm: 6px;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    direction: rtl;
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

button {
    cursor: pointer;
    font-family: inherit;
}

/* ============================================
   Admin Wrapper
   ============================================ */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: var(--white);
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--white);
}

.logo-icon {
    font-size: 1.75rem;
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold);
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    padding: 0.5rem;
}

.sidebar-nav {
    padding: 1rem 0;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    transition: var(--transition);
    position: relative;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.sidebar-nav a.active {
    background: var(--gold);
    color: var(--primary);
}

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--white);
}

.nav-icon {
    font-size: 1.25rem;
    width: 28px;
    text-align: center;
}

.badge {
    background: var(--danger);
    color: var(--white);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    margin-right: auto;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 1rem 1.5rem;
}

.logout-link:hover {
    background: rgba(220, 53, 69, 0.3) !important;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   Topbar
   ============================================ */
.topbar {
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--primary);
    margin: 5px 0;
    transition: var(--transition);
}

.topbar-title {
    flex: 1;
}

.topbar-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-info {
    text-align: left;
}

.user-name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--gray-800);
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.user-avatar {
    width: 42px;
    height: 42px;
    background: var(--gold);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

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

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

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

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.card-body {
    padding: 1.5rem;
}

/* ============================================
   Stats Grid
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

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

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.stat-icon.primary { background: rgba(0, 42, 40, 0.1); }
.stat-icon.success { background: rgba(40, 167, 69, 0.1); }
.stat-icon.warning { background: rgba(255, 193, 7, 0.1); }
.stat-icon.danger { background: rgba(220, 53, 69, 0.1); }
.stat-icon.info { background: rgba(23, 162, 184, 0.1); }

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--gray-600);
}

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

.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    background: var(--gray-100);
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table .status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status.available { background: #d4edda; color: #155724; }
.status.sold { background: #f8d7da; color: #721c24; }
.status.rented { background: #cce5ff; color: #004085; }
.status.reserved { background: #fff3cd; color: #856404; }
.status.hidden { background: #e2e3e5; color: #383d41; }

.status.new { background: #cce5ff; color: #004085; }
.status.replied { background: #d4edda; color: #155724; }
.status.closed { background: #e2e3e5; color: #383d41; }

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    transition: var(--transition);
    cursor: pointer;
}

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

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

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

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

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

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

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--gray-700);
}

.form-label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(174, 147, 87, 0.15);
}

.form-control.error {
    border-color: var(--danger);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-text {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
}

/* ============================================
   Alerts
   ============================================ */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-info {
    background: #cce5ff;
    color: #004085;
    border: 1px solid #b8daff;
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.5;
}

.alert-close:hover {
    opacity: 1;
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

/* ============================================
   Actions
   ============================================ */
.actions {
    display: flex;
    gap: 0.5rem;
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.pagination a,
.pagination span {
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-sm);
    background: var(--white);
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
    transition: var(--transition);
}

.pagination a:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.pagination .active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

/* ============================================
   Footer
   ============================================ */
.admin-footer {
    padding: 1rem 1.5rem;
    text-align: center;
    color: var(--gray-500);
    font-size: 0.85rem;
    border-top: 1px solid var(--gray-200);
    background: var(--white);
}

/* ============================================
   Login Page
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 1rem;
}

.login-box {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.login-header h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.login-header p {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.login-form .form-group {
    margin-bottom: 1.5rem;
}

.login-form .btn {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
}

/* ============================================
   Image Upload
   ============================================ */
.image-upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.image-upload-area:hover {
    border-color: var(--gold);
    background: rgba(174, 147, 87, 0.05);
}

.image-upload-area.dragover {
    border-color: var(--gold);
    background: rgba(174, 147, 87, 0.1);
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .remove-image {
    position: absolute;
    top: 0.25rem;
    left: 0.25rem;
    width: 24px;
    height: 24px;
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

/* ============================================
   Featured Badge
   ============================================ */
.featured-star {
    color: var(--gold);
    font-size: 1.25rem;
}

/* ============================================
   Property Image in Table
   ============================================ */
.property-thumb {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-close {
        display: block;
    }
    
    .main-content {
        margin-right: 0;
    }
    
    .menu-toggle {
        display: block;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .topbar-user .user-info {
        display: none;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .card-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}
