/* ═══════════════════════════════════════════════════════════
   CALMLY — Dashboard Propriétaire
   Page autonome (séparée du site principal)
═══════════════════════════════════════════════════════════ */

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

:root {
  --bg:          #F5F7FA;
  --bg-2:        #EBF0F7;
  --bg-card:     #FFFFFF;
  --bg-card-hov: #F0F4FA;
  --border:      #D4DCE8;
  --border-2:    #B8C4D4;
  --txt-1:       #14243E;
  --txt-2:       #4A5C74;
  --txt-3:       #8A9AB0;
  --navy:        #14243E;
  --navy-lt:     #1E3254;
  --gold:        #B8941A;
  --gold-lt:     #D4AF37;
  --gold-bg:     rgba(184,148,26,.12);
  --green:       #1E8E5A;
  --green-bg:    rgba(30,142,90,.12);
  --red:         #C0492F;
  --shadow-sm:   0 1px 3px rgba(20,36,62,.06), 0 2px 8px rgba(20,36,62,.04);
  --shadow-md:   0 4px 16px rgba(20,36,62,.08), 0 1px 4px rgba(20,36,62,.04);
  --shadow-lg:   0 8px 32px rgba(20,36,62,.10), 0 2px 8px rgba(20,36,62,.05);
  --r-sm:  8px;
  --r-md: 14px;
  --r-lg: 20px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--txt-1);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

/* État affiché : géré par JS via classes sur <body> */
.view { display: none; }
body.state-auth    #authView      { display: flex; }
body.state-app     #appView       { display: block; }
body.state-loading #loadingView   { display: flex; }

/* ═══════════════ LOADING ═══════════════ */
#loadingView {
  min-height: 100vh; align-items: center; justify-content: center;
  background: var(--navy);
}
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.18);
  border-top-color: var(--gold-lt);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════ AUTH (login/register) ═══════════════ */
#authView {
  min-height: 100vh; flex-direction: column;
  background:
    radial-gradient(circle at 20% 10%, rgba(184,148,26,.16), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(30,50,84,.6), transparent 50%),
    linear-gradient(135deg, #0E1C2A 0%, #14243E 60%, #1E3254 100%);
}
.auth-header { flex-shrink: 0; padding: 22px 30px; }
.auth-home { display: inline-flex; align-items: center; }
.auth-home img { height: 40px; width: auto; filter: brightness(0) invert(1); transition: opacity .15s; }
.auth-home:hover img { opacity: .82; }
.auth-center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 12px 24px 56px; }
.auth-card {
  width: 100%; max-width: 430px;
  background: var(--bg-card); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px 34px;
}
.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo img { height: 54px; margin: 0 auto 4px; width: auto; }
.auth-logo .auth-sub {
  font-size: .74rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold); font-weight: 600;
}
.auth-tabs {
  display: flex; gap: 4px; background: var(--bg-2);
  border-radius: 99px; padding: 4px; margin-bottom: 26px;
}
.auth-tab {
  flex: 1; border: none; background: none; padding: 9px;
  border-radius: 99px; font-size: .9rem; font-weight: 600; color: var(--txt-2);
  transition: all .18s;
}
.auth-tab.active { background: var(--bg-card); color: var(--navy); box-shadow: var(--shadow-sm); }

.auth-form { display: none; }
.auth-form.active { display: block; }
.auth-h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; }
.auth-lead { font-size: .9rem; color: var(--txt-2); margin-bottom: 22px; }

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: .78rem; font-weight: 600; color: var(--txt-2);
  letter-spacing: .03em; text-transform: uppercase; margin-bottom: 7px;
}
.field input {
  width: 100%; font-family: inherit; font-size: .95rem; color: var(--txt-1);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 12px 14px; transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-bg);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; font-size: .95rem; font-weight: 700; border: none;
  border-radius: var(--r-sm); padding: 13px 18px; transition: filter .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gold); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-ghost { background: var(--bg-2); color: var(--navy); width: auto; padding: 9px 16px; font-size: .85rem; }
.btn-ghost:hover { background: var(--bg-card-hov); }

.auth-msg {
  font-size: .85rem; padding: 11px 14px; border-radius: var(--r-sm);
  margin-bottom: 16px; display: none;
}
.auth-msg.show { display: block; }
.auth-msg.error   { background: rgba(192,73,47,.1);  color: var(--red);   border: 1px solid rgba(192,73,47,.25); }
.auth-msg.success { background: var(--green-bg);      color: var(--green); border: 1px solid rgba(30,142,90,.25); }

.auth-foot { text-align: center; margin-top: 22px; font-size: .82rem; color: var(--txt-3); }
.auth-foot a { color: var(--gold); font-weight: 600; }

/* ═══════════════ APP (dashboard) ═══════════════ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 24px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar-logo img { height: 38px; width: auto; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user { text-align: right; line-height: 1.3; }
.topbar-user .u-name  { font-size: .88rem; font-weight: 700; color: var(--txt-1); }
.topbar-user .u-mail  { font-size: .75rem; color: var(--txt-3); }
.topbar-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--navy); color: var(--gold-lt);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem;
}

.dash { max-width: 1180px; margin: 0 auto; padding: 34px 24px 80px; }
.dash-welcome { margin-bottom: 28px; }
.dash-welcome h1 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; letter-spacing: -.02em; }
.dash-welcome p  { color: var(--txt-2); font-size: .98rem; margin-top: 4px; }

.section-label {
  font-size: .76rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--gold); margin: 38px 0 14px; display: flex; align-items: center; gap: 8px;
}
.section-label::before { content: ""; width: 18px; height: 2px; background: var(--gold); }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi-ico {
  width: 38px; height: 38px; border-radius: 10px; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gold-bg); color: var(--gold);
}
.kpi-label { font-size: .8rem; color: var(--txt-2); font-weight: 600; }
.kpi-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.kpi-sub { font-size: .76rem; color: var(--txt-3); margin-top: 4px; }
.kpi-sub.up   { color: var(--green); }
.kpi-sub.down { color: var(--red); }

/* Cards container */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 24px; box-shadow: var(--shadow-sm);
}
.card-title { font-size: 1.02rem; font-weight: 700; margin-bottom: 4px; }
.card-sub { font-size: .82rem; color: var(--txt-3); margin-bottom: 18px; }

/* Revenue chart */
.chart-wrap { position: relative; height: 280px; }

/* Properties */
.prop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.prop-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md);
  overflow: hidden; box-shadow: var(--shadow-sm); transition: box-shadow .18s, transform .18s;
}
.prop-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.prop-img { aspect-ratio: 16/10; background: var(--bg-2); position: relative; overflow: hidden; }
.prop-img img { width: 100%; height: 100%; object-fit: cover; }
.prop-img .prop-status {
  position: absolute; top: 10px; right: 10px; font-size: .68rem; font-weight: 700;
  padding: 4px 10px; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em;
  backdrop-filter: blur(6px);
}
.prop-status.active { background: var(--green-bg); color: var(--green); }
.prop-status.paused { background: rgba(138,154,176,.18); color: var(--txt-2); }
.prop-body { padding: 16px 18px 18px; }
.prop-name { font-size: .98rem; font-weight: 700; line-height: 1.35; }
.prop-meta { font-size: .8rem; color: var(--txt-3); margin-top: 3px; }
.prop-stats { display: flex; gap: 18px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.prop-stat .s-val { font-size: 1.05rem; font-weight: 800; }
.prop-stat .s-lbl { font-size: .72rem; color: var(--txt-3); }

/* Table (bookings) */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th {
  text-align: left; font-size: .72rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--txt-3); padding: 0 14px 12px; white-space: nowrap;
}
table.data td { padding: 13px 14px; border-top: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
table.data tr:hover td { background: var(--bg-card-hov); }
.badge {
  font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 99px;
}
.badge.confirmed { background: var(--gold-bg); color: var(--gold); }
.badge.completed { background: var(--green-bg); color: var(--green); }
.badge.cancelled { background: rgba(138,154,176,.16); color: var(--txt-3); }
.plat { display: inline-flex; align-items: center; gap: 6px; }
.plat-dot { width: 8px; height: 8px; border-radius: 50%; }
.plat-dot.airbnb  { background: #FF5A5F; }
.plat-dot.booking { background: #2D5BFF; }

/* Documents / contrats */
.doc-list { display: flex; flex-direction: column; }
.doc-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 4px; border-top: 1px solid var(--border);
}
.doc-row:first-child { border-top: none; }
.doc-ico {
  width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--gold-bg); color: var(--gold);
}
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: .92rem; font-weight: 600; color: var(--txt-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { font-size: .76rem; color: var(--txt-3); margin-top: 2px; }
.btn-dl {
  display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0;
  font-family: inherit; font-size: .84rem; font-weight: 600; color: var(--navy);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 99px;
  padding: 8px 15px; cursor: pointer; transition: background .15s, border-color .15s;
}
.btn-dl:hover { background: var(--bg-card-hov); border-color: var(--border-2); }
html[dir="rtl"] .doc-name, html[dir="rtl"] .doc-meta { text-align: right; }

/* Empty state */
.empty {
  text-align: center; padding: 48px 24px; color: var(--txt-3);
}
.empty svg { margin: 0 auto 14px; color: var(--border-2); }
.empty p { font-size: .92rem; }

.spacer-lg { height: 22px; }

/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .dash { padding: 24px 16px 60px; }
  .topbar-inner { padding: 0 16px; }
  .topbar-user { display: none; }
  .topbar-right { gap: 10px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .kpi { padding: 16px; }
  .kpi-value { font-size: 1.4rem; }
  .auth-card { padding: 32px 24px 28px; }
  .chart-wrap { height: 240px; }
  .auth-header { padding: 16px 18px; }
  .auth-home img { height: 34px; }
  .auth-center { padding: 8px 18px 40px; }
}

/* ═══════════════ SÉLECTEUR DE LANGUE (identique au site principal) ═══════════════ */
.auth-lang { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.lang-switcher { position: relative; }
.lang-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: inherit; font-size: .84rem; font-weight: 600; color: var(--txt-1);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 99px; padding: 7px 13px 7px 11px; cursor: pointer;
  box-shadow: var(--shadow-sm); min-height: 40px; min-width: 92px; line-height: 1;
  transition: border-color .18s, box-shadow .18s, color .18s;
}
.lang-btn:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); }
.lang-switcher.open .lang-btn { border-color: var(--border-2); }
.lang-btn svg { transition: transform .22s ease; flex-shrink: 0; opacity: .4; margin-left: 1px; }
.lang-switcher.open .lang-btn svg { transform: rotate(180deg); opacity: .65; }
.lang-flag { font-size: 1.05rem; line-height: 1; }
.lang-code { font-size: .82rem; letter-spacing: .05em; font-weight: 700; }
.lang-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  padding: 4px; min-width: 168px; z-index: 60; list-style: none; margin: 0;
  opacity: 0; transform: translateY(-8px) scale(.97); pointer-events: none;
  transition: opacity .18s ease, transform .2s cubic-bezier(.22,1,.36,1);
}
.lang-switcher.open .lang-menu { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.lang-menu li { display: block; }
.lang-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  text-align: left; background: none; border: none;
  font-family: inherit; font-size: .86rem; font-weight: 500; color: var(--txt-2);
  padding: 9px 12px; border-radius: 9px; cursor: pointer; min-height: 38px;
  transition: background .12s, color .12s;
}
.lang-menu button:hover  { background: rgba(20,36,62,.06); color: var(--navy); }
.lang-menu button.active { color: var(--navy); font-weight: 700; background: rgba(20,36,62,.05); }
.lang-menu button.active::after { content: '✓'; margin-left: auto; font-size: .72rem; opacity: .7; font-weight: 800; }

/* ═══════════════ RTL (arabe) ═══════════════ */
html[dir="rtl"] body { direction: rtl; }
html[dir="rtl"] .topbar-user { text-align: left; }
html[dir="rtl"] table.data th { text-align: right; }
html[dir="rtl"] .auth-foot,
html[dir="rtl"] .field label,
html[dir="rtl"] .auth-h2,
html[dir="rtl"] .auth-lead { text-align: right; }
html[dir="rtl"] .auth-lang { justify-content: flex-start; }
html[dir="rtl"] .lang-menu { right: auto; left: 0; }
html[dir="rtl"] .lang-menu button { text-align: right; }
html[dir="rtl"] .section-label::before { margin-left: 0; }
html[dir="rtl"] .kpi-value { direction: ltr; text-align: right; }
