/* Retro Pixel-Art Design System - Base Styles */

/* Import DM Mono font from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&display=swap');

/* CSS Custom Properties (Variables) */
:root {
  /* Colors - Clean Black/White with Teal Accent */
  --color-primary: #14b8a6;
  --color-primary-dark: #0d9488;
  --color-primary-light: #5eead4;
  --color-secondary: #64748b;
  --color-accent: #14b8a6;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;

  --color-bg-dark: #000000;
  --color-bg-medium: #ffffff;
  --color-bg-light: #f8fafc;
  --color-text: #0f172a;
  --color-text-muted: #64748b;

  --color-border: #e2e8f0;
  --color-shadow: rgba(0, 0, 0, 0.1);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;

  /* Typography */
  --font-family: 'DM Mono', monospace;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;

  /* Border radius for pixel effect */
  --border-radius-sm: 2px;
  --border-radius-md: 4px;

  /* Animation */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg-dark: #ffffff;
    --color-bg-medium: #1a1a1a;
    --color-bg-light: #2d2d2d;
    --color-text: #e5e7eb;
    --color-text-muted: #94a3b8;
    --color-border: #404040;
    --color-shadow: rgba(0, 0, 0, 0.5);
  }
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg-light);
  overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-md) 0;
  font-weight: 500;
  line-height: 1.2;
  color: var(--color-text);
}

h1 {
  font-size: var(--font-size-2xl);
}

h2 {
  font-size: var(--font-size-xl);
}

h3 {
  font-size: var(--font-size-lg);
}

p {
  margin: 0 0 var(--space-md) 0;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

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

/* Layout */
main {
  max-width: 1024px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-md);
  min-height: calc(100vh - 120px);
}
/* Retro Pixel-Art Design System - Component Styles */

/* Navigation */
nav {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  max-width: 1024px;
  margin: 0 auto;
  padding: var(--space-md);
  background: var(--color-bg-medium);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 3px var(--color-shadow);
}

nav > div {
  display: flex;
  flex-direction: row;
  gap: var(--space-md);
  align-items: center;
}

nav a {
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text);
  font-weight: 500;
  font-size: var(--font-size-lg);
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-normal);
  min-height: 44px;
}

nav a:hover {
  color: var(--color-primary);
  background: var(--color-bg-light);
}

/* Dropdown Menu */
nav details {
  position: relative;
}

nav summary {
  cursor: pointer;
  list-style: none;
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text);
  font-weight: 500;
  font-size: var(--font-size-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  background: var(--color-bg-medium);
  transition: all var(--transition-normal);
  min-height: 44px;
  display: flex;
  align-items: center;
}

nav summary:hover {
  background: var(--color-bg-light);
  border-color: var(--color-primary);
}

nav summary::-webkit-details-marker {
  display: none;
}

nav summary::after {
  content: ' ▼';
  font-size: var(--font-size-xs);
  margin-left: var(--space-sm);
}

nav details[open] summary::after {
  content: ' ▲';
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-sm));
  background: var(--color-bg-medium);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  list-style: none;
  padding: var(--space-sm);
  margin: 0;
  min-width: 200px;
  max-width: calc(100vw - 2rem);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  z-index: 1000;
}

.dropdown-menu li {
  margin: var(--space-xs) 0;
  min-height: 44px;
}

.dropdown-menu a {
  display: flex;
  align-items: center;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text);
  font-weight: 500;
  font-size: var(--font-size-lg);
  text-align: left;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
  min-height: 44px;
}

.dropdown-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-weight: 500;
  font-size: var(--font-size-lg);
  text-align: left;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
  min-height: 44px;
}

.dropdown-menu a:hover {
  background: var(--color-bg-light);
  color: var(--color-primary);
}

.dropdown-menu button:hover {
  /* Button hover styles come from base button styles */
}

/* Buttons */
button,
input[type="submit"],
input[type="button"],
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 500;
  color: white;
  background: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-normal);
  min-height: 44px;
  text-align: center;
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
.button:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

button:active,
input[type="submit"]:active,
input[type="button"]:active,
.button:active {
  background: var(--color-primary-dark);
}

button:disabled,
input[type="submit"]:disabled,
input[type="button"]:disabled,
.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Button Variants */
.button-secondary {
  background: var(--color-secondary);
  border-color: var(--color-secondary);
  color: white;
}

.button-secondary:hover {
  background: #475569;
  border-color: #475569;
  color: white;
}

.button-danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: white;
}

.button-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
}

.button-small {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-sm);
  min-height: 44px;
}

/* Forms */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-family);
  font-size: var(--font-size-lg);
  color: var(--color-text);
  background: var(--color-bg-medium);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--color-primary);
}

label {
  display: block;
  margin-bottom: var(--space-xs);
  color: var(--color-text);
  font-weight: 500;
  font-size: var(--font-size-lg);
}

.field {
  margin-bottom: var(--space-lg);
}

/* Meals Section */
#list-meals label {
  font-size: var(--font-size-xl);
  font-weight: 500;
}

/* Cards and Containers */
.card {
  background: var(--color-bg-medium);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.card-header {
  margin: calc(-1 * var(--space-lg)) calc(-1 * var(--space-lg)) var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-light);
  border-bottom: 1px solid var(--color-border);
}

.card-header h2,
.card-header h3 {
  margin: 0;
}

.card-content {
  padding: 0 var(--space-lg) var(--space-lg);
}

/* Collapsible card (details element) */
details.card {
  padding: 0;
}

details.card summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background var(--transition-fast);
  margin: 0;
}

details.card summary::-webkit-details-marker {
  display: none;
}

details.card summary:hover {
  background: #f1f5f9;
}

details.card summary h2::after {
  content: ' ▼';
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-left: var(--space-sm);
  transition: transform var(--transition-fast);
  display: inline-block;
}

details.card[open] summary h2::after {
  transform: rotate(-180deg);
}

/* Lists */
ul, ol {
  padding-left: var(--space-xl);
}

ul.no-bullets {
  list-style: none;
  padding: 0;
}

/* Notices and Alerts */
.notice,
.alert {
  max-width: 1024px;
  margin: 0 auto var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  border: 1px solid;
  border-radius: var(--border-radius-md);
  font-weight: 400;
}

.notice {
  color: var(--color-primary-dark);
  background: rgba(20, 184, 166, 0.1);
  border-color: var(--color-primary);
}

.alert {
  color: #991b1b;
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--color-danger);
}

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  overflow: hidden;
}

thead {
  background: var(--color-bg-light);
}

th {
  padding: var(--space-md);
  text-align: left;
  color: var(--color-text);
  font-weight: 500;
  border-bottom: 1px solid var(--color-border);
}

td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

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

tbody tr {
  background: var(--color-bg-medium);
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: var(--color-bg-light);
}

/* Item Display */
section.item {
  display: flex;
  gap: var(--space-lg);
  flex-direction: row;
  padding: var(--space-lg);
  background: var(--color-bg-medium);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  margin-bottom: var(--space-lg);
}

section.item img {
  border-radius: var(--border-radius-md);
  border: 1px solid var(--color-border);
  flex-basis: 50%;
  max-width: 50%;
  object-fit: cover;
}

/* Groups */
.groups-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}

.group-card {
  position: relative;
  background: var(--color-bg-medium);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  padding: var(--space-lg);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  transition: all var(--transition-normal);
}

.group-card-selected {
  background: rgba(20, 184, 166, 0.05);
  border-color: var(--color-primary);
  border-width: 2px;
}

.group-radio {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.group-radio h3 {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: 500;
}

.selected-badge {
  position: absolute;
  top: -1px;
  right: var(--space-lg);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-primary);
  color: white;
  border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.group-actions {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  align-items: center;
}

.group-actions a {
  color: var(--color-primary);
  padding: var(--space-sm) var(--space-md);
}

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

.group-actions a.button-danger {
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.group-actions a.button-danger:hover {
  color: white;
}

.group-actions button[data-turbo-confirm],
.group-actions form[data-turbo-confirm] button,
form[data-turbo-confirm] button {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: white;
}

.group-actions button[data-turbo-confirm]:hover,
.group-actions form[data-turbo-confirm] button:hover,
form[data-turbo-confirm] button:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
}

/* List Items */
.list-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
}

.list-item-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--color-bg-light);
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius-md);
  transition: all var(--transition-fast);
}

.list-item-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.15);
}

.list-item-ticked {
  opacity: 0.5;
}

.list-item-ticked .list-item-name {
  text-decoration: line-through;
}

.list-item-main {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.list-item-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  min-width: 0;
}

.list-item-name {
  font-weight: 500;
  font-size: var(--font-size-xl);
  color: var(--color-text);
  flex: 1;
}

.list-item-checkbox input[type="checkbox"] {
  width: 32px;
  height: 32px;
  cursor: pointer;
  flex-shrink: 0;
}

.list-item-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0;
}

.list-item-actions {
  display: flex;
  gap: var(--space-md);
}

.list-item-quantity-inline {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 400;
  margin-left: var(--space-xs);
}

.list-item-actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  justify-content: flex-end;
}

.quantity-input {
  width: 60px;
  padding: 2px 4px;
  font-size: var(--font-size-sm);
  border: 1px solid var(--color-primary);
  border-radius: var(--border-radius-sm);
  background: var(--color-bg-medium);
  color: var(--color-text);
}
/* Retro Pixel-Art Design System - Utility Classes */

/* Utility Classes */
.text-center {
  text-align: center;
}

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

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

.text-primary {
  color: var(--color-primary);
}

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

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mt-4 { margin-top: var(--space-xl); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-4 { margin-bottom: var(--space-xl); }

.p-0 { padding: 0; }
.p-1 { padding: var(--space-sm); }
.p-2 { padding: var(--space-md); }
.p-3 { padding: var(--space-lg); }
.p-4 { padding: var(--space-xl); }

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.gap-1 { gap: var(--space-sm); }
.gap-2 { gap: var(--space-md); }
.gap-3 { gap: var(--space-lg); }
.gap-4 { gap: var(--space-xl); }

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

/* Responsive Design */
@media (max-width: 768px) {
  :root {
    --font-size-base: 0.9375rem;
  }

  nav {
    padding: var(--space-sm);
  }

  nav > div {
    gap: var(--space-sm);
  }

  nav a {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-sm);
  }

  main {
    padding: var(--space-md);
  }

  section.item {
    flex-direction: column;
  }

  section.item img {
    flex-basis: 100%;
    max-width: 100%;
  }

  .dropdown-menu {
    right: auto;
    left: 0;
  }
}

@media (max-width: 480px) {
  :root {
    --font-size-base: 0.875rem;
  }

  button,
  input[type="submit"],
  input[type="button"],
  .button {
    padding: var(--space-xs) var(--space-md);
    font-size: var(--font-size-sm);
  }

  .card {
    padding: var(--space-md);
  }
}

/* Autocomplete */
.autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--color-bg-medium);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  margin-top: var(--space-xs);
}

.autocomplete-results-visible {
  display: block;
}

.autocomplete-item {
  padding: var(--space-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-lg);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover {
  background: var(--color-bg-light);
  color: var(--color-primary);
}

.autocomplete-loading {
  padding: var(--space-md);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-lg);
}

/* Animations */
@keyframes glow {
  0%, 100% {
    text-shadow: 0 0 10px var(--color-shadow);
  }
  50% {
    text-shadow: 0 0 20px var(--color-shadow), 0 0 30px var(--color-shadow);
  }
}

.glow {
  animation: glow 2s ease-in-out infinite;
}

/* Sortable.js Drag and Drop */
.list-items-grid {
  min-height: 100px;
}

.list-item-card {
  -webkit-user-select: none;
  user-select: none;
}

.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  cursor: move;
  cursor: grab;
  color: var(--color-text-muted);
  touch-action: none;
  transition: color var(--transition-fast);
  margin-right: var(--space-sm);
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle:hover {
  color: var(--color-primary);
}

.drag-handle svg {
  pointer-events: none;
  width: 24px;
  height: 24px;
}

.sortable-ghost {
  opacity: 0.4;
  background: var(--color-primary-light);
  touch-action: none;
}

.sortable-chosen {
  cursor: grabbing;
  touch-action: none;
}

.sortable-drag {
  touch-action: none;
}

.sortable-fallback {
  opacity: 1 !important;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3) !important;
  cursor: grabbing !important;
  transition: none !important;
  z-index: 9999;
  touch-action: none;
}
