/* ==========================================================================
   متغیرهای CSS
   ========================================================================== */
:root {
    /* رنگ‌های اصلی */
    --primary-color: #4361ee;
    --primary-dark: #3a0ca3;
    --secondary-color: #3f37c9;
    --success-color: #28a745;
    --info-color: #17a2b8;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    
    /* رنگ‌های اضافی */
    --sidebar-bg: #2c3e50;
    --sidebar-hover: #34495e;
    --card-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    --hover-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
    
    /* فاصله‌ها */
    --spacing-xs: 5px;
    --spacing-sm: 10px;
    --spacing-md: 15px;
    --spacing-lg: 20px;
    --spacing-xl: 25px;
    
    /* شعاع گوشه‌ها */
    --border-radius-sm: 6px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 15px;
}

/* ==========================================================================
   فونت‌ها
   ========================================================================== */
@font-face {
    font-family: 'Vazir';
    src: url('fonts/Vazirmatn-Regular.woff2') format('woff2'),
         url('fonts/Vazirmatn-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ==========================================================================
   استایل‌های عمومی
   ========================================================================== */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Vazir', 'Segoe UI', Tahoma, sans-serif;
    background-color: #f4f7fa;
    color: #333;
    direction: rtl;
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

.container-fluid {
    padding-right: var(--spacing-md);
    padding-left: var(--spacing-md);
}

/* ==========================================================================
   کامپوننت‌های عمومی
   ========================================================================== */

/* کارت‌ها */
.card {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--card-shadow);
    margin-bottom: var(--spacing-lg);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

.card-header {
    background-color: white;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    color: var(--dark-color);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0 !important;
}

.card-header-custom {
    background: white;
    border-bottom: 2px solid #f0f2f5;
    padding: 18px;
    font-weight: 600;
    color: var(--dark-color);
}

.card-body {
    padding: var(--spacing-lg);
}

/* دکمه‌ها */
.btn {
    border-radius: var(--border-radius-md);
    padding: 8px 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
}

.btn-lg {
    font-size: 1.1rem;
    padding: 10px 30px;
    border-radius: var(--border-radius-md);
}

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

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-outline-danger {
    border-color: var(--danger-color);
    color: var(--danger-color);
    background-color: aliceblue;
}

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

/* فرم‌ها */
.form-control, .form-select {
    border-radius: var(--border-radius-md);
    border: 1px solid #ddd;
    padding: 12px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(67, 97, 238, 0.25);
}

/* جداول */
.table {
    border-collapse: collapse;
    width: 100%;
    margin-top: var(--spacing-md);
}

.table thead th {
    background-color: var(--sidebar-hover);
    color: white;
    font-weight: 600;
    vertical-align: middle;
    padding: var(--spacing-md);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: #f9f9f9;
}

.table tbody tr:hover {
    background-color: rgba(67, 97, 238, 0.05);
}

/* ==========================================================================
   سایدبار
   ========================================================================== */
.sidebar {
    min-height: 100vh;
    background: var(--sidebar-bg) !important;
    color: white;
    padding: 0;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}

.sidebar h5 {
    padding: var(--spacing-lg) var(--spacing-md);
    margin-bottom: 0;
    font-weight: 600;
    color: #ecf0f1;
    border-bottom: 1px solid var(--sidebar-hover);
}

.sidebar .nav-link {
    color: #bdc3c7;
    text-decoration: none;
    padding: 12px 15px;
    margin: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    transition: all 0.3s ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background-color: var(--sidebar-hover);
    color: white;
}

.sidebar .nav-link.bg-primary {
    background-color: var(--primary-color) !important;
    color: white !important;
    font-weight: 600;
}

.sidebar .btn-outline-danger {
    margin: 30px 10px;
}

/* ==========================================================================
   داشبورد
   ========================================================================== */
.dashboard-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: var(--spacing-xl) 0;
    margin-bottom: var(--spacing-xl);
    border-radius: 0 0 var(--border-radius-xl) var(--border-radius-xl);
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.15);
}

.greeting {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.date-time {
    font-size: 13px;
    opacity: 0.9;
}

.quick-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-lg);
    flex-wrap: wrap;
}

.quick-btn {
    padding: 8px 16px;
    border-radius: var(--border-radius-md);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.quick-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    color: white;
}

/* کارت‌های آمار */
.stat-card {
    background: white;
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    height: 100%;
    border: none;
}

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

.stat-icon {
    width: 55px;
    height: 55px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: var(--spacing-sm);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: var(--spacing-xs);
}

.stat-title {
    font-size: 13px;
    color: #6c757d;
    font-weight: 500;
}

/* لیست اخیر */
.recent-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.recent-list li {
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid #f0f2f5;
    display: flex;
    align-items: center;
    transition: background 0.2s;
}

.recent-list li:hover {
    background-color: var(--light-color);
}

.recent-list li:last-child {
    border-bottom: none;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-left: var(--spacing-sm);
    flex-shrink: 0;
}

.visit-badge {
    padding: 4px 10px;
    border-radius: 18px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.visit-done {
    background-color: #d3f9d8;
    color: var(--success-color);
}

.visit-cancelled {
    background-color: #ffe3e3;
    color: var(--danger-color);
}

.visit-pending {
    background-color: #fff3bf;
    color: var(--warning-color);
}

.empty-state {
    text-align: center;
    padding: 30px 20px;
    color: #6c757d;
}

.empty-state i {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ==========================================================================
   فرم هوشمند (ثبت ملک)
   ========================================================================== */
.hidden {
    display: none !important;
}

.spec-card {
    border: 1px dashed var(--primary-color);
    background: #ecf6ff;
    padding: var(--spacing-lg);
    margin-top: var(--spacing-md);
    border-radius: var(--border-radius-md);
    position: relative;
}

.remove-btn {
    position: absolute;
    top: var(--spacing-sm);
    left: var(--spacing-sm);
    z-index: 10;
}

.management-info {
    background-color: var(--light-color);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-md);
    margin-bottom: var(--spacing-lg);
    border-right: 4px solid var(--primary-color);
}

/* ==========================================================================
   صفحه جزئیات ملک
   ========================================================================== */
.property-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: var(--spacing-md);
    border-radius: var(--border-radius-md);
    margin-bottom: var(--spacing-md);
}

.header-price {
    font-size: 1.2rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 4px;
    display: inline-block;
}

.info-badge {
    background: #000;
    padding: 3px 8px;
    border-radius: 15px;
    font-size: 0.75rem;
    margin-left: 8px;
}

.section-title {
    border-bottom: 1px solid var(--primary-color);
    padding-bottom: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    color: var(--sidebar-bg);
    font-weight: 600;
    font-size: 1.1rem;
}

/* باکس‌های اطلاعات */
.price-box {
    background-color: #e8f5e9;
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-right: 3px solid var(--success-color);
}

.expert-box {
    background-color: #fff3cd;
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-right: 3px solid var(--warning-color);
}

.spec-box {
    background-color: var(--light-color);
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-right: 3px solid var(--primary-color);
}

.location-box {
    background-color: #e7f5ff;
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-right: 3px solid var(--info-color);
}

.unit-box {
    background-color: #fef9e7;
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-right: 3px solid var(--success-color);
}

.gallery-box {
    background-color: #f4f6f9;
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

/* وضعیت‌ها */
.status-active {
    color: var(--success-color);
    font-weight: 600;
}

.status-archived {
    color: #6c757d;
    font-weight: 600;
}

.status-sold {
    color: var(--danger-color);
    font-weight: 600;
}

.status-canceled {
    color: var(--warning-color);
    font-weight: 600;
}

/* جزئیات */
.detail-item {
    padding: 15px;
    border-bottom: 1px dashed #eee;
    display: initial;
    justify-content: initial;
    align-items: center;
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 600;
    color: var(--sidebar-hover);
    font-size: 0.85rem;
}

/* گالری تصاویر */
.image-gallery img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: var(--border-radius-sm);
    margin-bottom: var(--spacing-sm);
    border: 1px solid #ddd;
}

.image-thumbnail {
    position: relative;
    margin: var(--spacing-xs);
    display: inline-block;
}

.image-thumbnail img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--border-radius-sm);
}

.delete-checkbox {
    position: absolute;
    top: var(--spacing-xs);
    left: var(--spacing-xs);
}

/* ==========================================================================
   جدول ثابت (لیست املاک)
   ========================================================================== */
.sticky-table-container {
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    background-color: white;
}

.sticky-header-wrapper {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--dark-color);
}

.sticky-header-wrapper .table {
    margin-bottom: 0;
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
}

.sticky-header-wrapper th {
    background-color: var(--dark-color) !important;
    color: white !important;
    font-weight: 600;
    text-align: right;
    vertical-align: middle;
    padding: var(--spacing-md) var(--spacing-sm) !important;
    border-bottom: 2px solid #495057 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: sticky;
    top: 0;
    z-index: 1001;
}

.scrollable-body-wrapper {
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: auto;
}

.scrollable-body-wrapper .table {
    margin-bottom: 0;
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
}

.property-row {
    height: 55px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.property-row:hover {
    background-color: rgba(var(--primary-color), 0.05) !important;
}

.scrollable-body-wrapper td {
    padding: var(--spacing-sm) !important;
    vertical-align: middle !important;
    font-size: 0.9rem;
    border-bottom: 1px solid #dee2e6;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scrollable-body-wrapper td:nth-child(6) {
    white-space: normal !important;
    line-height: 1.4;
    min-height: 55px;
    display: table-cell;
    vertical-align: middle;
}

.scrollable-body-wrapper td:nth-child(6) small {
    white-space: normal !important;
}

/* ستون‌ها */
.sticky-header-wrapper th:nth-child(1),
.scrollable-body-wrapper td:nth-child(1) { width: 50px; min-width: 50px; max-width: 50px; }
.sticky-header-wrapper th:nth-child(2),
.scrollable-body-wrapper td:nth-child(2) { width: 80px; min-width: 80px; max-width: 80px; }
.sticky-header-wrapper th:nth-child(3),
.scrollable-body-wrapper td:nth-child(3) { width: 100px; min-width: 100px; max-width: 100px; }
.sticky-header-wrapper th:nth-child(4),
.scrollable-body-wrapper td:nth-child(4) { width: 80px; min-width: 80px; max-width: 80px; }
.sticky-header-wrapper th:nth-child(5),
.scrollable-body-wrapper td:nth-child(5) { width: 120px; min-width: 120px; max-width: 120px; }
.sticky-header-wrapper th:nth-child(6),
.scrollable-body-wrapper td:nth-child(6) { width: 80px; min-width: 80px; max-width: 80px; }
.sticky-header-wrapper th:nth-child(7),
.scrollable-body-wrapper td:nth-child(7) { width: 100px; min-width: 100px; max-width: 100px; }
.sticky-header-wrapper th:nth-child(8),
.scrollable-body-wrapper td:nth-child(8) { width: 120px; min-width: 120px; max-width: 120px; }
.sticky-header-wrapper th:nth-child(9),
.scrollable-body-wrapper td:nth-child(9) { width: 100px; min-width: 100px; max-width: 100px; }
.sticky-header-wrapper th:nth-child(10),
.scrollable-body-wrapper td:nth-child(10) { width: 80px; min-width: 80px; max-width: 80px; }
.sticky-header-wrapper th:nth-child(11),
.scrollable-body-wrapper td:nth-child(11) { width: 80px; min-width: 80px; max-width: 80px; }
.sticky-header-wrapper th:nth-child(12),
.scrollable-body-wrapper td:nth-child(12) { width: 80px; min-width: 80px; max-width: 80px; }
.sticky-header-wrapper th:nth-child(13),
.scrollable-body-wrapper td:nth-child(13) { width: 120px; min-width: 120px; max-width: 120px; }
.sticky-header-wrapper th:nth-child(14),
.scrollable-body-wrapper td:nth-child(14) { width: 140px; min-width: 140px; max-width: 140px; text-align: center !important; }

.action-cell {
    min-width: 140px;
    position: relative;
}

.action-buttons {
    display: flex;
    gap: var(--spacing-xs);
    justify-content: center;
    align-items: center;
}

.action-buttons .btn {
    width: 95px;
    height: 34px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.9rem;
}

/* باکس اطلاعات */
.details-container {
    position: relative;
    display: inline-block;
}

.details-box {
    display: none;
    position: fixed;
    background-color: white;
    border: 1px solid #c8d6e5;
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm);
    width: 900px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.25);
    z-index: 99999;
    text-align: right;
    font-size: 0.85rem;
    max-height: 250px;
    overflow-y: auto;
}

.details-box::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px;
    border-style: solid;
    border-color: transparent transparent white transparent;
}

.details-box::after {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 11px;
    border-style: solid;
    border-color: transparent transparent #c8d6e5 transparent;
    z-index: -1;
}

.details-container:hover .details-box {
    display: block;
}

.details-header {
    color: var(--sidebar-bg);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    font-weight: 700;
    font-size: 0.95rem;
}

.details-grid {
    display: grid;
    grid-template-columns: 0.75fr 0.75fr 0.75fr 1fr 0.5fr 0.5fr;
    gap: 2px;
}

.price-cell {
    min-width: 130px;
}

.price-cell .sale-price {
    color: var(--success-color);
    font-weight: 600;
}

.price-output {
    color: var(--success-color);
    font-weight: 600;
    margin-top: var(--spacing-xs);
    min-height: 24px;
}

/* ==========================================================================
   صفحه لاگین
   ========================================================================== */
.login-container {
    background: white;
    border-radius: var(--border-radius-xl);
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    max-width: 900px;
    width: 100%;
}

.login-image {
    background-image: url('uploads/loginbg.jpg');
    background-size: cover;
    background-position: center;
    min-height: 450px;
}

.login-form-section {
    padding: 50px;
}

/* ==========================================================================
   نقشه
   ========================================================================== */
#map {
    height: 350px;
    border-radius: var(--border-radius-md);
    z-index: 1;
    margin-bottom: var(--spacing-sm);
}

/* ==========================================================================
   کلاس‌های کمکی
   ========================================================================== */
.extraheight {
    margin-top: 100px !important;
}

.result-text {
    font-size: 11px;
    color: #6c757d;
    margin-top: 4px;
    line-height: 1.4;
    max-height: 36px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   رسپانسیو
   ========================================================================== */
@media (max-width: 992px) {
    .main-container {
        margin-right: 0;
        transition: margin-right 0.3s ease;
    }
    
    .content-wrapper {
        padding: var(--spacing-md);
    }
    
    .stat-number {
        font-size: 24px;
    }
    
    .greeting {
        font-size: 20px;
    }
    
    .quick-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .stat-number {
        font-size: 22px;
    }
    
    .greeting {
        font-size: 18px;
    }
    
    .dashboard-header {
        padding: var(--spacing-lg) 0;
    }
    
    .stat-card {
        padding: var(--spacing-md);
    }
    
    .property-row {
        height: 50px;
    }
    
    .scrollable-body-wrapper {
        max-height: 60vh;
    }
    
    .sticky-header-wrapper th {
        font-size: 0.85rem;
        padding: var(--spacing-sm) var(--spacing-xs) !important;
    }
    
    .scrollable-body-wrapper td {
        padding: var(--spacing-xs) !important;
        font-size: 0.85rem;
    }
    
    .action-buttons .btn {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
    
    .details-box {
        width: 300px;
        padding: var(--spacing-sm);
        font-size: 0.8rem;
        max-height: 400px;
    }
    
    .sticky-table-container {
        overflow-x: auto;
    }
    
    .sticky-header-wrapper,
    .scrollable-body-wrapper {
        min-width: 1200px;
    }
    
    .sticky-header-wrapper .table,
    .scrollable-body-wrapper .table {
        min-width: 1200px;
    }
    
    .login-form-section {
        padding: var(--spacing-lg);
    }
}

@media (max-width: 576px) {
    .container-fluid {
        padding-right: var(--spacing-sm);
        padding-left: var(--spacing-sm);
    }
    
    .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    .quick-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* ==========================================================================
   استایل‌های چاپ
   ========================================================================== */
@media print {
    .sidebar,
    .btn,
    .action-buttons,
    #map,
    .image-gallery,
    .property-header,
    .quick-actions,
    .dashboard-header,
    .card-header-custom {
        display: none !important;
    }
    
    .col-md-10 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
        background-color: white !important;
        padding: 0 !important;
    }

    body {
        background-color: white !important;
        padding: var(--spacing-xs) !important;
        margin: 0 !important;
        font-size: 11px !important;
    }

    .card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        margin-bottom: var(--spacing-sm) !important;
        page-break-inside: avoid;
        padding: 8px !important;
    }
    
    .container-fluid {
        padding: 0 !important;
    }
    
    .row {
        margin: 0 !important;
    }
    
    .col-md-6, .col-md-5, .col-md-7, .col-md-3, .col-md-4 {
        padding: var(--spacing-xs) !important;
    }
    
    .section-title {
        font-size: 12px !important;
        padding-bottom: var(--spacing-xs) !important;
        margin-bottom: var(--spacing-sm) !important;
    }
    
    .detail-item {
        padding: 3px 0 !important;
        font-size: 10px !important;
    }
    
    .detail-label {
        font-size: 10px !important;
    }
    
    .unit-box,
    .spec-box,
    .price-box,
    .expert-box,
    .location-box {
        margin-bottom: var(--spacing-sm) !important;
        padding: 8px !important;
        page-break-inside: avoid;
    }
    
    h3, h4, h5, h6 {
        margin-top: var(--spacing-xs) !important;
        margin-bottom: var(--spacing-sm) !important;
    }
}