@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
  --bg: #ecfdf5;
  --surface: #ffffff;
  --primary: #059669;
  --primary-hover: #047857;
  --primary-soft: rgba(5, 150, 105, 0.12);
  --text: #064e3b;
  --text-muted: #047857;
  --border: rgba(5, 150, 105, 0.2);
  --shadow: 0 4px 6px -1px rgba(6, 78, 59, 0.08), 0 2px 4px -2px rgba(6, 78, 59, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(6, 78, 59, 0.08), 0 4px 6px -4px rgba(6, 78, 59, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Layout 6 */
.layout { min-height: 100vh; display: flex; flex-direction: column; }
.nav {
  background: var(--surface); padding: 1rem 2rem;
  border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; justify-content: space-between; align-items: center;
}
.nav .logo { font-weight: 700; font-size: 1.125rem; color: var(--primary); text-decoration: none; }
.nav .logo:hover { color: var(--primary-hover); }
.nav .links { display: flex; align-items: center; gap: 1.5rem; }
.nav a { color: var(--text-muted); text-decoration: none; font-weight: 500; transition: color 0.2s; }
.nav a:hover { color: var(--primary); }
.nav .btn-link { background: none; border: none; color: var(--text-muted); font: inherit; font-weight: 500; cursor: pointer; padding: 0; }
.nav .btn-link:hover { color: var(--primary); }
.account-dropdown { position: relative; }
.account-btn { background: none; border: none; color: var(--text-muted); font: inherit; font-weight: 500; cursor: pointer; padding: 0; }
.account-btn:hover { color: var(--primary); }
.account-menu { position: absolute; right: 0; top: 100%; margin-top: 0.5rem; min-width: 180px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 0.5rem; display: flex; flex-direction: column; gap: 0.25rem; z-index: 100; }
.account-menu[hidden] { display: none; }
.account-name-link { display: block; padding: 0.5rem 0.75rem; font-size: 0.875rem; color: var(--text-muted); border-bottom: 1px solid var(--border); margin-bottom: 0.25rem; text-decoration: none; }
.account-name-link:hover { color: var(--primary); background: var(--primary-soft); }
.account-menu a, .account-menu .btn-link { display: block; padding: 0.5rem 0.75rem; text-align: left; border-radius: 6px; }
.account-menu a:hover, .account-menu .btn-link:hover { background: var(--primary-soft); }
.account-menu form { margin: 0; }
.lang-switcher { display: flex; align-items: center; gap: 0.5rem; }
.lang-icon { font-size: 1rem; opacity: 0.8; }
.lang-option { color: var(--text-muted); text-decoration: none; font-weight: 500; font-size: 0.875rem; padding: 0.25rem 0.5rem; border-radius: 4px; }
.lang-option:hover { color: var(--primary); }
.lang-option.active { color: var(--primary); font-weight: 600; }
.hero {
  flex: 0 0 25vh; min-height: 133px; background: linear-gradient(135deg, var(--primary) 0%, #047857 100%);
  display: flex; align-items: center; justify-content: center; padding: 2rem; text-align: center;
  color: white;
}
.hero h1 { font-size: 2rem; font-weight: 700; margin: 0 0 0.5rem; letter-spacing: -0.02em; }
.hero p { margin: 0; opacity: 0.9; font-size: 0.9375rem; }
.content { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 2rem; }
.content:has(.dashboard-layout) { justify-content: stretch; align-items: stretch; padding: 0; }
.center-box { width: 100%; max-width: 420px; }
.card {
  background: var(--surface); padding: 2rem; border-radius: 16px;
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.card h3 { font-size: 1.125rem; font-weight: 600; margin: 0 0 0.5rem; }
.card p { color: var(--text-muted); font-size: 0.9375rem; margin: 0 0 1rem; line-height: 1.5; }
.btn { display: inline-block; padding: 0.875rem 1.75rem; background: var(--primary); color: white; border: none; border-radius: 10px; font-weight: 600; cursor: pointer; transition: background 0.2s; font-family: inherit; }
.btn:hover { background: var(--primary-hover); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.icon-btn { background: none; border: none; padding: 0.35rem; cursor: pointer; color: var(--text-muted); border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { color: var(--primary); background: var(--primary-soft); }
.edit-cell { width: 50px; min-width: 50px; padding: 0.35rem !important; }
.user-id-display { margin: 0 0 1rem; font-size: 0.9rem; color: var(--text-muted); }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); margin-top: 0.5rem; }
.btn-outline:hover { background: var(--primary-soft); }

/* Tabs */
.form-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.form-tabs .tab { padding: 0.6rem 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; font: inherit; font-weight: 500; color: var(--text-muted); cursor: pointer; transition: all 0.2s; }
.form-tabs .tab:hover { color: var(--primary); border-color: var(--primary); }
.form-tabs .tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.form-panel { display: none; }
.form-panel.active { display: block; }
.form-switch-link { display: block; text-align: center; margin-top: 1rem; font-size: 0.9375rem; color: var(--primary); text-decoration: none; font-weight: 500; }
.form-switch-link:hover { text-decoration: underline; }

/* Auth forms */
.auth-form { background: var(--surface); padding: 2rem; border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.auth-form label { display: block; font-size: 0.875rem; font-weight: 500; margin: 1rem 0 0.4rem; color: var(--text); }
.auth-form label:first-of-type { margin-top: 0; }
.auth-form input { width: 100%; padding: 0.7rem 1rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 1rem; }
.auth-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.auth-form .row { display: flex; gap: 1rem; }
.auth-form .row .field { flex: 1; }
.auth-form .row .field label { margin-top: 0; }
.auth-form .row .field:not(:first-child) label { margin-top: 0; }
.auth-form .btn { width: 100%; margin-top: 1.25rem; }

/* Flash */
.flash-wrap { width: 100%; max-width: 420px; margin-bottom: 1rem; }
.flash { padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.9375rem; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-info { background: var(--primary-soft); color: var(--text); border: 1px solid var(--border); }

/* Color schemes */
body.scheme-emerald { /* default, already in :root */ }
body.scheme-blue { --bg: #eff6ff; --primary: #2563eb; --primary-hover: #1d4ed8; --primary-soft: rgba(37, 99, 235, 0.12); --text: #1e3a8a; --text-muted: #1d4ed8; --border: rgba(37, 99, 235, 0.2); --shadow: 0 4px 6px -1px rgba(30, 58, 138, 0.08), 0 2px 4px -2px rgba(30, 58, 138, 0.06); --shadow-lg: 0 10px 15px -3px rgba(30, 58, 138, 0.08), 0 4px 6px -4px rgba(30, 58, 138, 0.06); }
body.scheme-blue .hero { background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); }
body.scheme-slate { --bg: #f1f5f9; --primary: #475569; --primary-hover: #334155; --primary-soft: rgba(71, 85, 105, 0.12); --text: #0f172a; --text-muted: #475569; --border: rgba(71, 85, 105, 0.2); --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06); --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.06); }
body.scheme-slate .hero { background: linear-gradient(135deg, #475569 0%, #334155 100%); }
body.scheme-amber { --bg: #fffbeb; --primary: #d97706; --primary-hover: #b45309; --primary-soft: rgba(217, 119, 6, 0.12); --text: #78350f; --text-muted: #b45309; --border: rgba(217, 119, 6, 0.2); --shadow: 0 4px 6px -1px rgba(120, 53, 15, 0.08), 0 2px 4px -2px rgba(120, 53, 15, 0.06); --shadow-lg: 0 10px 15px -3px rgba(120, 53, 15, 0.08), 0 4px 6px -4px rgba(120, 53, 15, 0.06); }
body.scheme-amber .hero { background: linear-gradient(135deg, #d97706 0%, #b45309 100%); }
body.scheme-rose { --bg: #fff1f2; --primary: #e11d48; --primary-hover: #be123c; --primary-soft: rgba(225, 29, 72, 0.12); --text: #881337; --text-muted: #be123c; --border: rgba(225, 29, 72, 0.2); --shadow: 0 4px 6px -1px rgba(136, 19, 55, 0.08), 0 2px 4px -2px rgba(136, 19, 55, 0.06); --shadow-lg: 0 10px 15px -3px rgba(136, 19, 55, 0.08), 0 4px 6px -4px rgba(136, 19, 55, 0.06); }
body.scheme-rose .hero { background: linear-gradient(135deg, #e11d48 0%, #be123c 100%); }

/* Settings */
.settings-wrap { width: 100%; max-width: min(900px, 90vw); }
.settings-card, .settings-wrap .card { max-width: none; width: 100%; }
.settings-desc { color: var(--text-muted); font-size: 0.9375rem; margin: 0 0 1.5rem; }
.settings-form { margin-top: 0; }
.settings-row { margin-bottom: 1.5rem; }
.settings-row h3 { font-size: 1rem; margin: 0 0 0.5rem; }
.settings-select { width: 100%; max-width: 200px; padding: 0.6rem 1rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 0.9375rem; }
.color-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }
.color-tile {
  position: relative;
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.color-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.color-tile:has(input:checked) { border-color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.color-tile input { position: absolute; opacity: 0; pointer-events: none; }
.color-preview { display: block; aspect-ratio: 1.4; min-height: 40px; }
.color-label {
  display: block;
  padding: 0.4rem 0.6rem;
  background: var(--surface);
  font-weight: 600;
  font-size: 0.8125rem;
  text-align: center;
}
.color-tile:has(input:checked) .color-label { background: var(--primary-soft); color: var(--primary); }
@media (min-width: 480px) {
  .color-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .color-grid { grid-template-columns: repeat(5, 1fr); max-width: 500px; }
}

/* Dashboard layout B */
.dashboard-layout { flex: 1; display: flex; min-height: 0; }
.dashboard-layout .sidebar { width: 260px; background: var(--surface); border-right: 1px solid var(--border); padding: 1.5rem 0; flex-shrink: 0; box-shadow: var(--shadow); }
.dashboard-layout .sidebar-title { padding: 0 1.25rem 1rem; font-weight: 600; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.dashboard-layout .sidebar-nav { display: flex; flex-direction: column; gap: 0.5rem; padding: 0 0.75rem; }
.dashboard-layout .sidebar-nav a { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; color: var(--text-muted); text-decoration: none; font-weight: 500; font-size: 0.9375rem; border-radius: 10px; transition: all 0.2s; }
.dashboard-layout .sidebar-nav a:hover { color: var(--primary); background: var(--primary-soft); }
.dashboard-layout .sidebar-nav a.active { color: white; background: var(--primary); }
.dashboard-layout .sidebar-nav .icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; font-size: 1rem; opacity: 0.9; }
.dashboard-layout .dashboard-main { flex: 1; padding: 2rem; overflow: auto; }
.dashboard-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.stats-bar { display: flex; gap: 1rem; flex-wrap: wrap; flex: 1; }
.stat-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem 1rem; min-width: 100px; }
.stat-box .stat-label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.stat-box .stat-value { font-size: 1.25rem; font-weight: 700; }
.user-profile-block { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; margin-inline-start: auto; }
.dashboard-avatar, .dashboard-avatar-placeholder { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.dashboard-avatar-placeholder { background: var(--primary-soft); }
.dashboard-username { font-size: 0.875rem; font-weight: 600; }
.dashboard-layout .containers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.dashboard-layout .container { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; box-shadow: var(--shadow); }
.dashboard-layout .container h2 { font-size: 1rem; margin: 0 0 0.75rem; font-weight: 600; }
.dashboard-layout .container p { color: var(--text-muted); font-size: 0.9375rem; margin: 0; }
@media (max-width: 768px) {
  .dashboard-layout { flex-direction: column; }
  .dashboard-layout .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .dashboard-layout .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .dashboard-layout .containers { grid-template-columns: 1fr; }
}

/* RTL / Arabic */
[dir="rtl"] body { font-family: 'Noto Sans Arabic', 'Plus Jakarta Sans', system-ui, sans-serif; }
[dir="rtl"] .account-menu { right: auto; left: 0; }
[dir="rtl"] .account-menu a, [dir="rtl"] .account-menu .btn-link { text-align: right; }
[dir="rtl"] .dashboard-layout .sidebar { border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] .color-label, [dir="rtl"] .form-switch-link { text-align: center; }

/* User details */
.user-details-form { display: flex; flex-direction: column; gap: 1rem; }
.user-details-form label { font-size: 0.875rem; font-weight: 500; }
.user-details-form input[type="text"],
.user-details-form input[type="tel"] { width: 100%; padding: 0.7rem 1rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.user-details-form input[type="text"]:focus,
.user-details-form input[type="tel"]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.user-details-form .contact-error { font-size: 0.8125rem; color: #b91c1c; margin: 0.25rem 0 0; display: block; }
.avatar-upload { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.avatar-wrap { position: relative; display: inline-block; }
.avatar-clickable { cursor: pointer; }
.avatar-edit-btn {
  position: absolute; top: 0; right: 0;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: white; border: 2px solid var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; box-shadow: var(--shadow);
  transition: background 0.2s;
}
.avatar-edit-btn:hover { background: var(--primary-hover); }
.avatar-preview, .avatar-placeholder { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; display: block; }
.avatar-placeholder { background: var(--primary-soft); }
.avatar-upload input[type="file"] { display: none; }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); cursor: pointer; }
.modal-content { position: relative; background: var(--surface); border-radius: 12px; max-width: 90vw; max-height: 90vh; overflow: hidden; }
.modal-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 1rem; }
.crop-wrap { width: 400px; height: 400px; background: #000; }
.crop-wrap img { display: block; max-width: 100%; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 0.75rem; justify-content: flex-end; }
.modal-view .modal-content { padding: 0; }
.modal-view img { max-width: 90vw; max-height: 90vh; display: block; }

.search-modal-content { max-width: min(640px, 92vw); max-height: 85vh; overflow-y: auto; }
.search-form { padding: 1rem 1.5rem; }
.search-fields { display: grid; grid-template-columns: 1fr; gap: 0.75rem 1rem; margin-bottom: 1rem; }
.search-field label { display: block; font-size: 0.8125rem; font-weight: 500; margin-bottom: 0.25rem; color: var(--text); }
.search-field input { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 0.875rem; }
@media (min-width: 480px) {
  .search-fields { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 720px) {
  .search-fields { grid-template-columns: repeat(3, 1fr); }
}

/* Listings */
.listings-tools { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tools-left { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.tools-right { display: flex; align-items: center; gap: 0.5rem; margin-inline-start: auto; }
.tool-dropdown { position: relative; }
.tool-btn-icon { min-width: 36px; padding: 0.5rem; }
.dropdown-opt { display: block; width: 100%; padding: 0.5rem 0.75rem; background: none; border: none; font: inherit; font-size: 0.875rem; color: var(--text); cursor: pointer; text-align: left; border-radius: 6px; }
.dropdown-opt:hover { background: var(--primary-soft); color: var(--primary); }
.tool-btn { padding: 0.5rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 0.875rem; color: var(--text); cursor: pointer; }
.tool-btn:hover { border-color: var(--primary); color: var(--primary); }
.tool-btn.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.tool-btn.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: white; }
.dropdown-menu { position: absolute; top: 100%; left: 0; margin-top: 0.25rem; min-width: 180px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 0.75rem; z-index: 100; }
.dropdown-placeholder { font-size: 0.875rem; color: var(--text-muted); }
.dropdown-columns { min-width: 220px; max-height: 300px; overflow-y: auto; }
.column-checkboxes { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.75rem; }
.column-opt { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; cursor: pointer; }
.column-opt input { margin: 0; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8125rem; }
.listings-table { table-layout: fixed; width: max-content; }
.listings-table th { position: relative; }
.resize-handle { position: absolute; right: 0; top: 0; bottom: 0; width: 10px; cursor: col-resize; user-select: none; z-index: 1; }
.resize-handle:hover { background: var(--primary-soft); }
.th-content { padding-right: 0.5rem; }
.listings-table-wrap { overflow: auto; max-height: 60vh; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.listings-table { width: 100%; border-collapse: collapse; min-width: 1200px; }
.listings-table th, .listings-table td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.8125rem; }
.listings-table th { background: var(--primary-soft); font-weight: 600; white-space: nowrap; }
.listings-table .empty-msg { text-align: center; color: var(--text-muted); padding: 3rem 2rem; width: 100%; display: block; }
.listings-table tr.empty-row td { border: none; padding: 0; vertical-align: middle; text-align: center; }
.dashboard-main h1 { font-size: 1.5rem; margin: 0 0 1rem; }

/* Property owners sub-tabs - attached to container */
.sub-tab-container { background: var(--surface); border: 2px solid var(--primary); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.sub-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); background: var(--bg); }
.sub-tab { padding: 0.75rem 1.25rem; background: none; border: none; font: inherit; font-weight: 500; color: var(--text-muted); cursor: pointer; position: relative; }
.sub-tab:hover { color: var(--primary); }
.sub-tab.active { color: white; background: var(--primary); }
.sub-tab.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--primary); }
.sub-tab.active { border-bottom: 1px solid var(--primary); margin-bottom: -1px; }
.sub-tab-panels { padding: 1.5rem; }
.sub-tab-panel { display: none; }
.sub-tab-panel.active { display: block; }
.placeholder-msg { color: var(--text-muted); margin: 0; }

@media (max-width: 768px) {
  .hero { flex: 0 0 32vh; min-height: 160px; }
  .auth-form .row { flex-direction: column; gap: 0; }
}
