:root {
  --color-bg: #121212;
  --color-surface: #1e1e1e;
  --color-surface-dim: #252525;
  --color-text: #e0e0e0;
  --color-text-muted: #a0a0a0;

  --color-primary: #009688; /* Teal */
  --color-primary-dark: #00796b;
  --color-danger: #d32f2f;
  --color-warning: #ffa000;
  --color-success: #388e3c;

  --nav-height: 60px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;

  --border-radius: 12px;
  --border-radius-sm: 8px;

  --font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text);
  overflow: hidden; /* Prevent body scroll, handle in app-content */
  height: 100vh;
}

/* Layout */
.app-content {
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  padding: var(--spacing-md);
  padding-bottom: 80px; /* Space for FAB */
}

/* Navigation */
.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--nav-height);
  background-color: var(--color-surface);
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  user-select: none;
}

.nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 0.5s, background-color 0.5s;
}

.nav__item--active {
  color: var(--color-primary);
  background-color: rgba(0, 150, 136, 0.1);
}

.nav__icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.nav__label {
  font-size: 12px;
}

/* Filters & Search */
.filter-bar {
  display: flex;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-bar__btn {
  padding: 6px 12px;
  border: 1px solid transparent;
  background-color: transparent;
  color: var(--color-text-muted);
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  transition: all 0.3s;
}

.filter-bar__btn--in {
  border-color: var(--color-success);
  color: var(--color-success);
}
.filter-bar__btn--almost {
  border-color: var(--color-warning);
  color: var(--color-warning);
}
.filter-bar__btn--out {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

/* Active state logic handled in JS by setting background color, 
   but ideally should be class-based toggle. 
   Maintaining JS logic for now, but providing base styles. */

.search-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

/* Cards */
.card-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.list-header {
  display: flex;
  justify-content: space-between;
  padding: var(--spacing-sm) var(--spacing-md);
  background-color: var(--color-surface-dim);
  border-radius: var(--border-radius-sm);
  font-weight: bold;
  font-size: 0.9em;
  color: var(--color-text-muted);
  margin-top: var(--spacing-sm);
}

.card {
  background-color: var(--color-surface);
  border-radius: var(--border-radius);
  padding: var(--spacing-md);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
}

.card--usage {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.card--inventory {
  cursor: pointer;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.card__header {
  font-size: 1.1em;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px; /* for column layout */
}

.card--purchase {
  display: grid;
  grid-template-columns: 1.5fr 0.8fr 1fr 0.8fr 1fr; /* Name Qty Price Unit Amount */
  align-items: center;
  gap: var(--spacing-sm);
}

.card--purchase .card__header {
  margin-bottom: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card--purchase .card__field {
  margin-right: 0;
  text-align: right;
}
.card--purchase .card__field--unit {
  text-align: left;
  margin-left: 4px;
  font-size: 0.8em;
  color: var(--color-text-muted);
}
.card--purchase .card__field--qty {
  text-align: right;
  font-weight: bold;
}

/* Horizontal card adjustments */
.card--usage .card__header,
.card--inventory .card__header {
  margin-bottom: 0;
  flex: 1;
}

.card__detail {
  font-size: 0.9em;
  color: var(--color-text-muted);
}

.card__badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: bold;
  color: #fff;
  min-width: 30px;
  text-align: center;
  margin: 0 var(--spacing-sm);
}

.card__badge--success {
  background-color: var(--color-success);
}
.card__badge--warning {
  background-color: var(--color-warning);
  color: #000;
}
.card__badge--danger {
  background-color: var(--color-danger);
}

.card__field {
  margin-right: var(--spacing-md);
  font-size: 0.9em;
}
.card__field:last-child {
  margin-right: 0;
}
.card__field--price,
.card__field--amount {
  font-family: monospace;
}
.card__field--amount {
  font-weight: bold;
  color: var(--color-primary);
  margin-left: auto;
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: var(--border-radius-sm);
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn:hover {
  opacity: 0.9;
}

.btn--primary {
  background-color: var(--color-primary);
  color: white;
}
.btn--danger {
  background-color: var(--color-danger);
  color: white;
}
.btn--full {
  width: 100%;
  margin-top: var(--spacing-sm);
}
.btn--icon {
  padding: 8px;
  background: transparent;
  color: var(--color-text-muted);
  border-radius: 50%;
}
.btn--icon:hover {
  color: var(--color-primary);
  background-color: rgba(255, 255, 255, 0.05);
}

.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 20px);
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--color-primary);
  color: white;
  border: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 900;
  transition: transform 0.2s;
}
.fab:active {
  transform: scale(0.95);
}

/* Forms */
.form__input,
.form__select,
.form__textarea {
  width: 100%;
  padding: 12px;
  margin-bottom: var(--spacing-md);
  background-color: var(--color-surface-dim);
  border: 1px solid #444;
  border-radius: var(--border-radius-sm);
  color: var(--color-text);
  font-size: 1rem;
}
.form__input:focus,
.form__select:focus,
.form__textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form__input--search {
  margin-bottom: 0;
  flex: 1; /* For flex container */
}

.form__label {
  display: block;
  margin-bottom: 4px;
  color: var(--color-text-muted);
  font-size: 0.9em;
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  backdrop-filter: blur(2px);
}

.modal--top {
  align-items: flex-start;
  padding-top: 50px;
  z-index: 2100;
}

.modal__content {
  background-color: var(--color-surface);
  padding: var(--spacing-lg);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.modal__content--center {
  text-align: center;
}

.modal__close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 28px;
  cursor: pointer;
  color: var(--color-text-muted);
}
.modal__close:hover {
  color: var(--color-text);
}

.modal__title {
  color: var(--color-primary);
  margin-bottom: var(--spacing-lg);
  text-align: center;
}

.modal__subtitle {
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-sm);
}

.modal__section {
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid #333;
}
.modal__section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.modal__actions {
  display: flex;
  justify-content: space-around;
  gap: var(--spacing-sm);
}

/* Utility */
.d-none {
  display: none !important;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.slide-in-right {
  animation: slideInRight 0.3s ease-out forwards;
}

.slide-in-left {
  animation: slideInLeft 0.3s ease-out forwards;
}

.page-wrapper {
  width: 100%;
  min-height: 100%;
}
