/* 
 * Sree Indivar Villas (SIVOA) Design System
 * Mobile-First, Modern, Typeform-Inspired Aesthetics
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Color Palette */
  --bg-primary: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-card-hover: rgba(51, 65, 85, 0.9);
  --bg-input: #1e293b;
  --border-color: rgba(255, 255, 255, 0.1);
  --border-glow: rgba(99, 102, 241, 0.3);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  /* Accent Colors */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --success-border: rgba(16, 185, 129, 0.4);
  
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --warning-border: rgba(245, 158, 11, 0.4);
  
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --danger-border: rgba(239, 68, 68, 0.4);

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

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Light Theme Overrides (if needed) */
body.light-theme {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Top App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #6366f1, #10b981);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.brand-title {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.3px;
  color: var(--text-main);
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Main Container */
.main-container {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  touch-action: manipulation;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
.btn-primary:active {
  transform: scale(0.97);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-whatsapp {
  background: #25D366;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.3);
  font-weight: 700;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 24px;
  font-size: 16px;
  border-radius: var(--radius-md);
  width: 100%;
}

/* Typeform-Style Wizard Cards */
.typeform-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
  margin-bottom: 20px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.step-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.step-pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.step-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
  margin-bottom: 6px;
  color: var(--text-main);
}

.step-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Form Controls */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.form-select, .form-input, .form-textarea {
  width: 100%;
  padding: 14px 16px;
  font-family: var(--font-main);
  font-size: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-select:focus, .form-input:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--border-glow);
}

/* Checkbox Grid for Months */
.months-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.month-checkbox-card {
  position: relative;
}

.month-checkbox-card input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.month-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.month-checkbox-card input[type="checkbox"]:checked + .month-label {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.2);
}

.month-checkbox-card input[type="checkbox"]:disabled + .month-label {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.02);
}

.month-name {
  font-weight: 700;
  font-size: 14px;
}

.month-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
}
.dot-paid { background-color: var(--success); }
.dot-pending { background-color: var(--warning); }
.dot-due { background-color: var(--danger); }

/* QR Code Box */
.qr-box-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 20px;
  border-radius: var(--radius-lg);
  margin: 16px 0;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.qr-image {
  width: 200px;
  height: 200px;
  object-fit: contain;
}

.upi-id-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #1e293b;
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-family: monospace;
  font-size: 15px;
  font-weight: 700;
  margin-top: 12px;
}

/* File Upload Zone */
.upload-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  background: rgba(30, 41, 59, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-dropzone:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.preview-thumbnail {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-md);
  margin-top: 12px;
  display: none;
  object-fit: contain;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

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

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

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

/* Current Month Column Highlight in Spreadsheet */
.matrix-table th.current-month-col {
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.4), rgba(99, 102, 241, 0.2)) !important;
  border-left: 2px solid var(--primary);
  border-right: 2px solid var(--primary);
  border-top: 3px solid var(--primary);
  color: #ffffff !important;
  font-weight: 800;
  box-shadow: 0 -4px 12px rgba(99, 102, 241, 0.4);
  position: relative;
  z-index: 10;
}

.matrix-table th.current-month-col::after {
  content: '📍 CURRENT';
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #38bdf8;
  background: rgba(15, 23, 42, 0.85);
  padding: 1px 4px;
  border-radius: 4px;
  margin-top: 2px;
}

.matrix-table td.current-month-col {
  background-color: rgba(99, 102, 241, 0.09) !important;
  border-left: 2px solid rgba(99, 102, 241, 0.35);
  border-right: 2px solid rgba(99, 102, 241, 0.35);
}

.matrix-table tr:hover td.current-month-col {
  background-color: rgba(99, 102, 241, 0.2) !important;
}

.badge-current-legend {
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.5);
  font-weight: 700;
}

/* Responsive Table / Matrix View */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  position: relative;
}

.matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  font-size: 13px;
}

.matrix-table th, .matrix-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.matrix-table th {
  background: #0f172a;
  font-weight: 700;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Sticky First Column (Villa #) for Mobile & Desktop */
.matrix-table .sticky-col {
  position: sticky;
  left: 0;
  z-index: 15;
  background: #1e293b !important;
  border-right: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 4px 0 10px rgba(0, 0, 0, 0.35);
}

.matrix-table th.sticky-col {
  z-index: 25;
  background: #0f172a !important;
}

.matrix-table tr:hover td.sticky-col {
  background: #334155 !important;
}

/* Mobile Villa Cards (Alternative Matrix for small screens) */
.mobile-villa-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}

.villa-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.villa-number {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.villa-months-pills {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.month-pill {
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

/* Stats Overview Header */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.stat-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
}

.stat-lbl {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

/* Modal Popup */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  padding: 24px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

/* Admin Subpage Tab Styles */
.admin-tab-btn {
  background: #1e293b !important;
  color: #94a3b8 !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  padding: 10px 20px !important;
  border-radius: var(--radius-md) !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
}

.admin-tab-btn:hover {
  border-color: #6366f1 !important;
  color: #f8fafc !important;
  background: #334155 !important;
}

.admin-tab-btn.active {
  background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
  color: #ffffff !important;
  border-color: #818cf8 !important;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.5) !important;
  font-weight: 800 !important;
}
