/* ============================================================
   نظام التصميم الموحد — mobile-first
   ============================================================ */

[data-theme="dark"] .card,
[data-theme="dark"] .stat-card {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .card-header {
    background: var(--surface-elevated);
    border-color: var(--border);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] select.form-control,
[data-theme="dark"] textarea.form-control {
    background: var(--surface-elevated);
    color: var(--text-strong);
    border-color: var(--border);
}

[data-theme="dark"] .table tbody td {
    background: var(--surface);
    border-color: var(--border);
}

.app-body {
    min-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.owner-portal.app-body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0));
}

.wrapper {
    display: flex;
    min-height: 100dvh;
    width: 100%;
}

.main-content {
    flex: 1;
    min-width: 0;
    width: 100%;
    margin-right: var(--sidebar-width);
    transition: margin 0.3s ease;
}

.content {
    padding: 16px;
    max-width: 1400px;
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-sidebar { grid-template-columns: 1fr; gap: 16px; }

.row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.col-md-4, .col-md-6, .col-md-8, .col-lg-6 {
    flex: 0 0 100%;
    max-width: 100%;
}

@media (min-width: 768px) {
    .content { padding: 20px 24px; }
    .grid-sidebar { grid-template-columns: 1fr 2fr; }
    .col-md-4 { flex: 0 0 calc(33.333% - 11px); max-width: calc(33.333% - 11px); }
    .col-md-6, .col-lg-6 { flex: 0 0 calc(50% - 8px); max-width: calc(50% - 8px); }
    .col-md-8 { flex: 0 0 calc(66.666% - 11px); max-width: calc(66.666% - 11px); }
}

@media (max-width: 991px) {
    .main-content { margin-right: 0 !important; }
    .sidebar { transform: translateX(100%); }
    .sidebar.active { transform: translateX(0); }
    body.sidebar-open { overflow: hidden; }
}

.header { padding: 0 12px; gap: 8px; }

.toggle-sidebar,
.header-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    flex-shrink: 0;
}

.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    border-radius: 10px;
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-color);
    border: 1px solid var(--border);
}

.form-control, select.form-control, textarea.form-control {
    min-height: 44px;
    font-size: 16px;
    font-family: inherit;
    width: 100%;
}

.filter-panel {
    padding: 14px;
    background: var(--muted-surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    margin-bottom: 16px;
}

@media (max-width: 640px) {
    .table-mobile-cards thead { display: none; }
    .table-mobile-cards, .table-mobile-cards tbody,
    .table-mobile-cards tr, .table-mobile-cards td {
        display: block; width: 100%;
    }
    .table-mobile-cards tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 10px;
        padding: 12px;
    }
    .table-mobile-cards td {
        border: none;
        padding: 6px 0;
        display: flex;
        justify-content: space-between;
        gap: 12px;
    }
    .table-mobile-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.8rem;
    }
}

.card {
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    overflow: hidden;
}

.card-header { padding: 14px 16px; flex-wrap: wrap; gap: 10px; }
.card-header h5 { font-size: 0.95rem; }
.card-body { padding: 16px; }
.section-card { margin-top: 16px; }

.stats-grid--4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 768px) {
    .stats-grid--4 { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 576px) {
    .header-title h4 {
        font-size: 0.9rem;
        max-width: 130px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .user-info { display: none; }
    .quick-actions { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .quick-action { padding: 12px 8px; }
    .quick-action span { font-size: 11px; }
}

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 1060;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0));
}

.mobile-bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 10px;
    min-height: 52px;
    justify-content: center;
}

.mobile-bottom-nav a.active { color: var(--brand-primary); background: rgba(37, 99, 235, 0.08); }

@media (max-width: 991px) {
    .owner-portal .mobile-bottom-nav { display: flex; }
}

.notif-card {
    padding: 14px;
    border-radius: 10px;
    background: var(--muted-surface);
    border-right: 4px solid var(--notif-color, var(--brand-primary));
    margin-bottom: 10px;
}

.invoice-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 640px) { .invoice-grid { grid-template-columns: 1fr 1fr; } }
.invoice-box { background: var(--muted-surface); padding: 14px; border-radius: 10px; border: 1px solid var(--border); }

.mb-0{margin-bottom:0!important}.mb-3{margin-bottom:1rem!important}.mb-4{margin-bottom:1.5rem!important}
.mt-2{margin-top:.5rem!important}.mt-3{margin-top:1rem!important}
.p-0{padding:0!important}.py-4{padding:1.5rem 0!important}
.text-center{text-align:center!important}
.text-success{color:var(--color-success)!important}
.text-danger{color:var(--color-danger)!important}
.d-flex{display:flex!important}.flex-wrap{flex-wrap:wrap!important}
.gap-2{gap:8px!important}.w-100{width:100%!important}

.hidden { display: none !important; }

.filter-panel .d-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.filter-panel .form-control--auto {
    width: 100%;
}

@media (min-width: 576px) {
    .filter-panel .form-control--auto {
        width: auto;
        min-width: 130px;
    }
}

.auth-hero--image {
    background-size: cover;
    background-position: center;
    position: relative;
}

.auth-hero--image::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.82), rgba(30, 58, 138, 0.75));
}

.auth-hero-content {
    position: relative;
    z-index: 1;
}

.auth-hero-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    border-radius: 16px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-hero-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 12px;
}

/* إعدادات النظام */
.settings-upload-grid {
    margin-top: 16px;
}

.settings-upload-box {
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: var(--border-radius);
    background: var(--muted-surface);
}

.settings-preview {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
}

.settings-preview--small { width: 48px; height: 48px; }
.settings-preview--wide { width: 100%; max-width: 280px; height: auto; min-height: 80px; }
.settings-preview--wide img { width: 100%; height: auto; display: block; }
.settings-preview--empty { color: var(--text-muted); font-size: 1.5rem; }
.settings-preview img { width: 100%; height: 100%; object-fit: cover; }

.settings-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--muted-surface);
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-top: 12px;
}

.settings-toggle input { width: 18px; height: 18px; }

.settings-actions {
    margin: 20px 0;
    display: flex;
    gap: 12px;
}

.form-check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 8px 0;
}

/* لوحة المالك — أقل بروزاً */
.owner-dashboard {
    background: var(--surface);
    border: 1px solid var(--border);
    border-right: 4px solid var(--brand-primary);
    padding: 18px 16px;
    margin-bottom: 16px;
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.owner-dashboard::after { display: none; }

.owner-dashboard h2 {
    color: var(--text-strong);
    font-size: 1.15rem;
    margin-bottom: 6px;
}

.owner-dashboard p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 14px;
}

.quick-action {
    background: var(--muted-surface);
    border: 1px solid var(--border);
    color: var(--text-strong);
    backdrop-filter: none;
}

.quick-action:hover {
    background: var(--surface-elevated);
    color: var(--brand-primary);
    border-color: var(--brand-primary);
    transform: translateY(-1px);
}

[data-theme="dark"] .owner-dashboard {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .quick-action {
    background: var(--surface-elevated);
    color: var(--text-default);
}

.auth-help {
    margin-top: 20px;
    padding: 14px;
    background: var(--muted-surface);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    border: 1px solid var(--border);
}

@media print {
    html, body {
        background: #fff !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .sidebar, .header, .mobile-bottom-nav, .sidebar-overlay, .no-print, .header-nav, .btn { display: none !important; }
    .main-content, .owner-portal.app-body { margin: 0 !important; padding: 0 !important; }
    .card, .card-body, .invoice-box, .receipt, #invoice {
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
        border: 1px solid #333 !important;
    }
    .card *, .table, .table td, .table th, p, h1, h2, h3, h4, h5, h6, span, div {
        color: #000 !important;
        opacity: 1 !important;
    }
    .table th, thead tr {
        background: #1a1a1a !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .badge { border: 1px solid #333 !important; color: #000 !important; background: #eee !important; }
    .arrears-table { font-size: 9px; color: #000 !important; }
    .arrears-table td, .arrears-table th { color: #000 !important; background: #fff !important; border: 1px solid #333 !important; }
    .arrears-table .row-grand-total td, .arrears-table .row-subtotal td {
        background: #e8e8e8 !important;
        font-weight: bold !important;
    }
}
