/* Shopping List — stylesheet */

*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --bg: #111118;
  --surface: #1a1a24;
  --surface2: #22222e;
  --border: #2e2e40;
  --border-subtle: rgba(255, 255, 255, 0.05);
  --text: #e4e4f0;
  --text-muted: #7878a0;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-glow: rgba(129, 140, 248, 0.18);
  --accent-dim: rgba(129, 140, 248, 0.08);
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --danger-dim: rgba(248, 113, 113, 0.1);
  --success: #4ade80;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
  --sidebar-width: 240px;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------------------------------------------------------------------------
   Login
   --------------------------------------------------------------------------- */

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem 2.5rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: var(--shadow-lg);
}

.login-form h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  letter-spacing: -0.02em;
}

.login-error {
  color: var(--danger);
  font-size: 0.875rem;
  margin: 0;
  padding: 0.5rem 0.75rem;
  background: var(--danger-dim);
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: 6px;
}

.hidden {
  display: none !important;
}

/* ---------------------------------------------------------------------------
   Form fields
   --------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

input[type="text"],
input[type="password"],
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9375rem;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 1rem;
  transition: background 0.15s, color 0.15s;
}

.btn-primary {
  background: linear-gradient(135deg, #818cf8, #6366f1);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(129, 140, 248, 0.2);
  transition: filter 0.15s, box-shadow 0.15s;
}

.btn-primary:hover {
  filter: brightness(1.12);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4), 0 0 0 1px rgba(129, 140, 248, 0.3);
}

.login-form button[type="submit"] {
  background: linear-gradient(135deg, #818cf8, #6366f1);
  color: #fff;
  font-weight: 600;
  margin-top: 0.5rem;
  width: 100%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(129, 140, 248, 0.2);
  transition: filter 0.15s, box-shadow 0.15s;
}

.login-form button[type="submit"]:hover {
  filter: brightness(1.12);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4), 0 0 0 1px rgba(129, 140, 248, 0.3);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-danger {
  background: linear-gradient(135deg, #f87171, #ef4444);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: filter 0.15s;
}

.btn-danger:hover {
  filter: brightness(1.1);
}

.btn-icon {
  background: transparent;
  color: var(--text-muted);
  padding: 0.2rem 0.5rem;
  font-size: 1rem;
  border-radius: 4px;
}

.btn-icon:hover {
  background: var(--surface2);
  color: var(--text);
}

.btn-delete {
  background: transparent;
  color: var(--text-muted);
  padding: 0.1rem 0.4rem;
  font-size: 1.1rem;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.item-row:hover .btn-delete {
  opacity: 1;
}

@media (hover: none) {
  .btn-delete {
    opacity: 0.6;
  }
}

.btn-delete:hover {
  color: var(--danger);
}

.btn-sm {
  font-size: 0.8125rem;
  padding: 0.25rem 0.6rem;
}

.btn-add-list {
  background: transparent;
  color: var(--accent);
  font-size: 0.875rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  width: 100%;
  text-align: left;
}

.btn-add-list:hover {
  background: var(--surface2);
}

.btn-admin {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  width: 100%;
  text-align: left;
}

.btn-admin:hover {
  background: var(--surface2);
  color: var(--text);
}

/* ---------------------------------------------------------------------------
   App layout
   --------------------------------------------------------------------------- */

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------------------------------------------------------------------------
   Mobile top bar (hamburger + title, hidden on desktop)
   --------------------------------------------------------------------------- */

.mobile-topbar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-hamburger {
  background: transparent;
  color: var(--text);
  padding: 0.25rem 0.5rem;
  font-size: 1.3rem;
  line-height: 1;
  border-radius: 4px;
}

.btn-hamburger:hover {
  background: var(--surface2);
}

.mobile-topbar-title {
  font-weight: 700;
  font-size: 1rem;
}

/* ---------------------------------------------------------------------------
   Sidebar overlay (mobile backdrop)
   --------------------------------------------------------------------------- */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 399;
}

.sidebar-overlay.active {
  display: block;
}

/* ---------------------------------------------------------------------------
   Mobile breakpoint
   --------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .mobile-topbar {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 400;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: min(var(--sidebar-width), 85vw);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-area {
    padding: 1rem;
  }
}

/* ---------------------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------------------- */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0.75rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--accent-dim) 0%, transparent 100%);
}

.sidebar-title {
  font-weight: 800;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-section {
  padding: 0.5rem 0;
}

.list-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem 0.25rem;
}

.list-item-row {
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  margin: 0 0.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.12s, color 0.12s;
  border-left: 2px solid transparent;
}

.list-item-row:hover {
  background: var(--surface2);
}

.list-item-row.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left-color: var(--accent);
  padding-left: calc(0.75rem - 2px);
}

.list-name {
  font-size: 0.9rem;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-empty {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 0.25rem 0.75rem;
  font-style: italic;
}

.sidebar-add {
  padding: 0.25rem 0.25rem;
}

.sidebar-admin {
  margin-top: auto;
  padding: 0.5rem 0.25rem;
  border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------------------
   Main area
   --------------------------------------------------------------------------- */

.main-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.item-list-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.list-heading {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  flex: 1;
  letter-spacing: -0.02em;
}

/* ---------------------------------------------------------------------------
   Add item row
   --------------------------------------------------------------------------- */

.add-item-row {
  position: relative;
}

.add-item-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.9375rem;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.add-item-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---------------------------------------------------------------------------
   Item list
   --------------------------------------------------------------------------- */

.item-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  user-select: none;
}

.item-row:hover {
  background: var(--surface2);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.item-row.checked {
  opacity: 0.55;
}

.item-row.checked .item-name {
  text-decoration: line-through;
}

.item-row.dragging {
  opacity: 0.5;
}

.item-row.drag-over {
  border-color: var(--accent);
  background: rgba(124, 158, 245, 0.07);
}

.drag-handle {
  color: var(--text-muted);
  cursor: grab;
  font-size: 1rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.item-row:hover .drag-handle {
  opacity: 1;
}

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

.item-name {
  flex: 1;
  font-size: 0.9375rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Context menu
   --------------------------------------------------------------------------- */

.context-menu {
  position: absolute;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255, 255, 255, 0.04);
  z-index: 200;
  min-width: 160px;
  overflow: hidden;
}

.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border-radius: 0;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  color: var(--text);
}

.context-menu button:hover {
  background: var(--border);
}

.context-menu button.danger {
  color: var(--danger);
}

/* ---------------------------------------------------------------------------
   Dialogs
   --------------------------------------------------------------------------- */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.dialog-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem 2rem;
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.dialog-box h2 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.dialog-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* ---------------------------------------------------------------------------
   Admin panel
   --------------------------------------------------------------------------- */

.admin-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.admin-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-header h2 {
  margin: 0;
  flex: 1;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
}

.tab {
  background: transparent;
  color: var(--text-muted);
  border-radius: 0;
  padding: 0.5rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  padding-top: 1rem;
}

.admin-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}

.admin-form h3 {
  width: 100%;
  margin: 0 0 0.25rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
  font-weight: 600;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.admin-table tr:hover td {
  background: var(--surface2);
}

.actions-cell {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

/* ---------------------------------------------------------------------------
   Member list (groups dialog)
   --------------------------------------------------------------------------- */

.member-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  background: var(--bg);
}

.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: var(--surface2);
}

.member-add {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.member-add label {
  font-size: 0.875rem;
  white-space: nowrap;
}

.member-add select {
  flex: 1;
  min-width: 140px;
}

/* ---------------------------------------------------------------------------
   Empty / error states
   --------------------------------------------------------------------------- */

.empty-state {
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
  font-size: 0.875rem;
}

.error-msg {
  color: var(--danger);
  font-size: 0.875rem;
}

/* ---------------------------------------------------------------------------
   Scrollbars (subtle)
   --------------------------------------------------------------------------- */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
