/* Mobile-first layout on top of Pico */

:root {
  --nav-height: 64px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--pico-muted-border-color, #ddd);
}

.app-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.logout-form {
  margin: 0;
}

.logout-btn {
  margin: 0;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  width: auto;
}

.app-main {
  padding-top: 1rem;
  padding-bottom: calc(var(--nav-height) + 1.5rem);
}

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  display: flex;
  background: var(--pico-card-background-color, #fff);
  border-top: 1px solid var(--pico-muted-border-color, #ddd);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.72rem;
  text-decoration: none;
  color: var(--pico-muted-color, #666);
}

.bottom-nav a.active {
  color: var(--pico-primary, #0172ad);
  font-weight: 600;
}

/* SVG icons */
.icon-svg {
  vertical-align: -0.2em;
  flex-shrink: 0;
}

.logo-icon {
  vertical-align: -0.28em;
  color: var(--pico-primary, #0172ad);
}

.icon-ok { color: #2e7d32; }
.icon-warn { color: #ed6c02; }
.icon-err { color: #c62828; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

/* Page structure */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.page-head h1 {
  margin: 0;
  font-size: 1.5rem;
}

.add-btn {
  width: auto;
  padding: 0.4rem 0.9rem;
  margin: 0;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 0.8rem;
}

/* Chips */
.chip-row {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.3rem 0 0.8rem;
  -webkit-overflow-scrolling: touch;
}

.chip {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--pico-muted-border-color, #ccc);
  font-size: 0.8rem;
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
}

.chip-active {
  background: var(--pico-primary, #0172ad);
  border-color: var(--pico-primary, #0172ad);
  color: #fff;
}

.chip-small {
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
}

.chip-ok { border-color: #2e7d32; color: #2e7d32; }
.chip-warn { border-color: #ed6c02; color: #ed6c02; }
.chip-err { border-color: #c62828; color: #c62828; }

/* Item cards */
.item-cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.item-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--pico-muted-border-color, #ddd);
  border-radius: 10px;
  background: var(--pico-card-background-color, #fff);
}

.item-meta {
  display: flex;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--pico-muted-color, #666);
}

.item-notes {
  font-size: 0.78rem;
  color: var(--pico-muted-color, #666);
  margin-top: 0.15rem;
}

.item-actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex-shrink: 0;
}

.item-actions form {
  margin: 0;
}

.btn-small {
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  margin: 0;
  width: 100%;
  text-align: center;
}

.btn-danger {
  color: #c62828;
  border-color: #c62828;
}

/* Filter bar */
.filter-bar {
  margin-bottom: 0;
}

.filter-bar input[type="search"] {
  margin-bottom: 0.3rem;
}

.archived-toggle {
  margin-top: 1rem;
  font-size: 0.85rem;
}

.empty-state {
  color: var(--pico-muted-color, #666);
  text-align: center;
  padding: 1.5rem 0;
}

.flash-ok {
  color: #2e7d32;
  font-weight: 600;
}

.error-msg {
  color: #c62828;
  font-weight: 600;
}

/* Date navigation */
.date-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.date-nav a[role="button"] {
  width: auto;
}

.date-form {
  margin: 0;
  flex: 1;
}

.date-form input {
  margin: 0;
}

/* Outfit cards */
.outfit-card {
  margin: 0 0 0.8rem;
  padding: 0.8rem 1rem;
}

.outfit-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
  margin-bottom: 0.5rem;
  background: none;
}

.outfit-actions {
  display: flex;
  gap: 0.3rem;
}

.outfit-actions form {
  margin: 0;
}

.outfit-section {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--pico-muted-color, #666);
  min-width: 80px;
  flex-shrink: 0;
}

.outfit-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.full-width-btn {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 0.5rem;
}

/* Outfit builder */
.section-picker {
  border: 1px solid var(--pico-muted-border-color, #ddd);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.6rem;
}

.section-picker summary {
  font-weight: 600;
}

.pick-list {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-top: 0.5rem;
}

.pick-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.3rem;
  border-radius: 8px;
  cursor: pointer;
}

.pick-item:active {
  background: var(--pico-secondary-background, #f0f0f0);
}

.pick-item input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
}

.pick-name {
  font-weight: 500;
}

.pick-meta {
  font-size: 0.75rem;
  color: var(--pico-muted-color, #666);
  margin-left: auto;
  text-align: right;
}

/* Color field: text input + swatches (primary, works well on Android) with
   a native <input type="color"> kept only as an optional precision fallback -
   the OS color wheel alone is a poor primary control on many Android devices. */
.color-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.color-field input[type="text"] {
  flex: 1;
  margin: 0;
  min-width: 0;
}

.color-preview {
  display: inline-block;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid var(--pico-muted-border-color, #ccc);
  flex-shrink: 0;
}

.color-native {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0.1rem;
  margin: 0;
  flex-shrink: 0;
}

.color-field .btn-small {
  width: auto;
  flex-shrink: 0;
}

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.2rem 0 0.6rem;
}

.swatch-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
  padding: 0;
  cursor: pointer;
}

.swatch-btn.selected {
  box-shadow: 0 0 0 2px var(--pico-background-color, #fff), 0 0 0 4px var(--pico-primary, #0172ad);
}

.color-dot {
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.25);
  margin-right: 0.3em;
  vertical-align: baseline;
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

.form-actions button,
.form-actions a {
  margin: 0;
}

.form-actions form {
  margin: 0;
  flex: 1;
}

/* History */
.history-day h3 {
  font-size: 1rem;
  margin: 1rem 0 0.4rem;
}

.history-outfit {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
  margin-bottom: 0.4rem;
}

.history-link {
  font-size: 0.85rem;
}

/* Stats */
.stats-filters {
  margin-bottom: 1rem;
}

.stats-filters label {
  font-size: 0.8rem;
}

.stats-filters select,
.stats-filters input {
  margin-bottom: 0.5rem;
}

.filter-hint {
  color: var(--pico-muted-color, #666);
  margin: -0.3rem 0 0.5rem;
}

.stats-table {
  width: 100%;
}

.stats-table td,
.stats-table th {
  padding: 0.5rem 0.4rem;
}

.rank-col {
  color: var(--pico-muted-color, #666);
  width: 2rem;
}

.count-col {
  text-align: right;
  white-space: nowrap;
  width: 4rem;
}

.stat-item-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.stat-bar-track {
  height: 6px;
  border-radius: 3px;
  background: var(--pico-secondary-background, #eee);
  margin-top: 0.3rem;
  overflow: hidden;
}

.stat-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--pico-primary, #0172ad);
}

/* Import preview */
.table-scroll {
  overflow-x: auto;
}

.row-error td { color: #c62828; }
.row-duplicate td { color: #a0741f; }

/* Login */
.login-card {
  max-width: 420px;
  margin: 10vh auto 0;
}

/* Desktop tweaks */
@media (min-width: 768px) {
  .app-main {
    max-width: 860px;
  }
  .bottom-nav {
    max-width: 860px;
    margin: 0 auto;
    border-left: 1px solid var(--pico-muted-border-color, #ddd);
    border-right: 1px solid var(--pico-muted-border-color, #ddd);
  }
}
