/* ============================================================
   Property Service Request System — GHANEM AL SUWAIDI HOLDINGS
   ============================================================ */
:root {
  --navy: #0f2a43;
  --navy-2: #16395c;
  --gold: #c9a227;
  --gold-2: #e0b93b;
  --bg: #f2f5f9;
  --card: #ffffff;
  --text: #1d2733;
  --muted: #6b7a8d;
  --line: #e3e9f0;
  --green: #1e8e5a;
  --red: #d64545;
  --blue: #2d7ff9;
  --amber: #d99000;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 42, 67, .08), 0 4px 14px rgba(15, 42, 67, .06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
code { background: #eef2f7; padding: 2px 6px; border-radius: 6px; font-size: .9em; }

/* ---------- Layout ---------- */
.topbar {
  background: linear-gradient(90deg, var(--navy), var(--navy-2));
  color: #fff; display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; position: sticky; top: 0; z-index: 50;
}
.topbar img.logo { height: 38px; width: auto; }
.topbar .brand { font-weight: 700; font-size: 1.05rem; color: #fff; }
.topbar .brand small { display: block; font-weight: 400; font-size: .72rem; opacity: .8; }
.topbar .spacer { flex: 1; }
.topbar a { color: #dbe6f2; }
.icon-btn {
  position: relative; background: rgba(255,255,255,.12); border: 0; color: #fff;
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 17px;
}
.icon-btn:hover { background: rgba(255,255,255,.22); }
.notif-dot {
  position: absolute; top: -5px; right: -5px; background: var(--red); color: #fff;
  border-radius: 999px; font-size: 11px; min-width: 18px; height: 18px; line-height: 18px; padding: 0 4px;
}
.notif-panel {
  position: absolute; right: 12px; top: 58px; width: 360px; max-width: 92vw; max-height: 70vh;
  overflow: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); z-index: 100; display: none; color: var(--text);
}
.notif-panel.open { display: block; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: .9rem; cursor: pointer; }
.notif-item:hover { background: #f6f9fc; }
.notif-item.unread { background: #eef5ff; }
.notif-item time { display: block; color: var(--muted); font-size: .75rem; }

.layout { display: flex; min-height: calc(100vh - 58px); }
.sidebar {
  width: 230px; background: var(--card); border-right: 1px solid var(--line); padding: 16px 10px; flex-shrink: 0;
}
.sidebar a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 2px 0;
  border-radius: 10px; color: var(--text); font-weight: 500;
}
.sidebar a:hover { background: #eef3f9; text-decoration: none; }
.sidebar a.active { background: var(--navy); color: #fff; }
.sidebar .sep { margin: 14px 6px 6px; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.main { flex: 1; padding: 22px; min-width: 0; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .sidebar a { white-space: nowrap; }
  .sidebar .sep { display: none; }
  .main { padding: 14px; }
}

/* ---------- Cards / tables / forms ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 18px; border: 1px solid var(--line);
}
.card h2 { font-size: 1.15rem; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .num { font-size: 1.9rem; font-weight: 700; color: var(--navy); }
.stat .lbl { color: var(--muted); font-size: .85rem; }

table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { background: #f7fafd; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tbl tr:hover td { background: #f9fbfe; }
.tbl-wrap { overflow-x: auto; }

label.fld { display: block; margin-bottom: 12px; font-weight: 600; font-size: .88rem; }
label.fld input, label.fld select, label.fld textarea {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff;
}
label.fld input:focus, label.fld select:focus, label.fld textarea:focus {
  outline: 2px solid rgba(45, 127, 249, .35); border-color: var(--blue);
}
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 14px; }
legend { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-gold { background: var(--gold); color: #1d2733; }
.btn-outline { background: #fff; border-color: var(--line); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .85rem; border-radius: 8px; }
.btn-block { width: 100%; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .92rem; }
.alert-success { background: #e7f6ee; color: #14603c; border: 1px solid #bfe6d1; }
.alert-error   { background: #fdecec; color: #8f2f2f; border: 1px solid #f3c6c6; }
.alert-info    { background: #edf4ff; color: #1d4f9c; border: 1px solid #c9defc; }
.alert-warn    { background: #fff7e6; color: #7c5a00; border: 1px solid #f0ddb0; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge-new      { background: #e8f0fe; color: #1d4f9c; }
.badge-progress { background: #fff3d6; color: #7c5a00; }
.badge-hold     { background: #f3e8fd; color: #6b21a8; }
.badge-resolved { background: #e7f6ee; color: #14603c; }
.badge-closed   { background: #eef1f5; color: #556; }
.prio-low       { background: #eef1f5; color: #556; }
.prio-normal    { background: #e8f0fe; color: #1d4f9c; }
.prio-high      { background: #ffe9d6; color: #9a4a00; }
.prio-urgent    { background: #fdecec; color: #a12b2b; }

.pager { margin-top: 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.pager a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.pager a.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filter-bar label.fld { margin: 0; min-width: 150px; flex: 1; }
.filter-bar label.fld input, .filter-bar label.fld select { margin-top: 4px; padding: 8px 10px; }

/* ---------- Tenant pages ---------- */
.bg { background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 55%, #274b73 100%); min-height: 100vh; padding: 24px 12px; }
.tenant-card {
  max-width: 640px; margin: 0 auto; background: var(--card); border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.25); padding: 26px;
}
.tenant-head { text-align: center; margin-bottom: 18px; }
.tenant-head img { height: 56px; margin-bottom: 8px; }
.tenant-head h1 { font-size: 1.2rem; }
.where-chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 10px 0 4px; }
.chip { background: #eef3f9; border: 1px solid var(--line); padding: 6px 14px; border-radius: 999px; font-size: .88rem; }
.chip b { color: var(--navy); }
.type-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.type-picker input { display: none; }
.type-picker label {
  border: 2px solid var(--line); border-radius: 12px; padding: 12px 8px; text-align: center;
  cursor: pointer; font-weight: 600; font-size: .88rem; display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.type-picker label span.ico { font-size: 1.4rem; }
.type-picker input:checked + label { border-color: var(--navy); background: #eef3fb; }
@media (max-width: 480px) { .type-picker { grid-template-columns: 1fr; } }

.recorder { border: 1px dashed var(--line); border-radius: 12px; padding: 14px; text-align: center; margin-bottom: 12px; }
.recorder .dot { display: inline-block; width: 10px; height: 10px; background: var(--red); border-radius: 50%; margin-right: 6px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.attach-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attach-list .att { background: #eef3f9; border-radius: 8px; padding: 6px 10px; font-size: .8rem; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 26px; border-left: 2px solid var(--line); margin-left: 8px; }
.timeline li:before {
  content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--navy);
}
.timeline time { color: var(--muted); font-size: .78rem; display: block; }

/* ---------- Login / install ---------- */
.auth-wrap { max-width: 420px; margin: 8vh auto; padding: 0 12px; }
.auth-card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 30px; text-align: center; }
.auth-card img { height: 54px; margin-bottom: 10px; }
.auth-card form { text-align: left; margin-top: 16px; }

.install-wrap { max-width: 560px; margin: 6vh auto; padding: 0 12px; }
.install-card { padding: 28px; }
.install-head { text-align: center; margin-bottom: 18px; }
.install-head img { height: 56px; }
.checklist { list-style: none; padding: 0; }
.checklist li { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.checklist li.ok { color: var(--green); }
.checklist li.fail { color: var(--red); font-weight: 600; }

/* ---------- QR page ---------- */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.qr-item { border: 2px solid #000; padding: 18px; text-align: center; background: #fff; border-radius: 4px; }
.qr-item .qr-box { display: flex; justify-content: center; margin: 10px 0; }
.qr-item h3 { margin: 4px 0; }
.qr-actions { margin-top: 10px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- Misc ---------- */
.inline-form { display: inline; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.login-hint { margin-top: 14px; font-size: .8rem; }
footer.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 18px; }
@media print {
  .topbar, .sidebar, .btn, .filter-bar, .no-print, footer.foot { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
}
/* ---------- RTL (Arabic) ---------- */
[dir="rtl"] { text-align: right; }
[dir="rtl"] .topbar { flex-direction: row; }
[dir="rtl"] .notif-panel { right: auto; left: 12px; }
[dir="rtl"] .sidebar a { flex-direction: row-reverse; justify-content: flex-start; }
[dir="rtl"] .timeline li { padding: 0 26px 16px 0; border-left: 0; border-right: 2px solid var(--line); margin-right: 8px; margin-left: 0; }
[dir="rtl"] .timeline li:before { left: auto; right: -7px; }
[dir="rtl"] table.tbl th, [dir="rtl"] table.tbl td { text-align: right; }
[dir="rtl"] .filter-bar label.fld { text-align: right; }
[dir="rtl"] .actions-cell { justify-content: flex-end; }
[dir="rtl"] .stat .num { letter-spacing: 0; }
[dir="rtl"] .pager { justify-content: flex-end; }
[dir="rtl"] .type-picker label { direction: rtl; }
[dir="rtl"] .attach-list { justify-content: flex-end; }
[dir="rtl"] .qr-actions { justify-content: center; }
[dir="rtl"] input[type="checkbox"] { margin-left: 8px; margin-right: 0; }
