/* ── Ananda Tasks – Main Stylesheet ───────────────────────────
   Aesthetic: Refined Mediterranean management — warm neutrals, clean lines,
   DM Serif Display headings, DM Sans body. Light theme with amber accents.
   ─────────────────────────────────────────────────────────────────────── */

:root {
  --cream:       #d7d7cf;
  --white:       #ffffff;
  --stone-50:    #f0f0ec;
  --stone-100:   #e8e8e3;
  --stone-200:   #d0d0c8;
  --stone-300:   #b8b8b0;
  --stone-500:   #6b7068;
  --stone-700:   #4a5248;
  --stone-900:   #34413c;

  --amber-50:    #f7f1e8;
  --amber-100:   #ecdfc8;
  --amber-400:   #ab8456;
  --amber-500:   #ab8456;
  --amber-600:   #96724a;
  --amber-700:   #7d5f3d;

  --red-50:      #fef2f2;
  --red-100:     #fee2e2;
  --red-500:     #ef4444;
  --red-600:     #dc2626;
  --red-700:     #b91c1c;

  --green-50:    #f0fdf4;
  --green-100:   #dcfce7;
  --green-600:   #16a34a;
  --green-700:   #15803d;

  --violet-600:  #7c3aed;
  --violet-700:  #6d28d9;

  --nav-h:       60px;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:      0 4px 12px rgba(0,0,0,.08);
  --shadow-md:   0 8px 24px rgba(0,0,0,.10);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--cream);
  color: var(--stone-900);
  min-height: 100vh;
}

/* ── Typography ─────────────────────────────────────────────────────────── */

h1, h2, h3 { font-family: 'Cormorant Garamond', 'Adobe Caslon Pro', 'Big Caslon', Georgia, serif; font-weight: 400; line-height: 1.2; }

/* ── Navbar ─────────────────────────────────────────────────────────────── */

.navbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--white);
  border-bottom: 1px solid var(--stone-200);
  display: flex; align-items: center;
  padding: 0 24px; gap: 32px;
  box-shadow: var(--shadow-sm);
}

.nav-brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.nav-logo-img { width: 28px; height: 28px; object-fit: contain; }
.nav-icon  { font-size: 20px; }
.nav-title { font-family: 'Cormorant Garamond', 'Adobe Caslon Pro', 'Big Caslon', Georgia, serif; font-size: 18px; color: var(--stone-900); white-space: nowrap; }

.nav-links  { display: flex; gap: 4px; list-style: none; flex: 1; }
.nav-links a {
  display: block; padding: 6px 14px; border-radius: 6px;
  color: var(--stone-500); font-size: 14px; font-weight: 500;
  text-decoration: none; transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-links a:hover   { background: var(--stone-100); color: var(--stone-900); }
.nav-links a.active  { background: var(--amber-100); color: var(--amber-700); }

.nav-user { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.nav-username { font-size: 14px; font-weight: 500; color: var(--stone-700); }

.btn-logout {
  font-size: 13px; color: var(--stone-500); text-decoration: none;
  padding: 4px 10px; border-radius: 5px; border: 1px solid var(--stone-200);
  transition: all .15s;
}
.btn-logout:hover { background: var(--stone-100); color: var(--stone-900); }

/* ── Main content ───────────────────────────────────────────────────────── */

.main-content { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

/* ── Flash messages ─────────────────────────────────────────────────────── */

.flash-container { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.flash {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500;
}
.flash-success { background: var(--green-100); color: var(--green-700); }
.flash-danger  { background: var(--red-100);   color: var(--red-700);   }
.flash-warning { background: var(--amber-100); color: var(--amber-700); }
.flash-info    { background: var(--stone-100); color: var(--stone-700); }

/* ── Page header ────────────────────────────────────────────────────────── */

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; gap: 16px;
}
.page-title    { font-size: 28px; color: var(--stone-900); }
.page-subtitle { font-size: 14px; color: var(--stone-500); margin-top: 2px; }
.header-actions { display: flex; gap: 8px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; border: 1px solid transparent;
  transition: all .15s; white-space: nowrap; font-family: inherit;
}
.btn-primary { background: var(--amber-500); color: var(--white); border-color: var(--amber-500); }
.btn-primary:hover { background: var(--amber-600); border-color: var(--amber-600); }
.btn-primary { border-width: 1.5px; }

.btn-outline { background: var(--white); color: var(--stone-700); border-color: var(--stone-300); }
.btn-outline:hover { background: var(--stone-100); }

.btn-danger { background: var(--red-600); color: var(--white); border-color: var(--red-600); }
.btn-danger:hover { background: var(--red-700); }

.btn-danger-outline { background: var(--white); color: var(--red-600); border-color: var(--red-100); }
.btn-danger-outline:hover { background: var(--red-50); border-color: var(--red-600); }

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-mobile-only { display: none; }  /* shown only on mobile */
.btn-full { width: 100%; }

/* ── Status bar ─────────────────────────────────────────────────────────── */

.status-bar {
  display: flex; align-items: center; gap: 0;
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--stone-200); box-shadow: var(--shadow-sm);
  padding: 16px 28px; margin-bottom: 24px; flex-wrap: wrap; gap: 8px;
}
.status-bar-alert { border-color: var(--red-200); background: var(--red-50); }
.status-bar-ok    { border-color: var(--green-100); background: var(--green-50); }

.status-bar-item  { display: flex; align-items: center; gap: 8px; }
.status-bar-number {
  font-family: 'Cormorant Garamond', 'Adobe Caslon Pro', 'Big Caslon', Georgia, serif; font-size: 32px; line-height: 1;
}
.status-bar-number.alert { color: var(--red-600); }
.status-bar-label { font-size: 14px; color: var(--stone-600); font-weight: 500; }
.status-bar-label.muted  { color: var(--stone-400); font-size: 13px; }
.status-bar-divider {
  width: 1px; height: 32px; background: var(--stone-200); margin: 0 20px;
}

/* ── Table header filter popovers ───────────────────────────────────────── */

.th-filterable { position: relative; }

.th-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}

.th-filter-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 4px; border: 1px solid transparent;
  background: transparent; cursor: pointer; color: var(--stone-400);
  transition: all .15s; flex-shrink: 0; padding: 0;
}
.th-filter-btn:hover { background: var(--stone-200); color: var(--stone-700); }
.th-filter-btn.active {
  background: var(--amber-100); border-color: var(--amber-400);
  color: var(--amber-700);
}
.th-filterable.filtered > .th-inner > .th-filter-btn {
  background: var(--amber-400); border-color: var(--amber-500); color: var(--white);
}

.th-popover {
  display: none; position: fixed; z-index: 999;
  background: var(--white); border: 1px solid var(--stone-200);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  min-width: 140px; overflow: hidden;
}
.th-popover.open { display: block; }

.th-popover-option {
  padding: 8px 14px; font-size: 13px; font-weight: 500; cursor: pointer;
  color: var(--stone-700); transition: background .1s; white-space: nowrap;
  border-bottom: 1px solid var(--stone-100);
}
.th-popover-option:last-child { border-bottom: none; }
.th-popover-option:hover    { background: var(--stone-50); }
.th-popover-option.selected {
  background: var(--amber-50); color: var(--amber-700); font-weight: 600;
}
.th-popover-option.selected::after { content: ' ✓'; }

/* ── Status pills ──────────────────────────────────────────────────────── */

.status-pill {
  display: inline-block; padding: 3px 10px; border-radius: 100px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill-overdue { background: var(--red-100);   color: var(--red-700); }
.pill-never   { background: var(--red-100);   color: var(--red-700); }
.pill-soon    { background: var(--amber-100); color: var(--amber-700); }
.pill-ok      { background: var(--green-100); color: var(--green-700); }

/* ── Dashboard table specifics ──────────────────────────────────────────── */

.dashboard-table .row-overdue { background: var(--red-50); }
.dashboard-table td:first-child { text-align: center; }
.dashboard-table .row-overdue:hover { background: #fde8e8; }
.villa-cell  { font-weight: 500; white-space: nowrap; }
.date-cell   { white-space: nowrap; font-size: 13px; }
.text-danger { color: var(--red-600); font-weight: 600; }
.text-warning{ color: var(--amber-600); font-weight: 600; }
.text-ok     { color: var(--green-600); }
.text-muted  { color: var(--stone-400); }

/* ── Badges ─────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 100px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.badge-pool     { background: var(--amber-100); color: var(--amber-700); }
.badge-property { background: var(--stone-100); color: var(--stone-700); }
.badge-freq     { background: var(--stone-100); color: var(--stone-600); }
.badge-active   { background: var(--green-100); color: var(--green-700); }
.badge-inactive { background: var(--stone-100); color: var(--stone-500); }
.badge-you      { background: var(--violet-600); color: #fff; }
.role-owner     { background: var(--amber-100); color: var(--amber-700); }
.role-manager   { background: var(--stone-100); color: var(--stone-600); }

/* ── Cards ───────────────────────────────────────────────────────────────── */

.filter-card, .form-card {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--stone-200); box-shadow: var(--shadow-sm);
  padding: 24px; margin-bottom: 24px;
}

.report-actions {
  display: flex; gap: 8px; padding-top: 16px;
  border-top: 1px solid var(--stone-100); margin-top: 16px;
}

/* ── Filters ────────────────────────────────────────────────────────────── */

.filter-form {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end;
}
.filter-form .form-group { flex: 1; min-width: 160px; margin: 0; }
.filter-actions { display: flex; gap: 8px; align-items: flex-end; }

/* ── Forms ───────────────────────────────────────────────────────────────── */

.form-group  { margin-bottom: 18px; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-check  { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.form-check input { width: 16px; height: 16px; cursor: pointer; }
.form-check label { font-size: 14px; cursor: pointer; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--stone-700); margin-bottom: 6px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="file"],
select,
textarea {
  width: 100%; padding: 9px 12px; border-radius: var(--radius);
  border: 1px solid var(--stone-300); background: var(--white);
  font-family: inherit; font-size: 14px; color: var(--stone-900);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--amber-500);
  box-shadow: 0 0 0 3px rgba(245,158,11,.15);
}
textarea { resize: vertical; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--stone-100); }

.optional  { font-weight: 400; color: var(--stone-400); }
.required  { color: var(--red-600); }

/* ── Table ───────────────────────────────────────────────────────────────── */

.table-card {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--stone-200); box-shadow: var(--shadow-sm);
  overflow: visible; margin-bottom: 24px;
}
/* Restore radius clipping on first/last cells instead of the card */
.data-table thead tr:first-child th:first-child { border-radius: var(--radius-lg) 0 0 0; }
.data-table thead tr:first-child th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }
.data-table tbody tr:last-child td:first-child  { border-radius: 0 0 0 var(--radius-lg); }
.data-table tbody tr:last-child td:last-child   { border-radius: 0 0 var(--radius-lg) 0; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead tr { background: var(--stone-50); border-bottom: 1px solid var(--stone-200); }
.data-table th {
  padding: 11px 16px; text-align: left; font-size: 12px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--stone-500);
}
.data-table td { padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--stone-100); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--stone-50); }
.row-inactive { opacity: .55; }
.notes-cell { max-width: 220px; color: var(--stone-500); font-size: 13px; }
.task-name-cell { font-weight: 500; }
.task-desc { font-size: 12px; color: var(--stone-400); margin-top: 2px; }
.actions-cell { white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.result-count { padding: 10px 16px; font-size: 13px; color: var(--stone-500); border-bottom: 1px solid var(--stone-100); }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px; border: none;
  cursor: pointer; font-size: 13px; font-weight: 700; transition: all .15s;
  background: transparent;
}
.btn-icon-danger { color: var(--red-500); }
.btn-icon-danger:hover { background: var(--red-50); color: var(--red-700); }

/* ── Pagination ─────────────────────────────────────────────────────────── */

.pagination {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 16px;
}
.page-info { font-size: 13px; color: var(--stone-500); }

/* ── Empty state ────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center; padding: 64px 24px;
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--stone-200);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { color: var(--stone-500); margin-bottom: 20px; }

/* ── Info/example boxes ─────────────────────────────────────────────────── */

.info-box {
  background: var(--amber-50); border: 1px solid var(--amber-100);
  border-radius: var(--radius); padding: 14px 16px;
  font-size: 13px; color: var(--stone-700); margin-bottom: 20px; line-height: 1.6;
}
.csv-example {
  background: var(--stone-50); border: 1px solid var(--stone-200);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px; font-size: 13px;
}
.csv-example pre { margin-top: 8px; font-size: 12px; overflow-x: auto; }

/* ── Auth page ──────────────────────────────────────────────────────────── */

.auth-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--cream);
}
.auth-card {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--stone-200); box-shadow: var(--shadow-md);
  padding: 40px; width: 100%; max-width: 400px;
}
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-logo   { margin-bottom: 8px; }
.auth-logo-img { width: 64px; height: 64px; object-fit: contain; }
.auth-title  { font-size: 26px; }
.auth-subtitle { color: var(--stone-500); font-size: 14px; margin-top: 4px; }
.auth-form .form-group { margin-bottom: 18px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-box {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 32px; width: 100%; max-width: 420px; box-shadow: var(--shadow-md);
}
.modal-title { font-size: 20px; margin-bottom: 20px; }

/* ── Responsive ─────────────────────────────────────────────────────────── */

/* ── Hamburger button ────────────────────────────────────────────────────── */

.nav-hamburger {
  display: none;
  flex-direction: column; justify-content: center; gap: 5px;
  width: 36px; height: 36px; padding: 6px;
  background: transparent; border: 1px solid var(--stone-200);
  border-radius: 6px; cursor: pointer; flex-shrink: 0;
}
.nav-hamburger span {
  display: block; height: 2px; background: var(--stone-900);
  border-radius: 2px; transition: all .2s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile slide-down menu ─────────────────────────────────────────────── */

.mobile-menu {
  display: none;
  background: var(--white);
  border-bottom: 1px solid var(--stone-200);
  box-shadow: var(--shadow);
}
.mobile-menu.open { display: block; }

.mobile-nav-links {
  list-style: none; padding: 8px 0; margin: 0;
}
.mobile-nav-links li a {
  display: block; padding: 12px 20px;
  font-size: 15px; font-weight: 500; color: var(--stone-700);
  text-decoration: none; border-left: 3px solid transparent;
  transition: all .15s;
}
.mobile-nav-links li a:hover  { background: var(--stone-50); color: var(--stone-900); }
.mobile-nav-links li a.active { background: var(--amber-50); color: var(--amber-700);
  border-left-color: var(--amber-500); }

.mobile-menu-signout { border-top: 1px solid var(--stone-100); margin-top: 4px; }
.mobile-menu-signout a {
  display: block; padding: 12px 20px;
  font-size: 15px; font-weight: 500; color: var(--stone-500);
  text-decoration: none; transition: background .15s;
}
.mobile-menu-signout a:hover { background: var(--stone-50); color: var(--stone-700); }

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Navbar */
  .navbar        { padding: 0 16px; width: 100%; box-sizing: border-box; }
  .nav-links     { display: none !important; }
  .nav-username  { display: none !important; }
  .btn-logout    { display: none !important; }
  .nav-hamburger { display: flex !important; margin-left: auto; }

  /* Layout */
  .main-content  { padding: 16px 12px; }
  .form-row      { grid-template-columns: 1fr; }
  .filter-form   { flex-direction: column; }
  .page-header   { flex-direction: column; gap: 12px; }

  /* Status bar: compact + hide totals and both dividers */
  .status-bar             { padding: 12px 16px; gap: 6px; }
  .status-bar-number      { font-size: 24px; }
  .status-bar-label       { font-size: 13px; }
  .status-bar-total       { display: none !important; }
  .status-bar-divider     { display: none !important; }

  /* Dashboard table: tighter cells, hide less-critical columns */
  .dashboard-table th,
  .dashboard-table td     { padding: 8px 10px; }

  .dashboard-table th.col-freq,
  .dashboard-table th.col-last,
  .dashboard-table th.col-next,
  .dashboard-table td.col-freq,
  .dashboard-table td.col-last,
  .dashboard-table td.col-next { display: none !important; }

  /* Status header: hide label text, keep filter icon */
  .th-label-text          { display: none !important; }

  /* Status column: font-size:0 hides text, ::before shows dot */
  .status-pill            { font-size: 0 !important; padding: 0;
                            background: transparent !important; }
  .status-pill::before    { font-size: 16px; line-height: 1; }
  .pill-overdue::before,
  .pill-never::before     { content: '🔴'; }
  .pill-soon::before      { content: '🟡'; }
  .pill-ok::before        { content: '🟢'; }

  /* Mark Complete button: checkmark only on mobile */
  .btn-desktop-only { display: none !important; }
  .btn-mobile-only  { display: inline-flex !important; }
  .btn-icon-only    { padding: 5px 12px; font-size: 16px; font-weight: 700;
                      min-width: 38px; justify-content: center; }

  /* Table card: no radius clipping needed */
  .table-card             { overflow-x: auto; }
}

@media (max-width: 480px) {
  .page-header { flex-direction: column; }
}
