/* ==================== GLOBAL STYLES ==================== */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700;900&display=swap');

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

:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --accent-color: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-color: #1e293b;
    --light-color: #f8fafc;
    --gray-color: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 20px 40px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== LANGUAGE SUPPORT (RTL/LTR) ==================== */
html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

html[dir="ltr"] body {
    direction: ltr;
    text-align: left;
}

/* Flip sidebar for RTL/LTR */
html[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
}

html[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: 260px;
}

html[dir="rtl"] .navbar {
    left: auto;
    right: 260px;
}

html[dir="ltr"] .sidebar {
    left: 0;
    right: auto;
}

html[dir="ltr"] .main-content {
    margin-left: 260px;
    margin-right: 0;
}

html[dir="ltr"] .navbar {
    left: 260px;
    right: auto;
}

/* Language Toggle Button */
#languageToggle {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

#languageToggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(37, 99, 235, 0.4);
}

#languageToggle i {
    font-size: 1.1rem;
}

body {
    font-family: 'Cairo', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    direction: rtl;
    color: var(--dark-color);
    overflow-x: hidden;
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==================== UTILITIES ==================== */
.animate-fade-in-up { animation: fadeInUp 0.6s ease-out; }
.animate-fade-in-down { animation: fadeInDown 0.6s ease-out; }
.animate-scale-in { animation: scaleIn 0.6s ease-out; }

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 10;
}

/* ==================== NAVBAR ==================== */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    animation: fadeInDown 0.6s ease-out;
}

.navbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 15px;
    text-decoration: none;
    color: var(--dark-color);
    font-size: 1.8rem;
    font-weight: 900;
    transition: var(--transition);
}

.navbar-brand:hover {
    color: var(--primary-color);
    transform: scale(1.05);
}

.navbar-menu {
    display: flex;
    gap: 20px;
    list-style: none;
    align-items: center;
}

.navbar-menu a {
    text-decoration: none;
    color: var(--dark-color);
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 8px;
    transition: var(--transition);
}

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

/* ==================== BUTTONS ==================== */
.btn {
    padding: 12px 30px;
    border-radius: 10px;
    border: none;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white !important;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white !important;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
    color: white;
}

/* ==================== CARDS ==================== */
.card {
    background: white;
    border-radius: 15px;
    box-shadow: var(--shadow);
    padding: 25px;
    transition: var(--transition);
}

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

/* ==================== FORMS ==================== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-color);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* ==================== TABLES ==================== */
.table-container {
    background: white;
    border-radius: 15px;
    box-shadow: var(--shadow);
    overflow: hidden;
    min-width: 100%;
}

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

.table thead {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
}

.table thead th {
    padding: 15px;
    text-align: right;
    font-weight: 700;
}

.table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.table tbody tr:hover {
    background: var(--light-color);
}

.table tbody td {
    padding: 15px;
}

/* ==================== MODALS ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 2000;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: scaleIn 0.3s ease-out;
}

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

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-color);
    transition: var(--transition);
    width: 35px;
    height: 35px;
    border-radius: 50%;
}

.modal-close:hover {
    background: var(--danger-color);
    color: white;
}

/* ==================== ALERTS ==================== */
.alert {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    animation: slideInRight 0.4s ease-out;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
}

/* ==================== GRID SYSTEM ==================== */
.grid {
    display: grid;
    gap: 25px;
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* ==================== PROPERTY CARD ==================== */
.property-card {
    overflow: hidden;
    border-radius: 15px;
    background: white;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.property-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-hover);
}

.property-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
}

.property-details {
    padding: 20px;
}

.property-price {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--primary-color);
    margin: 10px 0;
}

.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin: 5px;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-primary {
    background: #dbeafe;
    color: #1e40af;
}

/* ==================== MODAL IMPROVEMENTS ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 10000;
    justify-content: center !important;
    align-items: center !important;
    overflow-y: auto;
    padding: 20px;
}

.modal.active {
    display: flex !important;
}

.modal-content {
    position: relative;
    margin: auto;
}

/* ==================== COMPREHENSIVE RESPONSIVE DESIGN ==================== */

/* Tablets and below (max-width: 1024px) */
@media (max-width: 1024px) {
    .container {
        max-width: 95% !important;
        padding: 15px !important;
    }
    
    .navbar {
        padding: 15px 20px;
    }
    
    .navbar-menu {
        gap: 15px;
    }
    
    .navbar-menu li a {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
    
    .card {
        padding: 20px;
    }
}

/* Mobile devices (max-width: 768px) */
@media (max-width: 768px) {
    body {
        font-size: 13px;
    }
    
    /* Container */
    .container {
        padding: 5px !important;
        margin-top: 70px !important;
    }
    
    /* Navbar */
    .navbar {
        flex-direction: column;
        padding: 8px 10px;
        height: auto;
    }
    
    .navbar-container {
        flex-direction: column;
        gap: 8px;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar-brand i {
        font-size: 1.3rem;
    }
    
    .navbar-menu {
        flex-direction: column;
        width: 100%;
        display: none;
        background: white;
        padding: 8px;
        border-radius: 8px;
        box-shadow: var(--shadow);
    }
    
    .navbar-menu.active {
        display: flex;
    }
    
    .navbar-menu li {
        width: 100%;
    }
    
    .navbar-menu li a {
        width: 100%;
        justify-content: flex-start;
        padding: 10px 12px;
        font-size: 0.85rem;
    }
    
    .navbar-user {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    /* Mobile Menu Toggle Button */
    .mobile-menu-toggle {
        display: block;
        position: absolute;
        top: 12px;
        left: 12px;
        background: var(--primary-color);
        color: white;
        border: none;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        cursor: pointer;
        font-size: 1.2rem;
        z-index: 1001;
    }
    
    /* Page Header - تقليل المسافات */
    .page-header {
        padding: 12px 8px;
        margin-bottom: 10px !important;
    }
    
    .page-header h1 {
        font-size: 1.4rem;
        margin-bottom: 3px !important;
    }
    
    .page-header p {
        font-size: 0.8rem;
        margin-bottom: 0 !important;
    }
    
    /* Grid System */
    .grid-3 {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    
    .grid-2 {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    /* Cards - تقليل Padding */
    .card {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    /* Statistics Cards */
    .card [style*="display: flex"] {
        flex-direction: row !important;
        text-align: right !important;
        gap: 8px !important;
    }
    
    .card [style*="width: 70px"] {
        width: 40px !important;
        height: 40px !important;
        margin: 0 !important;
        flex-shrink: 0;
    }
    
    .card [style*="width: 70px"] i {
        font-size: 1rem !important;
    }
    
    .card h3 {
        font-size: 1.2rem !important;
        margin: 0 0 2px 0 !important;
        line-height: 1.2 !important;
    }
    
    .card p {
        font-size: 0.7rem !important;
        margin: 0 !important;
        line-height: 1.2 !important;
    }
    
    /* Tables */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -10px;
        padding: 0 10px;
    }
    
    .data-table {
        min-width: 800px;
        font-size: 0.75rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 6px 4px;
        font-size: 0.75rem;
        white-space: nowrap;
    }
    
    .data-table th {
        font-size: 0.7rem;
        text-transform: uppercase;
    }
    
    /* Forms */
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    
    .form-group {
        margin-bottom: 10px;
    }
    
    .form-label {
        font-size: 0.85rem;
        margin-bottom: 5px;
    }
    
    .form-control {
        font-size: 14px; /* Prevent zoom on iOS */
        padding: 10px 12px;
    }
    
    /* Buttons */
    .btn {
        padding: 10px 16px;
        font-size: 0.85rem;
        width: 100%;
        margin-bottom: 8px;
    }
    
    .btn-sm {
        padding: 6px 10px;
        font-size: 0.75rem;
        width: auto;
        margin-bottom: 0;
        min-width: 32px;
    }
    
    /* Action buttons container */
    [style*="display: flex"][style*="gap: 10px"] {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    [style*="display: flex"][style*="gap: 15px"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }
    
    /* Modal */
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        padding: 15px 10px;
        max-height: 90vh;
    }
    
    .modal-header {
        flex-direction: row;
        gap: 10px;
        padding-bottom: 10px;
        margin-bottom: 15px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-close {
        width: 30px;
        height: 30px;
        font-size: 1.2rem;
    }
    
    /* Property Cards */
    .property-card {
        margin-bottom: 15px;
    }
    
    .property-image {
        height: 180px !important;
    }
    
    /* Search Bar */
    input[type="search"],
    input[type="text"] {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    /* Badges */
    .badge {
        font-size: 0.7rem;
        padding: 3px 8px;
    }
}

/* Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .card h3 {
        font-size: 1.5rem;
    }
    
    .modal-content {
        padding: 15px 10px;
    }
    
    .btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    .navbar-brand span {
        font-size: 1rem;
    }
    
    /* Reduce spacing */
    .container {
        padding: 5px !important;
    }
    
    .card {
        padding: 12px;
    }
    
    /* Statistics */
    .card h3 {
        font-size: 1.8rem !important;
    }
    
    .card p {
        font-size: 0.85rem;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .navbar {
        padding: 8px 15px;
    }
    
    .page-header {
        padding: 15px 10px;
    }
    
    .modal-content {
        max-height: 75vh;
    }
}

/* Touch Improvements */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px; /* iOS minimum touch target */
    }
    
    .btn-sm {
        min-height: 38px;
    }
    
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    
    input,
    select,
    textarea {
        font-size: 16px !important; /* Prevent zoom */
    }
}

/* Print Styles */
@media print {
    .navbar,
    .btn,
    .mobile-menu-toggle,
    #languageToggle {
        display: none !important;
    }
    
    .container {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* High Resolution Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here if needed */
}

/* Property Details Modal - Mobile Optimization */
@media (max-width: 768px) {
    .property-details-modal {
        max-width: 100% !important;
        height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    
    .property-details-grid {
        grid-template-columns: 1fr !important;
    }
    
    .property-details-sidebar {
        max-height: none !important;
        padding: 15px !important;
        font-size: 0.85rem !important;
    }
    
    .property-details-sidebar h2 {
        font-size: 1.5rem !important;
    }
    
    .property-details-sidebar h4 {
        font-size: 0.95rem !important;
    }
    
    .property-details-sidebar .badge {
        padding: 6px 12px !important;
        font-size: 0.75rem !important;
    }
    
    /* تصغير كروت البيانات */
    .property-details-sidebar > div > div {
        padding: 8px !important;
        font-size: 0.75rem !important;
        gap: 8px !important;
    }
    
    /* تصغير الأزرار */
    .property-details-sidebar .btn {
        padding: 10px !important;
        font-size: 0.85rem !important;
    }
    
    /* معرض الصور على الموبايل */
    .property-details-modal #mainImage {
        height: 300px !important;
    }
}

/* Property Cards - Mobile */
@media (max-width: 768px) {
    .property-card {
        font-size: 0.85rem !important;
    }
    
    .property-card h3 {
        font-size: 1.1rem !important;
        line-height: 1.3 !important;
    }
    
    .property-card .property-price {
        font-size: 1.3rem !important;
    }
    
    .property-card .badge {
        padding: 4px 8px !important;
        font-size: 0.7rem !important;
    }
    
    .property-card p {
        font-size: 0.75rem !important;
        margin: 3px 0 !important;
    }
}

/* Enhanced Table Width for Dashboard */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Wider tables on larger screens */
@media (min-width: 1400px) {
    .container {
        max-width: 1600px;
    }
    
    .table {
        min-width: 1400px;
    }
}

@media (min-width: 1600px) {
    .container {
        max-width: 1800px;
    }
    
    .table {
        min-width: 1600px;
    }
}
