/* ===== هوية أملاك البصرية ===== */
:root {
    --am-primary: #0e2f4f;
    --am-primary-dark: #081a2c;
    --am-primary-light: #e9eef3;
    --am-accent: #b8923f;
    --am-accent-light: #f6efdd;
    --am-bg: #f3f5f7;
    --am-surface: #ffffff;
    --am-surface-2: #f7f8fa;
    --am-border: #e2e6eb;
    --am-text: #1c2531;
    --am-muted: #67727e;
    --am-danger: #b0392e;
    --am-danger-light: #fbe8e6;
    --am-success: #2b8f57;
    --am-warning: #a67a26;
    --am-shadow: 0 1px 3px rgba(8,20,35,0.06);
    --am-shadow-lg: 0 12px 32px rgba(8,20,35,0.12);
    --am-sidebar-w: 248px;
}

[data-theme="dark"] {
    --am-primary: #4d7ba3;
    --am-primary-dark: #081726;
    --am-primary-light: #182635;
    --am-accent: #ceac5c;
    --am-accent-light: #2a2415;
    --am-bg: #0c1218;
    --am-surface: #151d26;
    --am-surface-2: #1b2530;
    --am-border: #283340;
    --am-text: #e6ebf0;
    --am-muted: #8a97a5;
    --am-danger: #dd6c5f;
    --am-danger-light: #341d1a;
    --am-success: #4bbd7d;
    --am-warning: #d9b360;
    --am-shadow: 0 1px 3px rgba(0,0,0,0.3);
    --am-shadow-lg: 0 14px 36px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }

body {
    background: var(--am-bg);
    color: var(--am-text);
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    margin-bottom: 0;
    transition: background 0.2s ease, color 0.2s ease;
}

::selection { background: var(--am-accent); color: var(--am-primary-dark); }

/* ---------- Sidebar ---------- */
.am-shell { display: flex; min-height: 100vh; }
.am-sidebar {
    width: var(--am-sidebar-w);
    flex: 0 0 auto;
    background: linear-gradient(175deg, var(--am-primary) 0%, var(--am-primary-dark) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.am-brand {
    display: flex; align-items: center; gap: 11px;
    padding: 24px 22px 20px;
    font-size: 1.3rem; font-weight: 800;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}
.am-brand .am-brand-icon {
    width: 36px; height: 36px; border-radius: 10px;
    overflow: hidden; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.am-brand .am-brand-icon img { width: 100%; height: 100%; display: block; }
.am-nav { flex: 1 1 auto; padding: 16px 12px; }
.am-nav-label {
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em;
    color: rgba(255,255,255,0.38); text-transform: uppercase;
    padding: 10px 14px 6px;
}
.am-nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 14px; margin-bottom: 3px;
    border-radius: 10px;
    color: rgba(255,255,255,0.80);
    text-decoration: none;
    font-size: 0.92rem; font-weight: 600;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    position: relative;
}
.am-nav a i { font-size: 1.05rem; width: 20px; text-align: center; }
.am-nav a:hover { background: rgba(255,255,255,0.09); color: #fff; }
.am-nav a.active { background: var(--am-accent); color: var(--am-primary-dark); box-shadow: 0 3px 10px rgba(0,0,0,0.2); }
.am-sidebar-footer {
    padding: 16px 22px; font-size: 0.72rem; color: rgba(255,255,255,0.45);
    border-top: 1px solid rgba(255,255,255,0.12);
}

/* ---------- Main / Topbar ---------- */
.am-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.am-topbar {
    background: var(--am-surface);
    border-bottom: 1px solid var(--am-border);
    padding: 15px 28px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 10;
}
.am-topbar-title { font-size: 1.2rem; font-weight: 800; color: var(--am-text); margin: 0; }
.am-topbar-user { font-size: 0.85rem; color: var(--am-muted); display: flex; align-items: center; gap: 14px; }
.am-topbar-user a { color: var(--am-primary); font-weight: 700; text-decoration: none; }
.am-topbar-user a:hover { text-decoration: underline; }
.am-content { padding: 28px; flex: 1 1 auto; }

/* ---------- Global search ---------- */
.am-search { position: relative; flex: 1 1 auto; max-width: 380px; margin: 0 24px; }
.am-search-icon { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: 12px; color: var(--am-muted); font-size: 0.9rem; pointer-events: none; }
.am-search-input {
    width: 100%; height: 38px; border-radius: 10px;
    border: 1px solid var(--am-border); background: var(--am-surface-2); color: var(--am-text);
    padding-inline-start: 34px; padding-inline-end: 12px; font-size: 0.85rem; font-family: inherit;
}
.am-search-input:focus { outline: none; border-color: var(--am-primary); background: var(--am-surface); }
.am-search-results {
    position: absolute; top: calc(100% + 6px); inset-inline-start: 0; width: 100%;
    background: var(--am-surface); border: 1px solid var(--am-border); border-radius: 12px;
    box-shadow: var(--am-shadow-lg); max-height: 380px; overflow-y: auto; z-index: 50;
}
.am-search-group { padding: 8px 14px 4px; font-size: 0.7rem; font-weight: 700; color: var(--am-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.am-search-item { display: flex; align-items: center; gap: 10px; padding: 8px 14px; text-decoration: none; color: var(--am-text); }
.am-search-item:hover { background: var(--am-surface-2); }
.am-search-item i { color: var(--am-primary); font-size: 0.95rem; }
[data-theme="dark"] .am-search-item i { color: var(--am-accent); }
.am-search-title { display: block; font-weight: 600; font-size: 0.86rem; }
.am-search-sub { display: block; font-size: 0.74rem; color: var(--am-muted); }
.am-search-empty { padding: 16px; text-align: center; color: var(--am-muted); font-size: 0.85rem; }
@media (max-width: 900px) { .am-search { display: none; } }

/* ---------- Notifications ---------- */
.am-notif { position: relative; }
.am-notif-badge {
    position: absolute; top: -4px; inset-inline-end: -4px;
    min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px;
    background: #dc3545; color: #fff; font-size: 0.62rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; line-height: 1;
}
.am-notif-panel {
    position: absolute; top: calc(100% + 10px); inset-inline-end: 0; width: 340px;
    background: var(--am-surface); border: 1px solid var(--am-border); border-radius: 12px;
    box-shadow: var(--am-shadow-lg); max-height: 420px; overflow-y: auto; z-index: 50;
}
.am-notif-panel-head { padding: 12px 14px; font-weight: 700; font-size: 0.88rem; color: var(--am-text); border-bottom: 1px solid var(--am-border); }
.am-notif-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; text-decoration: none; color: var(--am-text); border-bottom: 1px solid var(--am-border); }
.am-notif-item:last-child { border-bottom: none; }
.am-notif-item:hover { background: var(--am-surface-2); }
.am-notif-item i { margin-top: 2px; font-size: 0.95rem; }
.am-notif-item.severity-warning i { color: #f0a500; }
.am-notif-item.severity-danger i { color: #dc3545; }
.am-notif-text { font-size: 0.82rem; line-height: 1.4; }
.am-notif-empty { padding: 20px 14px; text-align: center; color: var(--am-muted); font-size: 0.85rem; }

/* ---------- Attachments ---------- */
.am-attach-list { max-height: 260px; overflow-y: auto; }
.am-attach-item { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--am-border); }
.am-attach-item:last-child { border-bottom: none; }
.am-attach-item > i { font-size: 1.3rem; color: var(--am-primary); }
.am-attach-info { flex: 1 1 auto; min-width: 0; }
.am-attach-name { font-size: 0.86rem; font-weight: 600; color: var(--am-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-attach-meta { font-size: 0.72rem; color: var(--am-muted); }
.am-attach-empty { padding: 20px; text-align: center; color: var(--am-muted); font-size: 0.85rem; }

/* ---------- Units: vacant highlight ---------- */
.am-row-vacant { background: rgba(40, 167, 69, 0.06); }
.am-row-vacant:hover { background: rgba(40, 167, 69, 0.12) !important; }

/* ---------- Quick table filter bar ---------- */
.am-filter-bar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

/* ---------- Tenant special alert ---------- */
.am-row-alert { background: rgba(220, 53, 69, 0.05); }
.am-row-alert:hover { background: rgba(220, 53, 69, 0.1) !important; }

.am-theme-toggle {
    width: 36px; height: 36px; border-radius: 10px;
    border: 1px solid var(--am-border); background: var(--am-surface-2);
    color: var(--am-text); display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 1rem; transition: background 0.15s;
    text-decoration: none; font-weight: 700;
}
.am-theme-toggle:hover { background: var(--am-primary-light); color: var(--am-text); }
a.am-theme-toggle { font-size: 0.72rem; letter-spacing: 0.02em; }

/* ---------- Cards / Tables ---------- */
.am-card {
    background: var(--am-surface);
    border: 1px solid var(--am-border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--am-shadow);
}
.am-page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.am-page-head h3 { font-size: 1.3rem; font-weight: 800; margin: 0; color: var(--am-text); display: flex; align-items: center; }
.text-muted { color: var(--am-muted) !important; }

.table { margin-bottom: 0; color: var(--am-text); background: var(--am-surface); }
.table > tbody > tr > * { background: var(--am-surface); color: var(--am-text); box-shadow: none; }
.table thead th {
    background: var(--am-primary-light);
    color: var(--am-primary);
    font-weight: 700; font-size: 0.8rem;
    border-bottom: none; padding: 13px 14px;
}
[data-theme="dark"] .table thead th { color: var(--am-accent); }
.table td { padding: 13px 14px; vertical-align: middle; border-color: var(--am-border); font-size: 0.9rem; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: var(--am-surface-2); }

/* Empty / loading states */
.am-empty-row td { padding: 44px 14px; text-align: center; color: var(--am-muted); }
.am-empty-row i { font-size: 1.8rem; display: block; margin-bottom: 8px; opacity: 0.5; }
.am-skel-row td { padding: 13px 14px; }
.am-skel-bar { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--am-surface-2) 25%, var(--am-border) 50%, var(--am-surface-2) 75%); background-size: 200% 100%; animation: am-shimmer 1.3s infinite; }
@keyframes am-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Badges */
.badge { font-weight: 700; font-size: 0.72rem; padding: 5px 10px; border-radius: 7px; }

/* ---------- Buttons ---------- */
.btn { border-radius: 9px; font-weight: 700; font-size: 0.85rem; transition: transform 0.08s, box-shadow 0.15s, background 0.15s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--am-primary); border-color: var(--am-primary); }
.btn-primary:hover { background: var(--am-primary-dark); border-color: var(--am-primary-dark); }
.btn-success { background: var(--am-accent); border-color: var(--am-accent); color: var(--am-primary-dark); }
.btn-success:hover { background: #9f7c31; border-color: #9f7c31; color: var(--am-primary-dark); box-shadow: 0 4px 12px rgba(184,146,63,0.35); }
.btn-outline-primary { color: var(--am-primary); border-color: var(--am-primary); }
.btn-outline-primary:hover { background: var(--am-primary); border-color: var(--am-primary); }
.btn-outline-danger { color: var(--am-danger); border-color: var(--am-danger); }
.btn-outline-danger:hover { background: var(--am-danger); border-color: var(--am-danger); }
.btn-secondary { background: var(--am-surface-2); border-color: var(--am-border); color: var(--am-text); }
.btn-secondary:hover { background: var(--am-border); border-color: var(--am-border); color: var(--am-text); }

/* ---------- Forms / Modals ---------- */
.form-control, .form-select {
    border-radius: 9px; border-color: var(--am-border);
    background: var(--am-surface); color: var(--am-text);
}
.form-control:focus, .form-select:focus { border-color: var(--am-primary); box-shadow: 0 0 0 0.2rem rgba(28,61,90,0.12); background: var(--am-surface); color: var(--am-text); }
.form-label { font-weight: 700; font-size: 0.85rem; color: var(--am-text); }
.modal-content { border-radius: 16px; border: none; background: var(--am-surface); color: var(--am-text); box-shadow: var(--am-shadow-lg); }
.modal-header { border-bottom: 1px solid var(--am-border); padding: 18px 22px; }
.modal-body { padding: 22px; }
.modal-footer { border-top: 1px solid var(--am-border); padding: 16px 22px; }
.modal-title { font-weight: 800; color: var(--am-text); }
.btn-close { filter: var(--am-close-filter, none); }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1); }

/* ---------- Dashboard KPI cards ---------- */
.am-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 24px; }
.am-kpi-card {
    background: var(--am-surface); border: 1px solid var(--am-border); border-radius: 16px;
    padding: 22px; display: flex; align-items: center; gap: 15px;
    text-decoration: none; color: inherit;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    box-shadow: var(--am-shadow);
}
.am-kpi-card:hover { transform: translateY(-3px); box-shadow: var(--am-shadow-lg); color: inherit; border-color: var(--am-accent); }
.am-kpi-icon {
    width: 48px; height: 48px; border-radius: 13px;
    background: var(--am-primary-light); color: var(--am-primary);
    display: flex; align-items: center; justify-content: center; font-size: 1.35rem; flex: 0 0 auto;
}
[data-theme="dark"] .am-kpi-icon { color: var(--am-accent); }
.am-kpi-body .val { font-size: 1.6rem; font-weight: 800; color: var(--am-text); line-height: 1.1; }
.am-kpi-body .lbl { font-size: 0.82rem; color: var(--am-muted); margin-top: 3px; }

@media (max-width: 900px) {
    .am-sidebar { position: fixed; z-index: 100; transform: translateX(100%); transition: transform 0.2s; }
    .am-sidebar.open { transform: translateX(0); }
}
