/* ============================================================
   Household Manager Design System
   Redesigned with IO Planner specifications
   ============================================================ */

/* ---- Design Tokens --------------------------------------------------- */
:root {
  /* Primary Brand Colors (IO Planner inspired - adapted for Household Manager) */
  --primary:        #009687;   /* Teal green - primary actions */
  --primary-bright: #18A689;   /* Bright green - hover states */
  --primary-dark:   #007A6E;   /* Pressed/dense */
  
  /* Secondary Colors */
  --turkis:         #9DCECD;   /* Secondary accent */
  --mint:           #E5F4F2;   /* Subtle backgrounds */
  --navy:           #2E404F;   /* Primary text, headers */
  
  /* Neutral Grays */
  --gray-50:   #F8FAFB;
  --gray-100:  #F1F2F4;
  --gray-200:  #E4E7EB;
  --gray-300:  #CDD2D8;
  --gray-400:  #A4ACB5;
  --gray-500:  #717B86;
  --gray-600:  #4F5862;
  --gray-700:  #353D45;
  --gray-800:  #232930;
  --gray-900:  #14181C;
  
  /* Semantic Surfaces */
  --bg-app:        #F1F1F1;   /* App canvas */
  --bg-surface:    #FFFFFF;   /* Cards, panels */
  --bg-surface-2:  #F8FAFB;   /* Sub-panel, inputs */
  --bg-tinted:     #E5F4F2;   /* Brand-tinted */
  
  /* Borders */
  --border-subtle:  #E4E7EB;
  --border-default: #CDD2D8;
  --border-strong:  #A4ACB5;
  
  /* Text Colors */
  --text-primary:   #2E404F;   /* Body & headings */
  --text-secondary: #4F5862;   /* Supporting copy */
  --text-muted:     #717B86;   /* Labels, hints */
  --text-inverse:   #FFFFFF;
  
  /* Status Colors */
  --success:       #18A689;
  --success-bg:    #E5F4F2;
  --success-fg:    #00766A;
  
  --warning:       #F0AD4E;
  --warning-bg:    #FDF3E3;
  --warning-fg:    #8A5A0E;
  
  --danger:        #E55353;
  --danger-bg:     #FCEBEB;
  --danger-fg:     #9F2C2C;
  
  /* Typography */
  --font-sans: 'Open Sans', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  
  /* Type Scale */
  --fs-xs:   0.75rem;    /* 12px */
  --fs-sm:   0.875rem;   /* 14px */
  --fs-base: 1rem;       /* 16px */
  --fs-lg:   1.125rem;   /* 18px */
  --fs-xl:   1.25rem;    /* 20px */
  --fs-2xl:  1.5rem;     /* 24px */
  --fs-3xl:  2rem;       /* 32px */
  
  /* Line Heights */
  --lh-tight:  1.15;
  --lh-snug:   1.3;
  --lh-base:   1.5;
  
  /* Font Weights */
  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;
  --fw-extra:    800;
  
  /* Spacing (4px base) */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  
  /* Border Radius */
  --radius-xs:   2px;
  --radius-sm:   4px;
  --radius-md:   6px;
  --radius-lg:   10px;
  --radius-xl:   16px;
  --radius-pill: 999px;
  
  /* Shadows (calm, navy-tinted) */
  --shadow-xs: 0 1px 1px rgba(46, 64, 79, 0.04);
  --shadow-sm: 0 1px 2px rgba(46, 64, 79, 0.06);
  --shadow-md: 0 2px 4px rgba(46, 64, 79, 0.06), 0 4px 12px rgba(46, 64, 79, 0.06);
  --shadow-lg: 0 8px 16px rgba(46, 64, 79, 0.08), 0 16px 32px rgba(46, 64, 79, 0.06);
  --shadow-focus: 0 0 0 3px rgba(0, 150, 135, 0.25);
  
  /* Transitions */
  --ease-standard: cubic-bezier(0.2, 0.0, 0, 1);
  --dur-1: 120ms;
  --dur-2: 180ms;
  --dur-3: 240ms;
}

/* ============================================================
   Base Styles
   ============================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--lh-base);
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Typography */
h1, .h1 {
  font-size: var(--fs-3xl);
  line-height: var(--lh-tight);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  margin: 0;
}

h2, .h2 {
  font-size: var(--fs-2xl);
  line-height: var(--lh-snug);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin: 0;
}

h3, .h3 {
  font-size: var(--fs-xl);
  line-height: var(--lh-snug);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin: 0;
}

h4, .h4 {
  font-size: var(--fs-base);
  line-height: var(--lh-snug);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin: 0;
}

.eyebrow {
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
}

p {
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
  color: var(--text-primary);
}

.small {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.caption {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

a {
  color: var(--primary-dark);
  text-decoration: none;
  transition: color var(--dur-2) var(--ease-standard);
}

a:hover {
  color: var(--primary);
}

/* ============================================================
   Layout
   ============================================================ */
.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

@media (max-width: 768px) {
  .container {
    padding: 0 var(--space-4);
  }
}

.main-content {
  padding: var(--space-10) 0;
  min-height: calc(100vh - 200px);
}

@media (max-width: 768px) {
  .main-content {
    padding: var(--space-8) 0;
  }
}

/* ============================================================
   Header
   ============================================================ */
.header {
  background: var(--navy);
  color: var(--text-inverse);
  padding: var(--space-4) 0;
  box-shadow: var(--shadow-sm);
}

.header .container {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.header-title {
  flex: 1;
  min-width: 0;
}

.header-title h1 {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 50px;
}

.header-logo {
  height: 50px;
  width: auto;
  object-fit: contain;
  vertical-align: middle;
  margin-right: var(--space-2);
}

.header h1 {
  color: var(--text-inverse);
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
}

.header .location-subtitle {
  font-weight: var(--fw-regular);
  opacity: 0.8;
  font-size: var(--fs-sm);
}

.header .search-wrapper {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.header .search-form {
  display: flex;
  align-items: center;
}

.header .search-input {
  padding: var(--space-2) var(--space-4);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.15);
  color: var(--text-inverse);
  font-size: var(--fs-sm);
  width: 220px;
  transition: all var(--dur-2) var(--ease-standard);
}

.header .search-input::placeholder {
  color: rgba(255,255,255,0.6);
}

.header .search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255,255,255,0.2);
  box-shadow: var(--shadow-focus);
}

@media (max-width: 768px) {
  .header .container {
    flex-direction: column;
    gap: var(--space-3);
    align-items: stretch;
  }
  
  .header-title {
    text-align: center;
  }
  
  .header-title h1 {
    white-space: normal;
    line-height: 1.3;
  }
  
  .header-logo {
    height: 40px;
    vertical-align: middle;
  }
  
  .header .search-wrapper {
    width: 100%;
    justify-content: center;
  }
  
  .header .search-input {
    width: 100%;
    max-width: 300px;
  }
}

/* ============================================================
   Navigation
   ============================================================ */
.nav {
  background: var(--bg-surface);
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.nav ul {
  list-style: none;
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
}

.nav-spacer {
  margin-left: auto;
}

.nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: var(--fw-medium);
  font-size: var(--fs-sm);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  transition: all var(--dur-2) var(--ease-standard);
  display: inline-block;
}

.nav a:hover {
  color: var(--primary);
  background: var(--mint);
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  background: #1e2e3a;
  color: rgba(255,255,255,0.45);
  padding: var(--space-6) 0;
  text-align: center;
  font-size: var(--fs-xs);
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
}

@media (max-width: 768px) {
  .card {
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }
}

.card-title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  color: var(--navy);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--dur-2) var(--ease-standard);
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--primary-bright);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 150, 135, 0.35);
}

.btn-secondary {
  background: transparent;
  color: var(--navy);
  border: 2px solid var(--border-subtle);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--mint);
}

.btn-success {
  background: var(--success);
  color: var(--text-inverse);
}

.btn-danger {
  background: var(--danger);
  color: var(--text-inverse);
}

.btn-danger:hover {
  background: #c43d3d;
}

.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: 0.8125rem;
}

.btn:disabled {
  background: var(--gray-200);
  color: var(--gray-400);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

@media (max-width: 768px) {
  .btn {
    padding: var(--space-2) var(--space-5);
    font-size: 0.8125rem;
  }
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
  margin-bottom: var(--space-5);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  font-size: var(--fs-sm);
}

.form-control {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: all var(--dur-2) var(--ease-standard);
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

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

textarea.form-control {
  min-height: 140px;
  resize: vertical;
  line-height: var(--lh-base);
}

select.form-control {
  cursor: pointer;
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-5);
  font-weight: var(--fw-medium);
  font-size: var(--fs-sm);
  border-left: 4px solid;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-fg);
  border-left-color: var(--success);
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border-left-color: var(--danger);
}

.alert-info {
  background: var(--bg-tinted);
  color: var(--primary-dark);
  border-left-color: var(--primary);
}

/* ============================================================
   Tables
   ============================================================ */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: var(--fs-sm);
}

.table th,
.table td {
  padding: var(--space-4) var(--space-5);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.table th {
  background: var(--navy);
  color: var(--text-inverse);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover {
  background: var(--gray-100);
}

@media (max-width: 768px) {
  .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.8125rem;
  }
  
  .table th,
  .table td {
    padding: var(--space-3) var(--space-4);
  }
}

/* ============================================================
   Grid System
   ============================================================ */
.grid {
  display: grid;
  gap: var(--space-8);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Item Cards
   ============================================================ */
.item-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all var(--dur-2) var(--ease-standard);
  border: 1px solid var(--border-subtle);
}

.item-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.item-card-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-surface);
  transition: all var(--dur-2) var(--ease-standard);
}

.item-card:hover .item-card-image {
  filter: brightness(1.03);
}

.item-card-body {
  padding: var(--space-5);
}

.item-card-title {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  line-height: var(--lh-snug);
}

.item-card-title a {
  color: inherit;
  text-decoration: none;
}

.item-card-title a:hover {
  color: var(--primary);
}

.item-card-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

/* ============================================================
   Images & Galleries
   ============================================================ */
.thumbnail {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-5);
  margin-top: var(--space-5);
}

@media (max-width: 640px) {
  .image-gallery {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--space-4);
  }
}

.image-gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--dur-2) var(--ease-standard);
  background: var(--bg-surface);
}

.image-gallery img:hover {
  border-color: var(--primary);
  transform: scale(1.02);
  box-shadow: var(--shadow-md);
  filter: brightness(1.05);
}

.image-gallery img.primary {
  border-color: var(--primary);
  border-width: 2px;
}

.image-gallery div {
  position: relative;
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: var(--fw-semibold);
  background: var(--primary);
  color: var(--text-inverse);
}

.badge-success {
  background: var(--success);
}

/* ============================================================
   Lists
   ============================================================ */
.link-list,
.file-list {
  list-style: none;
}

.link-list li,
.file-list li {
  margin-bottom: var(--space-2);
  padding: var(--space-3);
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.link-list a {
  color: var(--primary);
  text-decoration: none;
  font-weight: var(--fw-medium);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.link-list a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .file-list li,
  .link-list li {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .file-list li > div:last-child,
  .link-list li > div:last-child {
    width: 100%;
    display: flex;
    gap: var(--space-2);
  }
  
  .file-list li > div:last-child form,
  .link-list li > div:last-child form {
    flex: 1;
  }
  
  .file-list li > div:last-child button,
  .link-list li > div:last-child button,
  .file-list li > div:last-child a,
  .link-list li > div:last-child a {
    flex: 1;
    text-align: center;
  }
}

/* ============================================================
   Breadcrumb
   ============================================================ */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-5);
  font-size: var(--fs-sm);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
  font-weight: var(--fw-medium);
  transition: color var(--dur-2) var(--ease-standard);
}

.breadcrumb a:hover {
  color: var(--primary-dark);
}

.breadcrumb-separator {
  color: var(--text-muted);
  margin: 0 var(--space-2);
}

/* ============================================================
   Empty States
   ============================================================ */
.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-6);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: var(--space-5);
  opacity: 0.4;
}

.empty-state-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  color: var(--navy);
  margin-bottom: var(--space-2);
}

.empty-state p {
  max-width: 400px;
  margin: 0 auto var(--space-5);
  color: var(--text-secondary);
}

/* ============================================================
   Utilities
   ============================================================ */
hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-10) 0;
}

input[type="file"] {
  padding: var(--space-2);
  background: var(--bg-surface);
}

input[type="date"] {
  min-width: 150px;
}

/* Tabular numerics for data */
.num, .tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1, 'lnum' 1;
}

/* ============================================================
   Mobile Adjustments
   ============================================================ */
@media (max-width: 640px) {
  .header h1 {
    font-size: var(--fs-xl);
  }
  
  .nav ul {
    gap: var(--space-2);
  }
  
  .nav a {
    font-size: 0.8125rem;
    padding: var(--space-2) var(--space-2);
  }
  
  .btn {
    width: 100%;
    margin-bottom: var(--space-2);
  }
  
  .btn + .btn {
    margin-left: 0;
  }
  
  form .btn[type="submit"] {
    width: 100%;
  }
  
  form div[style*="display: flex"] {
    flex-direction: column;
  }
  
  form div[style*="display: flex"] .btn {
    width: 100%;
    margin-bottom: var(--space-2);
  }
}
