/* Variables and base styles are now primarily in theme.css */

/* Ensure body takes full height and uses theme variables */
body {
  min-height: 100vh;
  background-color: var(--dark-bg);
  /* From theme.css */
  color: var(--text-primary);
  /* From theme.css */
  font-family: var(--font-body);
  /* From theme.css */
}

.app-header {
  /* background: var(--header-gradient); /* This will be updated later to match Event Cards */
  color: white;
  /* Or var(--text-primary) */
  padding: 1rem;
  font-weight: bold;
  /* Consider using var(--font-heading) if it's a main title */
}

.app-main {
  padding: 1rem;
}

/* --- Button Styles --- */
/* Base .btn (inspired by Event Cards general button, adapted for primary action feel) */
.btn {
  display: inline-flex;
  /* Aligns icon and text nicely */
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  /* Default padding */
  font-family: var(--font-body);
  /* Default to body font */
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: var(--text-primary);
  /* Default white text */
  background: linear-gradient(135deg, #013801, #001300);
  /* Darker Green, can be var(--accent-green) based */
  border: 1px solid var(--accent-gold);
  /* Gold border for definition */
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), inset 0 -1px 1px rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
  /* For ripple if added via JS */
  cursor: pointer;
  transition: all 0.2s ease-out;
  user-select: none;
  /* Prevent text selection */
}

.btn-ghost {
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.5));
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.btn-ghost:hover {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.7));
}

.btn:hover {
  background: linear-gradient(135deg, #015701, #002f00);
  /* Slightly lighter green */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), inset 0 -1px 1px rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
  color: var(--accent-gold);
  /* Gold text on hover */
}

.btn:active,
.btn.button-pressed {
  transform: translateY(0px) scale(0.98);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(0, 0, 0, 0.2);
  background: linear-gradient(135deg, #001300, #013801);
  /* Inverted gradient on press */
}

/* Primary Button (Maladum Red) */
.btn-primary {
  background: linear-gradient(135deg, var(--maladum-red), #4a0000);
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold);
  font-family: var(--font-heading);
  /* Cinzel for primary CTAs */
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4a0000, var(--maladum-red));
  border-color: var(--accent-gold);
  color: #fff;
  /* Brighter text on hover for primary */
  transform: translateY(-1px);
}

.btn-primary:active,
.btn-primary.button-pressed {
  background: linear-gradient(135deg, #4a0000, #6b0000);
}

/* Small Button Variant */
.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  /* text-sm */
  border-radius: 6px;
  /* Slightly smaller radius */
}

/* Danger Button Variant (e.g., for Clear Inventory) */
.btn-danger {
  background: linear-gradient(135deg, var(--maladum-red), #5c0000);
  border-color: #a87732;
  /* Darker gold/bronze border for danger */
  color: var(--text-primary);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #5c0000, var(--maladum-red));
  color: #fff;
  border-color: var(--accent-gold);
}

.btn:disabled,
.btn[disabled] {
  background: #555;
  color: #999;
  border-color: #777;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--text-primary);
}

.icon-btn:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.icon-pill {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  padding-inline: 0.75rem;
  border-radius: 999px;
}

.pill-icon {
  font-size: 1rem;
}

/* --- Form Control Styles --- */
.form-field,
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
select,
textarea {
  background-color: rgba(0, 0, 0, 0.3);
  /* Dark, slightly transparent */
  color: var(--text-primary);
  border: 1px solid var(--border-ornate, #444);
  /* Using var from theme if available */
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-body);
  font-size: 1rem;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-field:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px rgba(197, 165, 114, 0.5);
  /* accent-gold with transparency */
}

/* Input Error Styling */
.input-error {
  border-color: var(--maladum-red) !important;
  /* Important to override focus */
  box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.5) !important;
  /* maladum-red with transparency */
}

/* Checkbox styling (basic, can be enhanced) */
.form-checkbox {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--accent-gold);
  border-radius: 4px;
  background-color: transparent;
  position: relative;
  cursor: pointer;
  vertical-align: middle;
  /* Align with label text */
}

.form-checkbox:checked {
  background-color: var(--accent-gold);
  border-color: var(--accent-gold);
}

.form-checkbox:checked::after {
  content: '✓';
  font-size: 14px;
  color: var(--bg-dark);
  /* Checkmark color against gold background */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: bold;
}

/* Styles for number input up/down buttons (browser default can be ugly) */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  /* Firefox */
  appearance: textfield;
}

/* --- Animations & Interactivity --- */
/* Fade In */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}

/* Flip Animations (from Event Cards) */
@keyframes flipInForward {
  from {
    transform: perspective(1000px) rotateY(90deg);
    opacity: 0;
  }

  to {
    transform: perspective(1000px) rotateY(0deg);
    opacity: 1;
  }
}

.flip-forward {
  animation: flipInForward 0.5s ease-out forwards;
  backface-visibility: hidden;
  /* Improves rendering during flip */
}

@keyframes flipInBackward {

  /* If needed */
  from {
    transform: perspective(1000px) rotateY(-90deg);
    opacity: 0;
  }

  to {
    transform: perspective(1000px) rotateY(0deg);
    opacity: 1;
  }
}

.flip-backward {
  animation: flipInBackward 0.5s ease-out forwards;
  backface-visibility: hidden;
}

/* Button Ripple Effect (CSS part) */
.btn .ripple-element {
  /* Renamed from .ripple to avoid conflict if .ripple class is used elsewhere */
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  /* Slightly less opaque */
  transform: scale(0);
  animation: ripple-animation 0.6s linear forwards;
  pointer-events: none;
}

@keyframes ripple-animation {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* --- Content Presentation & Typography Utilities --- */
.text-block-readable {
  max-width: 60ch;
  /* Add margin-left: auto; margin-right: auto; if block should be centered */
}

/* Example helper for consistent icon and text spacing if needed more broadly */
/* .icon-text-container {
  display: flex;
  align-items: center;
  gap: 0.75rem; /* Equivalent to Tailwind mr-3 or gap-3 */
/* } */
/* For now, specific margins like mr-3 on icons are handled by Tailwind in components. */


/* Card Styling from Spec */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.75));
  border: 2px solid #333;
  /* Spec */
  border-radius: 10px;
  /* Spec */
  box-shadow: 0 4px 10px rgba(0, 0, 0, .45);
  /* Spec */
  position: relative;
  /* For ::before pseudo-element */
  overflow: hidden;
  /* Ensures ::before respects border-radius */
  color: var(--text-light, #1a202c);
  /* Default dark text for parchment. Fallback if --text-light is removed. */
  /* padding: 1rem; Removed to let Tailwind control padding */
  backdrop-filter: blur(4px);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  /* Replaces top:0, left:0, right:0, bottom:0 */
  background: url("images/parchment-texture.png") center/cover no-repeat;
  opacity: .15;
  /* Spec */
  mix-blend-mode: overlay;
  /* Spec */
  pointer-events: none;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.45);
  border-color: var(--accent-gold);
}

.card:active {
  transform: translateY(0px) scale(0.99);
}

/* Old .material-card styles are commented out, to be replaced by .card */
/*
.material-card {
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.8);
}

.dark .material-card {
  background: rgba(17, 24, 39, 0.8);
}
*/

/* Styles for item icons in the list */
.item-icon {
  /* Tailwind classes w-24 h-24 mr-2 are applied for sizing */
  /* Add any additional specific styles if needed, e.g., border */
  border: 1px solid #ccc;
  /* Example border */
  border-radius: 4px;
  object-fit: contain;
  /* Ensure icon aspect ratio is maintained */
}

.rarity-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 10;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #333;
}

.rarity-common {
  background-color: green;
}

.rarity-uncommon {
  background-color: yellow;
}

.rarity-rare {
  background-color: lightblue;
}

.rarity-border-common {
  border-color: green;
}

.rarity-border-uncommon {
  border-color: yellow;
}

.rarity-border-rare {
  border-color: lightblue;
}

.relic-border {
  border-color: var(--accent-gold);
  background-color: var(--relic-bg);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.items-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.filter-bar {
  width: 100%;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.75rem;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.filter-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.7rem;
  color: var(--accent-gold);
}

.segmented-control {
  display: inline-flex;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.25);
}

.segmented-control .segmented {
  border-radius: 0;
  border: none;
  min-width: 120px;
  justify-content: center;
}

.segmented-control .segmented.active {
  background: linear-gradient(135deg, #025502, #013201);
  color: var(--accent-gold);
}

.segmented-control .segmented:not(.active) {
  color: var(--text-primary);
}

.inventory-state {
  position: absolute;
  top: 8px;
  left: 8px;
  text-transform: uppercase;
}

.inventory-empty {
  border-color: #7f1d1d;
  background: linear-gradient(180deg, rgba(127, 29, 29, 0.18), rgba(127, 29, 29, 0.05));
  color: var(--text-primary);
  /* Light text for dark background */
}

.inventory-empty .inventory-state {
  color: #fff;
  border-color: #ef4444;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.inventory-low {
  border-color: #b45309;
  background: linear-gradient(180deg, rgba(180, 83, 9, 0.15), rgba(180, 83, 9, 0.04));
}

.inventory-low .inventory-state {
  color: #fff;
  border-color: #f59e0b;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.inventory-surplus {
  border-color: #166534;
}

.inventory-surplus .inventory-state {
  background: #166534;
  color: #dcfce7;
  border-color: #22c55e;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.favourite-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.2);
  color: #d97706;
  font-size: 1.2rem;
  transition: transform 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.favourite-toggle:hover {
  color: #fbbf24;
  border-color: var(--accent-gold);
  transform: scale(1.05);
}

.deficit-ribbon {
  position: absolute;
  right: -8px;
  top: 12px;
  transform: rotate(3deg);
  background: rgba(0, 0, 0, 0.65);
  color: var(--accent-gold);
  padding: 0.35rem 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  border-radius: 6px;
  border: 2px solid currentColor;
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.35);
}

.deficit-ribbon.rarity-border-common {
  color: green;
}

.deficit-ribbon.rarity-border-uncommon {
  color: goldenrod;
}

.deficit-ribbon.rarity-border-rare {
  color: lightblue;
}

/* Styles for the icon zoom modal */
.icon-modal {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  /* Ensure it's on top */
}

.icon-modal-content {
  position: relative;
  background-color: var(--bg-light);
  padding: 20px;
  border-radius: 8px;
  text-align: center;
}

.dark .icon-modal-content {
  background-color: var(--bg-dark);
}

.icon-modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  color: var(--text-light);
}

.dark .icon-modal-close {
  color: var(--text-dark);
}

.zoomed-icon {
  max-width: 80vw;
  max-height: 80vh;
  border-radius: 4px;
}

/* Simple table styling for the All Items view */
.item-table {
  width: 100%;
  border-collapse: collapse;
}

.item-table th,
.item-table td {
  border-bottom: 1px solid #d1d5db;
  padding: 0.25rem 0.5rem;
}

.dark .item-table th,
.dark .item-table td {
  border-color: #374151;
}

/* ==========================================
   NEW SIDEBAR LAYOUT STYLES (v2.0)
   ========================================== */

/* Filter chips for type selection */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 1rem;
  border-radius: 9999px;
  background: #1a2e24;
  color: #9db9a8;
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-chip:hover {
  border-color: #28392f;
  color: white;
}

.filter-chip.active {
  background: #13ec6d;
  color: #0c1a12;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(19, 236, 109, 0.3);
}

/* Surface dark background color */
.bg-surface-dark {
  background-color: #162e21;
}

/* Item icon styling for new cards */
.item-icon {
  border: none;
  border-radius: 0;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

/* Scrollbar styling already handled in index.html inline styles */

/* Mobile sidebar transitions */
@media (max-width: 768px) {
  .sidebar-hidden {
    transform: translateX(-100%);
  }
}

/* ==========================================
   BOTTOM NAVIGATION BAR (Mobile)
   ========================================== */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: linear-gradient(to top, #0c1a12 0%, #102218 100%);
  border-top: 1px solid #28392f;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.bottom-nav-container {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 64px;
  max-width: 480px;
  margin: 0 auto;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  color: #9db9a8;
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:active {
  transform: scale(0.95);
}

.bottom-nav-item .nav-icon {
  font-size: 24px;
  transition: all 0.2s ease;
}

.bottom-nav-item .nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
}

.bottom-nav-item.active {
  color: #13ec6d;
}

.bottom-nav-item.active .nav-icon {
  transform: scale(1.1);
}

.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: #13ec6d;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 2px 8px rgba(19, 236, 109, 0.4);
}

.bottom-nav-item:hover:not(.active) {
  color: #c5e8d2;
}

/* Show bottom nav only on mobile */
@media (max-width: 767px) {
  .bottom-nav {
    display: block;
  }

  /* Add padding to main content to account for bottom nav */
  .main-content-with-bottom-nav {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Hide the desktop header nav toggle buttons on mobile */
  #headerNavLinks {
    display: none !important;
  }

  /* Hide sidebar completely on mobile when bottom nav is present */
  #sidebar {
    display: none !important;
  }

  /* Make main content full width on mobile */
  main.flex-1 {
    margin-left: 0 !important;
  }
}

/* Inventory panel styles (slides up from bottom on mobile) */
.inventory-panel {
  display: none;
}

@media (max-width: 767px) {
  .inventory-panel {
    display: block;
    position: fixed;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    z-index: 45;
    background: linear-gradient(to bottom, #102218 0%, #0c1a12 100%);
    border-top: 1px solid #28392f;
    border-radius: 20px 20px 0 0;
    max-height: calc(85vh - 64px - env(safe-area-inset-bottom, 0px));
    transform: translateY(calc(100% - 56px));
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    touch-action: none;
  }

  .inventory-panel.peek {
    transform: translateY(calc(100% - 56px));
  }

  .inventory-panel.half {
    transform: translateY(50%);
  }

  .inventory-panel.full {
    transform: translateY(0);
  }

  .inventory-panel.dragging {
    transition: none;
  }

  .inventory-panel-drag-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0 4px 0;
    cursor: grab;
    touch-action: none;
  }

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

  .drag-indicator {
    width: 36px;
    height: 4px;
    background: #3d5a4a;
    border-radius: 2px;
    transition: background 0.2s ease;
  }

  .inventory-panel-drag-handle:hover .drag-indicator,
  .inventory-panel-drag-handle:active .drag-indicator {
    background: #13ec6d;
  }

  .inventory-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 12px 16px;
    border-bottom: 1px solid #28392f;
    background: transparent;
  }

  .inventory-panel-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .inventory-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #9db9a8;
  }

  .inventory-summary-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    background: rgba(19, 236, 109, 0.1);
    border: 1px solid rgba(19, 236, 109, 0.2);
    font-weight: 600;
  }

  .inventory-summary-badge.warning {
    background: rgba(234, 179, 8, 0.1);
    border-color: rgba(234, 179, 8, 0.2);
    color: #eab308;
  }

  .inventory-summary-badge.danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
  }

  .inventory-panel-content {
    padding: 12px 16px;
    overflow-y: auto;
    max-height: calc(85vh - 64px - 100px - env(safe-area-inset-bottom, 0px));
    overscroll-behavior: contain;
  }

  /* Panel state indicator for items tab */
  .bottom-nav-item[data-tab="inventory"]::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: transparent;
    border-radius: 50%;
    transition: all 0.2s ease;
  }

  .bottom-nav-item[data-tab="inventory"].has-items::after {
    background: #13ec6d;
    box-shadow: 0 0 6px rgba(19, 236, 109, 0.5);
  }
}