/* ========================================================
   BARKAT HOMES WATER FUND - PREMIUM DARK GLASSMORPHISM
   ======================================================== */

:root {
  --bg-main: #090d16;
  --bg-card: rgba(17, 24, 39, 0.72);
  --bg-card-hover: rgba(24, 33, 53, 0.82);
  --bg-input: rgba(15, 23, 42, 0.6);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(14, 165, 233, 0.5);
  --border-accent: rgba(14, 165, 233, 0.25);
  
  --accent-cyan: #0ea5e9;
  --accent-teal: #14b8a6;
  --accent-sky: #38bdf8;
  --accent-blue: #2563eb;

  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --text-subdued: #64748b;

  --success-bg: rgba(16, 185, 129, 0.15);
  --success-text: #34d399;
  --success-border: rgba(16, 185, 129, 0.3);

  --danger-bg: rgba(239, 68, 68, 0.15);
  --danger-text: #f87171;
  --danger-border: rgba(239, 68, 68, 0.3);

  --warning-bg: rgba(245, 158, 11, 0.15);
  --warning-text: #fbbf24;
  --warning-border: rgba(245, 158, 11, 0.3);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.15);

  --tap-min: 48px;
}

/* Base Reset & Typography */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: 
    radial-gradient(circle at 50% 0%, rgba(14, 165, 233, 0.12) 0%, transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(20, 184, 166, 0.08) 0%, transparent 50%),
    var(--bg-main);
  background-attachment: fixed;
  padding-bottom: 84px; /* Space for bottom nav on mobile */
}

/* Container */
.container {
  width: 100%;
  max-width: 520px; /* Constrained for pristine mobile focus */
  margin: 0 auto;
  padding: 16px;
}

/* Header & Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-teal));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.35);
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--accent-cyan);
  font-weight: 500;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.user-badge.admin {
  color: var(--accent-sky);
  border-color: rgba(14, 165, 233, 0.3);
  background: rgba(14, 165, 233, 0.1);
}

/* Glassmorphism Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:focus-within {
  border-color: var(--border-accent);
}

.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Overview / Metric Cards */
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 14px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.metric-card.hero {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.15), rgba(15, 23, 42, 0.85));
  border-color: rgba(14, 165, 233, 0.35);
  box-shadow: var(--shadow-glow);
  padding: 22px 18px;
}

.metric-card.hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, var(--accent-cyan), var(--accent-teal));
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.metric-card.hero .metric-value {
  font-size: 2.1rem;
  color: #38bdf8;
}

.metric-sub {
  font-size: 0.72rem;
  color: var(--text-subdued);
  margin-top: 4px;
}

/* Action Buttons (Large Touch Targets >= 48px) */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap-min);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #38bdf8, var(--accent-cyan));
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-sm {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  width: auto;
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.badge-neutral {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-control {
  width: 100%;
  min-height: var(--tap-min);
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.25);
}

.form-control::placeholder {
  color: var(--text-subdued);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 36px;
}

select.form-control option {
  background-color: #0f172a;
  color: #fff;
}

/* Transaction & Item List */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.item-card:hover {
  background: rgba(255, 255, 255, 0.06);
}

.item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.item-icon.in {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.item-icon.out {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.item-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}

.item-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.item-right {
  text-align: right;
}

.item-amount {
  font-size: 0.98rem;
  font-weight: 700;
}

.item-amount.in {
  color: #34d399;
}

.item-amount.out {
  color: #f87171;
}

.item-date {
  font-size: 0.72rem;
  color: var(--text-subdued);
}

/* Flat Grid (Flats Directory & Balances) */
.flat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.flat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-primary);
  display: block;
}

.flat-card:hover {
  border-color: var(--accent-cyan);
  background: rgba(14, 165, 233, 0.08);
}

.flat-number {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

.flat-resident {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 2px 0 4px;
}

.flat-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.flat-status-dot.paid { background-color: #10b981; }
.flat-status-dot.due { background-color: #ef4444; }
.flat-status-dot.vacant { background-color: #64748b; }

/* Alerts / Flash Messages */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

/* Offline Banner */
.offline-banner {
  background: #b45309;
  color: #fff;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px;
  display: block;
}

.offline-banner.hidden {
  display: none;
}

/* Fixed Bottom Navigation (Mobile First) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(9, 13, 22, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  width: 100%;
  height: 100%;
  gap: 3px;
  transition: color 0.15s ease;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
}

.nav-item.active {
  color: var(--accent-cyan);
}

.nav-item:active {
  background: rgba(255, 255, 255, 0.05);
}

/* Resident Big Dues Card */
.dues-card {
  text-align: center;
  padding: 26px 16px;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.dues-card.paid {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(15, 23, 42, 0.9));
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.dues-card.due {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(15, 23, 42, 0.9));
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.dues-amount {
  font-size: 2.4rem;
  font-weight: 800;
  margin: 6px 0;
  letter-spacing: -0.02em;
}

.dues-card.paid .dues-amount { color: #34d399; }
.dues-card.due .dues-amount { color: #f87171; }

/* Safe Area & Responsiveness */
@media (max-width: 480px) {
  .container {
    padding: 12px;
  }
  .card {
    padding: 16px;
  }
  .metric-value {
    font-size: 1.4rem;
  }
}

/* Reduced Motion Fallback */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
