/* ========================================
   UNIFIED PROFESSIONAL CSS 1.2 - CRITICAL FIX
   Senior Assistance System
   
   Fixes Applied:
   - Login Page Usability (Restored inputs, labels, and buttons)
   - Contrast Fix (Resolved white-on-white text in cards)
   - Layout Squashing (Added flex-wrap for split screens)
   - Maintained all Admin Dashboard fixes from v1.1
   ======================================== */

/* 1. CSS RESET & BASE */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Colors */
  --bg: #0b1220;
  --bg-alt: #0f1724;
  --surface: rgba(255,255,255,0.06);
  --border: rgba(255,255,255,0.14);
  --text: rgba(255,255,255,0.92);
  --text-alt: rgba(255,255,255,0.72);
  --primary: #4a90e2;
  --primary-alt: #2575fc;
  --success: #27ae60;
  --danger: #e94b3c;
  --warning: #f39c12;
  
  /* Layout */
  --sidebar-w: 260px;
  --sidebar-w-min: 72px;
  --radius: 12px;
  --trans-all: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Prevent scrolling when mobile sidebar is open */
body:has(.sidebar.open) { overflow: hidden; }


/* ========================================
   2. CRITICAL UI & LOGIN FIXES
   ======================================== */

/* Fix invisible inputs & textareas stripped by Tailwind */
input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
  width: 100%;
  padding: 0.85rem 1rem;
  background-color: #ffffff !important; /* Force visible background */
  color: #111827 !important; /* Force readable text */
  border: 1px solid #cbd5e1 !important; /* Force visible borders */
  border-radius: 8px;
  outline: none;
  display: block;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.25) !important;
}

/* Fix invisible buttons stripped by Tailwind */
button, input[type="submit"], input[type="button"], .btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.85rem 1.5rem;
  background-color: var(--primary);
  color: #ffffff !important;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: background-color 0.2s, transform 0.1s;
}

button:hover, input[type="submit"]:hover, .btn:hover { background-color: var(--primary-alt); }
button:active { transform: scale(0.98); }

/* CONTRAST FIX: Fixes "White text on White background" inside cards */
.bg-white, .card-white, [class*="bg-white"] {
  background-color: #ffffff !important;
  color: #1f2937 !important;
}

.bg-white h1, .bg-white h2, .bg-white h3, .bg-white h4, .bg-white p, .bg-white label, .bg-white span {
  color: #1f2937 !important;
}

/* General Layout Fixes for Login & App Download Split-Screen */
/* (This stops elements from squashing together on mobile) */
.flex-container, .login-wrapper, .container {
  display: flex;
  flex-wrap: wrap !important; /* CRITICAL: Allows items to wrap on phones */
  gap: 2rem;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.flex-container > div, .login-wrapper > div {
  flex: 1 1 350px !important; /* Let cards shrink/grow but default to 350px */
  max-width: 450px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
label { display: block; font-weight: 600; margin-bottom: 0.5rem; }


/* ========================================
   3. ADMIN DASHBOARD & SIDEBAR 
   (Retained from enhanced CSS 1.1)
   ======================================== */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(180deg, rgba(6,6,10,0.95), rgba(10,10,18,0.92));
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  z-index: 1000;
  transition: var(--trans-all);
  overflow-y: auto;
  overflow-x: hidden; 
}

.sidebar.collapsed {
  width: var(--sidebar-w-min);
  padding: 16px 12px;
}

.logo-section {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.logo-section img {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
  transition: var(--trans-all);
}

.sidebar.collapsed .logo-section img { width: 48px; height: 48px; }
.sidebar.collapsed .logo-section h2 { opacity: 0; transform: translateX(-12px); pointer-events: none; }

.sidebar-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  color: var(--text-alt);
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 500;
  transition: var(--trans-all);
  white-space: nowrap;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

/* Mobile Overlay Fix */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
  z-index: 1999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
body:has(.sidebar.open)::after { opacity: 1; visibility: visible; pointer-events: auto; }

@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 2000;
  }
  .sidebar.open { transform: translateX(0); }
}

.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: var(--trans-all);
}

.sidebar.collapsed ~ .main-wrapper { margin-left: var(--sidebar-w-min); }
@media (max-width: 992px) { .main-wrapper { margin-left: 0; } }

.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 900;
}

/* Stat Cards & Charts (Fixes Grid Blowouts) */
.stat-card { 
  background: var(--surface); 
  border: 1px solid var(--border); 
  border-radius: 12px; 
  padding: 1.5rem; 
  display: flex; 
  flex-direction: column; 
  height: 100%; 
  position: relative; 
  z-index: 1;
  min-width: 0; 
}

.charts-grid { 
  display: grid; 
  grid-template-columns: 2fr 1fr 1fr; 
  gap: 1.5rem; 
  margin-top: 2rem; 
}
.chart-panel { 
  background: var(--surface); 
  border: 1px solid var(--border); 
  border-radius: 12px; 
  padding: 1.5rem; 
  min-width: 0; 
}

@media (max-width: 1400px) { 
  .charts-grid { grid-template-columns: 1fr 1fr; } 
  .chart-panel:first-child { grid-column: span 2; } 
}
@media (max-width: 992px) { 
  .charts-grid { grid-template-columns: 1fr; } 
  .chart-panel:first-child { grid-column: span 1; } 
}