/* professional-style.css - تصميم احترافي متكامل */

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

:root {
    --primary-color: #2563eb;
    --secondary-color: #0ea5e9;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-color: #1e293b;
    --light-color: #f8fafc;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    direction: rtl;
    color: var(--dark-color);
}

/* ========== Sidebar Navigation ========== */
/* ========== Sidebar Navigation - مع Scroll كامل ========== */
.sidebar {
    position: fixed;
    right: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    background: white;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar .logo {
    text-align: center;
    padding: 15px 20px;
    border-bottom: 2px solid var(--border-color);
    flex-shrink: 0;
    background: white;
}

.sidebar .logo h2 {
    color: var(--primary-color);
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 3px;
}

.sidebar .logo p {
    color: #64748b;
    font-size: 13px;
}

.sidebar nav {
    flex: 1;
    padding: 10px 0;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0; /* ✅ مهم للـ Flex */
}

/* Scrollbar للقائمة */
.sidebar nav::-webkit-scrollbar {
    width: 5px;
}

.sidebar nav::-webkit-scrollbar-track {
    background: #f8fafc;
}

.sidebar nav::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 10px;
}

.sidebar nav::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.sidebar nav a {
    display: flex;
    align-items: center;
    padding: 12px 25px; /* ✅ قللت المسافة من 15px */
    color: var(--dark-color);
    text-decoration: none;
    transition: all 0.3s;
    border-right: 4px solid transparent;
    position: relative;
    font-size: 15px;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.1) 0%, transparent 100%);
    border-right-color: var(--primary-color);
    color: var(--primary-color);
}

.sidebar nav a i {
    margin-left: 10px;
    font-size: 18px;
    width: 25px;
}

.sidebar .user-info {
    padding: 15px 20px; /* ✅ قللت من 20px 25px */
    background: var(--light-color);
    border-top: 2px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar .user-info .user-name {
    font-weight: bold;
    color: var(--dark-color);
    font-size: 15px;
}

.sidebar .user-info .user-role {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

/* تحسين زر الخروج */
.sidebar .user-info .btn {
    margin-top: 10px;
    padding: 10px 15px;
    font-size: 14px;
}

/* ========== Main Content ========== */
.main-content {
    margin-right: 280px;
    padding: 30px;
    min-height: 100vh;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    max-width: 1400px;
    margin: 0 auto;
}

/* ========== Page Header ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 3px solid var(--border-color);
}

.page-header h1 {
    font-size: 32px;
    color: var(--dark-color);
    font-weight: bold;
}

.page-header h1 i {
    margin-left: 10px;
    color: var(--primary-color);
}

.page-header .header-actions {
    display: flex;
    gap: 15px;
}

/* ========== Stats Cards ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(45deg);
    transition: all 0.5s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 25px rgba(0, 0, 0, 0.15);
}

.stat-card:hover::before {
    right: -100%;
}

.stat-card.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.stat-card.warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.stat-card.danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.stat-card .stat-icon {
    font-size: 36px;
    opacity: 0.9;
    margin-bottom: 15px;
}

.stat-card .stat-number {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 5px;
    position: relative;
    z-index: 1;
}

.stat-card .stat-label {
    font-size: 16px;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

/* ========== Forms ========== */
.form-card {
    background: var(--light-color);
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
}

.form-card h3 {
    color: var(--dark-color);
    margin-bottom: 25px;
    font-size: 20px;
    display: flex;
    align-items: center;
}

.form-card h3 i {
    margin-left: 10px;
    color: var(--primary-color);
}

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

.form-group {
    display: flex;
    flex-direction: column;
}

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

.form-group label i {
    margin-left: 5px;
    color: var(--primary-color);
}

input,
textarea,
select {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s;
    background: white;
    color: var(--dark-color);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

/* ========== Buttons ========== */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-family: inherit;
}

.btn i {
    font-size: 18px;
}

/* ✅ إصلاح مشكلة الزاوية في الأزرار التي تحتوي على أيقونات */
.btn i:first-child {
    margin-right: -4px;
    margin-left: 4px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(37, 99, 235, 0.3);
}

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

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.3);
}

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

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(239, 68, 68, 0.3);
}

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

.btn-warning:hover {
    background: #d97706;
}

.btn-outline {
    background: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

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

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

/* ========== Tables ========== */
.table-container {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--shadow);
    margin: 20px 0;
}

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

thead {
    background: linear-gradient(135deg, var(--dark-color) 0%, #334155 100%);
}

thead th {
    padding: 18px 15px;
    text-align: right;
    color: white;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

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

tbody td {
    padding: 16px 15px;
    color: var(--dark-color);
}

tbody tr:last-child {
    border-bottom: none;
}

/* ========== Status Badges ========== */
.badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.badge.vacant,
.badge.status.vacant {
    background: #dbeafe;
    color: #1e40af;
}

.badge.rented,
.badge.status.rented {
    background: #d1fae5;
    color: #065f46;
}

.badge.maintenance,
.badge.status.maintenance {
    background: #fed7aa;
    color: #92400e;
}

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

.badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.badge.overdue {
    background: #fee2e2;
    color: #991b1b;
}

/* ========== Messages ========== */
.message {
    padding: 16px 20px;
    border-radius: 10px;
    margin: 20px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
}

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

.message i {
    font-size: 20px;
}

.message.success {
    background: #d1fae5;
    color: #065f46;
    border-right: 4px solid #10b981;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
    border-right: 4px solid #ef4444;
}

.message.warning {
    background: #fef3c7;
    color: #92400e;
    border-right: 4px solid #f59e0b;
}

.message.info {
    background: #dbeafe;
    color: #1e40af;
    border-right: 4px solid #3b82f6;
}

/* ========== Notifications ========== */
.notification-badge {
    position: absolute;
    top: 10px;
    left: 20px;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

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

.notification-item {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.notification-item:hover {
    background: var(--light-color);
}

.notification-item.unread {
    background: rgba(37, 99, 235, 0.05);
    border-right: 3px solid var(--primary-color);
}

/* ========== Reports Section ========== */
.report-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

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

.report-header h3 {
    font-size: 22px;
    color: var(--dark-color);
}

.report-filters {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

/* ========== Modal ========== */
/* تحسين Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex !important;
    opacity: 1;
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: scale(1);
}

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

.modal-header h3 {
    margin: 0;
    color: var(--dark-color);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #64748b;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 5px;
    transition: all 0.3s;
}

.modal-close:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* ========== Loading ========== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

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

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0;
    }

    .menu-toggle {
        display: block;
        position: fixed;
        top: 20px;
        right: 20px;
        z-index: 1001;
        background: var(--primary-color);
        color: white;
        border: none;
        padding: 12px;
        border-radius: 8px;
        cursor: pointer;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    .page-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    table {
        font-size: 13px;
    }

    thead th,
    tbody td {
        padding: 10px;
    }
}

/* ========== Print Styles ========== */
@media print {
    .sidebar,
    .page-header .header-actions,
    .btn,
    button {
        display: none !important;
    }

    .main-content {
        margin: 0;
    }

    .container {
        box-shadow: none;
    }

    body {
        background: white;
    }
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* زر القائمة للموبايل */
.menu-toggle {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 20px;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s;
}

.menu-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
}

.menu-toggle:active {
    transform: translateY(0);
}

/* إصلاح الـ Sidebar للموبايل */
@media (max-width: 1024px) {
    .menu-toggle {
        display: block;
    }

    .sidebar {
        transform: translateX(100%);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.3);
    }

    .main-content {
        margin-right: 0;
        padding: 80px 15px 30px;
    }
}
@media (max-width: 1024px) {
    .sidebar {
        height: 100vh;
        max-height: 100vh;
    }

    .sidebar nav {
        max-height: calc(100vh - 280px); /* ✅ ارتفاع متاح للقائمة */
    }
}

@media (max-height: 700px) {
    /* للشاشات القصيرة */
    .sidebar .logo h2 {
        font-size: 20px;
    }

    .sidebar .logo {
        padding: 12px 15px;
    }

    .sidebar nav a {
        padding: 10px 20px;
        font-size: 14px;
    }

    .sidebar .user-info {
        padding: 12px 15px;
    }
}
/* ========== تحسين الجداول على الموبايل ========== */

/* Wrapper للجدول مع Scroll أفقي */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling على iOS */
    margin-bottom: 20px;
    position: relative;
}

/* تحسين Scrollbar */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

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

.table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* تثبيت عرض الجدول على الموبايل */
@media (max-width: 768px) {
    .table-responsive {
        border: 1px solid #e2e8f0;
        border-radius: 10px;
    }

    .data-table {
        min-width: 1200px; /* منع الجدول من الانضغاط */
    }

    .data-table th,
    .data-table td {
        white-space: nowrap; /* منع النص من الالتفاف */
        padding: 12px 10px !important;
        font-size: 13px;
    }

    /* تحسين الأزرار على الموبايل */
    .btn-sm {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }

    .btn-sm i {
        font-size: 11px;
    }
}

/* ========== أزرار رأس الجدول ========== */
.table-header-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 15px;
    gap: 10px;
}

.table-header-actions .btn {
    padding: 8px 18px; /* ✅ تقليل الحجم */
    font-size: 14px; /* ✅ تقليل حجم الخط */
    border-radius: 8px;
}

/* ========== أزرار الأيقونات الصغيرة ========== */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
    background-color: #f1f5f9; /* ✅ لون خلفية افتراضي */
    color: #475569; /* ✅ لون أيقونة افتراضي */
    font-size: 15px;
}

.btn-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    background-color: #e2e8f0; /* ✅ تغيير اللون عند المرور */
}

.btn-icon:active {
    transform: translateY(0);
}

.btn-icon .badge-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--danger-color);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

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

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

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

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

.btn-icon.btn-info {
    background-color: var(--secondary-color);
    color: white;
}

.btn-icon.btn-outline {
    background-color: transparent;
    border: 2px solid var(--border-color);
    color: var(--dark-color);
}

.btn-icon.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Shadow عند وجود محتوى مخفي */
.table-responsive::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.9), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.table-responsive.has-scroll::after {
    opacity: 1;
}

/* رسالة تنبيه للتمرير على الموبايل */
.scroll-hint {
    display: none;
    text-align: center;
    padding: 10px;
    background: #dbeafe;
    color: #1e40af;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 13px;
}

@media (max-width: 768px) {
    .scroll-hint {
        display: block;
    }
}

/* Modal responsive */
.modal-content {
    max-width: 600px; /* أضيق للمستندات */
    width: 95%;
    margin: 20px auto;
}

/* للموبايل - full width مع مسافات */
@media (max-width: 768px) {
    .modal-content {
        max-width: 100%;
        width: 95%;
        margin: 10px auto;
    }
}

/* للشاشات الصغيرة جداً */
@media (max-width: 480px) {
    .modal-content {
        width: 98%;
        margin: 5px auto;
    }

    .modal-header h3 {
        font-size: 16px;
    }

    .btn {
        font-size: 13px;
        padding: 8px 12px;
    }
}
