/* ========================================
   LISTA FAMÍLIA - Design System CSS
   Baseado nos mockups e especificações
   ======================================== */

/* CSS Variables */
:root {
  /* Brand Colors */
  --navy: #1E3A6E;
  --navy-hover: #15275C;
  --orange: #E85A2A;
  --orange-hover: #D74A1F;
  
  /* Grayscale */
  --white: #FFFFFF;
  --gray-lightest: #F5F5F5;
  --gray-light: #F0F0F0;
  --gray-border: #E5E7EB;
  --gray-text: #999999;
  --gray-dark: #333333;
  --gray-darkest: #111111;
  
  /* Semantic */
  --success: #10B981;
  --error: #D1495A;
  --warning: #F97316;
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
  
  /* Sizing */
  --input-height: 44px;
  --button-height: 48px;
  --header-height: 56px;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Base Styles */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--gray-lightest);
  color: var(--gray-dark);
  line-height: 1.5;
  min-height: 100vh;
}

/* Typography */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

/* ========================================
   BUTTONS
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: 0 var(--spacing-lg);
  height: var(--button-height);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--orange);
  color: var(--white);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--orange-hover);
}

.btn-secondary {
  background-color: var(--navy);
  color: var(--white);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--navy-hover);
}

.btn-outline {
  background-color: transparent;
  border: 2px solid var(--orange);
  color: var(--orange);
}

.btn-outline:hover:not(:disabled) {
  background-color: var(--orange);
  color: var(--white);
}

.btn-danger {
  background-color: var(--error);
  color: var(--white);
}

.btn-danger:hover:not(:disabled) {
  background-color: #B13A49;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  height: 36px;
  padding: 0 var(--spacing-md);
  font-size: 0.875rem;
}

.btn-icon-only {
  width: var(--button-height);
  padding: 0;
  font-size: 1.25rem;
}

/* ========================================
   FORM ELEMENTS
   ======================================== */

.form-group {
  margin-bottom: var(--spacing-md);
}

.form-group label {
  display: block;
  margin-bottom: var(--spacing-xs);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-dark);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  height: var(--input-height);
  padding: 0 var(--spacing-md);
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid var(--gray-border);
  border-radius: var(--radius-md);
  background-color: var(--white);
  color: var(--gray-dark);
  transition: border-color 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--orange);
}

input::placeholder,
textarea::placeholder {
  color: var(--gray-text);
}

textarea {
  height: 80px;
  padding: var(--spacing-md);
  resize: vertical;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
}

.quantity-control {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.quantity-control input {
  width: 60px;
  text-align: center;
}

.qty-btn {
  width: 36px;
  height: 36px;
  border: 2px solid var(--gray-border);
  border-radius: var(--radius-md);
  background: var(--white);
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
}

.qty-btn:hover {
  border-color: var(--orange);
  color: var(--orange);
}

.error-message {
  padding: var(--spacing-md);
  background-color: #FEE2E2;
  color: var(--error);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: var(--spacing-md);
}

/* ========================================
   AUTH PAGES
   ======================================== */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  background: linear-gradient(135deg, var(--gray-light) 0%, var(--white) 100%);
}

.auth-container {
  width: 100%;
  max-width: 400px;
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: var(--spacing-xl);
}

.logo {
  margin-bottom: var(--spacing-md);
}

.logo-icon {
  font-size: 2.5rem;
}

.auth-title {
  color: var(--navy);
  font-size: 1.75rem;
  margin-bottom: var(--spacing-xs);
}

.auth-subtitle {
  color: var(--gray-text);
  font-size: 0.875rem;
}

.auth-form h2 {
  text-align: center;
  margin-bottom: var(--spacing-lg);
  color: var(--navy);
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: var(--spacing-lg) 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background-color: var(--gray-border);
}

.auth-divider span {
  padding: 0 var(--spacing-md);
  color: var(--gray-text);
  font-size: 0.875rem;
}

.auth-links {
  text-align: center;
  margin-top: var(--spacing-lg);
}

.auth-links a {
  color: var(--orange);
  text-decoration: none;
  font-weight: 600;
}

.auth-links a:hover {
  text-decoration: underline;
}

.link-forgot {
  display: block;
  margin-bottom: var(--spacing-sm);
  font-size: 0.875rem;
}

/* ========================================
   APP HEADER
   ======================================== */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--navy);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-md);
  z-index: 100;
}

.header-title {
  font-size: 1.125rem;
  font-weight: 700;
}

.menu-btn,
.back-btn,
.action-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--white);
  font-size: 1.25rem;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background 0.2s;
}

.menu-btn:hover,
.back-btn:hover,
.action-btn:hover {
  background: rgba(255,255,255,0.1);
}

.header-user {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--orange);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
}

.header-actions {
  display: flex;
  gap: var(--spacing-xs);
}

/* ========================================
   SIDEBAR
   ======================================== */

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: -260px;
  width: 260px;
  height: calc(100vh - var(--header-height));
  background: var(--white);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  transition: left 0.3s ease;
  overflow-y: auto;
}

.sidebar.open {
  left: 0;
}

.sidebar-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--gray-border);
}

.user-name {
  display: block;
  font-weight: 600;
  color: var(--navy);
}

.user-email {
  display: block;
  font-size: 0.875rem;
  color: var(--gray-text);
}

.sidebar-menu {
  list-style: none;
  padding: var(--spacing-md) 0;
}

.sidebar-menu li a {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  color: var(--gray-dark);
  text-decoration: none;
  transition: background 0.2s;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
  background: var(--gray-light);
  color: var(--orange);
}

/* ========================================
   MAIN CONTENT
   ======================================== */

.main-content {
  padding: calc(var(--header-height) + var(--spacing-md)) var(--spacing-md) var(--spacing-md);
  max-width: 800px;
  margin: 0 auto;
}

/* ========================================
   DASHBOARD
   ======================================== */

.welcome-section {
  margin-bottom: var(--spacing-xl);
}

.welcome-section h2 {
  font-size: 1.5rem;
  color: var(--navy);
}

.welcome-subtitle {
  color: var(--gray-text);
}

.quick-actions {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-xl);
}

.info-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
}

.info-card h3 {
  color: var(--navy);
  margin-bottom: var(--spacing-md);
}

.steps-list {
  list-style: none;
}

.steps-list li {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--gray-border);
}

.steps-list li:last-child {
  border-bottom: none;
}

.step-number {
  font-size: 1.25rem;
}

/* ========================================
   FAMILIES
   ======================================== */

.families-list,
.lists-list,
.members-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.family-card,
.list-card,
.member-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.family-card:hover,
.list-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.family-card h3,
.list-card h3 {
  color: var(--navy);
  margin-bottom: var(--spacing-xs);
}

.family-card .meta,
.list-card .meta {
  font-size: 0.875rem;
  color: var(--gray-text);
}

.family-info-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.family-info-card h3 {
  color: var(--navy);
  margin-bottom: var(--spacing-md);
}

.invite-code-section {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  background: var(--gray-light);
  border-radius: var(--radius-md);
}

.invite-code {
  font-family: monospace;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 2px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: var(--spacing-xs);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
}

.section-header h3 {
  color: var(--navy);
}

.member-card {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  cursor: default;
}

.member-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.member-info {
  flex: 1;
}

.member-name {
  font-weight: 600;
  color: var(--gray-dark);
}

.member-email {
  font-size: 0.875rem;
  color: var(--gray-text);
}

.member-role {
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.member-role.admin {
  background: var(--navy);
  color: var(--white);
}

.member-role.member {
  background: var(--gray-light);
  color: var(--gray-dark);
}

/* ========================================
   LISTS
   ======================================== */

.list-card .status {
  display: inline-block;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: var(--spacing-sm);
}

.list-card .status.active {
  background: #D1FAE5;
  color: #065F46;
}

.list-card .status.completed {
  background: var(--gray-light);
  color: var(--gray-text);
}

.select-family-prompt {
  background: var(--white);
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  margin-bottom: var(--spacing-lg);
}

/* ========================================
   LIST DETAIL
   ======================================== */

.list-detail-header {
  padding-right: var(--spacing-sm);
}

.checkin-banner {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  background: var(--success);
  color: var(--white);
  padding: var(--spacing-sm) var(--spacing-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 99;
}

.checkin-market {
  font-weight: 600;
}

.checkin-sync {
  font-size: 0.875rem;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.list-detail-content {
  padding-top: calc(var(--header-height) + var(--spacing-md));
}

.list-detail-content.checkin-active {
  padding-top: calc(var(--header-height) + 48px + var(--spacing-md));
}

.add-item-section {
  margin-bottom: var(--spacing-md);
}

.quick-add-form {
  display: flex;
  gap: var(--spacing-sm);
}

.quick-add-input {
  flex: 1;
  height: var(--button-height);
  padding: 0 var(--spacing-md);
  font-size: 1rem;
  border: 2px solid var(--gray-border);
  border-radius: var(--radius-md);
  background: var(--white);
}

.quick-add-input:focus {
  outline: none;
  border-color: var(--orange);
}

.items-counter {
  font-size: 0.875rem;
  color: var(--gray-text);
  margin-bottom: var(--spacing-md);
}

.items-list {
  display: flex;
  flex-direction: column;
}

.item-card {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--white);
  border-bottom: 1px solid var(--gray-border);
  cursor: pointer;
  transition: background 0.2s;
}

.item-card:first-child {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.item-card:last-child {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  border-bottom: none;
}

.item-card:only-child {
  border-radius: var(--radius-lg);
}

.item-card:hover {
  background: var(--gray-light);
}

.item-card.purchased {
  opacity: 0.7;
}

.item-card.purchased .item-name {
  text-decoration: line-through;
  color: var(--gray-text);
}

.item-checkbox {
  width: 24px;
  height: 24px;
  border: 2px solid var(--gray-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.item-checkbox.checked {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--white);
}

.item-checkbox.checked::after {
  content: '✓';
  font-size: 0.875rem;
  font-weight: 700;
}

.item-content {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.item-name {
  font-weight: 600;
  color: var(--gray-dark);
  margin-bottom: var(--spacing-xs);
}

.item-meta {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: 0.875rem;
}

.item-category {
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--gray-light);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  color: var(--navy);
}

.item-quantity {
  color: var(--gray-text);
}

.item-price {
  font-weight: 600;
  color: var(--navy);
  font-size: 0.875rem;
}

/* Category Groups (during check-in) */
.category-group {
  margin-bottom: var(--spacing-lg);
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--navy);
  color: var(--white);
  font-weight: 600;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.category-header:hover {
  background: var(--navy-dark, #152d4a);
}

.category-toggle {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  flex: 1;
}

.chevron {
  display: inline-block;
  width: 20px;
  text-align: center;
  transition: transform 0.2s ease;
  font-size: 12px;
}

.category-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-stats {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  min-width: 120px;
}

.category-progress {
  flex: 1;
  min-width: 60px;
}

.progress-bar {
  display: block;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  background: #E85A2A;
  transition: width 0.3s ease;
}

.category-counter {
  font-size: 0.75rem;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  min-width: 40px;
  text-align: right;
}

.category-items {
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.category-items.collapsed {
  max-height: 0;
}

/* ========================================
   MODALS
   ======================================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal.active {
  display: flex;
}

@media (min-width: 768px) {
  .modal {
    align-items: center;
  }
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@media (min-width: 768px) {
  .modal-content {
    border-radius: var(--radius-lg);
    margin: var(--spacing-md);
  }
}

.modal-small {
  max-width: 320px;
}

.modal-large {
  max-width: 600px;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--navy);
  color: var(--white);
}

.modal-header h2 {
  font-size: 1.125rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.8;
}

.modal-close:hover {
  opacity: 1;
}

.modal-body {
  padding: var(--spacing-lg);
}

.modal-actions {
  display: flex;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

.modal-actions .btn {
  flex: 1;
}

/* Markets List */
.markets-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.market-option {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  border: 2px solid var(--gray-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.2s;
}

.market-option:hover {
  border-color: var(--orange);
}

.market-option input {
  width: 20px;
  height: 20px;
  accent-color: var(--orange);
}

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

/* Price History */
.price-history-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: var(--spacing-md);
}

.price-history-item {
  display: flex;
  justify-content: space-between;
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--gray-border);
}

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

.price-date {
  font-size: 0.875rem;
  color: var(--gray-text);
}

.price-value {
  font-weight: 600;
  color: var(--navy);
}

.price-summary {
  padding: var(--spacing-md);
  background: var(--gray-light);
  border-radius: var(--radius-md);
  text-align: center;
}

.price-avg .label {
  font-size: 0.875rem;
  color: var(--gray-text);
}

.price-avg .value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
  margin-left: var(--spacing-sm);
}

/* Menu Options */
.menu-options {
  list-style: none;
}

.menu-option {
  width: 100%;
  padding: var(--spacing-md);
  background: none;
  border: none;
  text-align: left;
  font-size: 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-border);
  transition: background 0.2s;
}

.menu-option:hover {
  background: var(--gray-light);
}

.menu-option:last-child {
  border-bottom: none;
}

.menu-option.danger {
  color: var(--error);
}

/* ========================================
   SETTINGS
   ======================================== */

.settings-section {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.settings-section h3 {
  color: var(--navy);
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--gray-border);
}

.settings-item {
  margin-bottom: var(--spacing-md);
}

.settings-item:last-child {
  margin-bottom: 0;
}

.settings-item label {
  display: block;
  font-size: 0.875rem;
  color: var(--gray-text);
  margin-bottom: var(--spacing-xs);
}

.settings-item input {
  margin-top: var(--spacing-xs);
}

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle {
  position: relative;
  width: 48px;
  height: 28px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--gray-border);
  border-radius: var(--radius-full);
  transition: 0.3s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: var(--white);
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
  background-color: var(--orange);
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.version {
  font-size: 0.875rem;
  color: var(--gray-text);
}

.tagline {
  color: var(--orange);
  font-style: italic;
}

.danger-zone {
  border: 2px solid var(--error);
}

/* ========================================
   EMPTY STATES
   ======================================== */

.empty-state {
  text-align: center;
  padding: var(--spacing-2xl) var(--spacing-lg);
  color: var(--gray-text);
}

.empty-state p {
  margin-bottom: var(--spacing-lg);
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.toast-container {
  position: fixed;
  bottom: var(--spacing-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.toast {
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--gray-darkest);
  color: var(--white);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  animation: toastIn 0.3s ease;
  min-width: 200px;
  text-align: center;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--error);
}

@keyframes toastIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ========================================
   UTILITIES
   ======================================== */

.mt-2 { margin-top: var(--spacing-sm); }
.mt-4 { margin-top: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-md); }
.text-center { text-align: center; }

/* ========================================
   RESPONSIVE
   ======================================== */

@media (min-width: 768px) {
  .sidebar {
    left: 0;
    box-shadow: none;
    border-right: 1px solid var(--gray-border);
  }
  
  .main-content {
    margin-left: 260px;
    max-width: calc(800px + 260px);
  }
  
  .menu-btn {
    display: none;
  }
  
  .quick-actions {
    flex-direction: row;
  }
  
  .quick-actions .btn {
    flex: 1;
  }
}

/* Dark Mode */
body.dark-mode {
  --white: #1A1A1A;
  --gray-lightest: #111111;
  --gray-light: #222222;
  --gray-border: #333333;
  --gray-text: #888888;
  --gray-dark: #EEEEEE;
  --gray-darkest: #FFFFFF;
}

/* ========================================
   VIEW MODE TOGGLE
   ======================================== */

.view-mode-toggle {
  display: flex;
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  background: var(--white);
  border-bottom: 1px solid var(--gray-border);
  z-index: 98;
}

.mode-btn {
  flex: 1;
  padding: var(--spacing-md);
  border: none;
  background: var(--gray-light);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: var(--navy);
  color: var(--white);
}

.mode-btn:first-child {
  border-right: 1px solid var(--gray-border);
}

.mode-helper {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--gray-light);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--gray-text);
  text-align: center;
  margin-bottom: var(--spacing-md);
}

.list-detail-content {
  padding-top: calc(var(--header-height) + 52px + var(--spacing-md));
}

/* Needed badge */
.needs-badge {
  font-size: 0.75rem;
}

.item-card.needed {
  border-left: 3px solid var(--orange);
}

/* Market mode: hide add section */
.market-mode .add-item-section {
  display: none;
}

.market-mode .mode-helper {
  background: #D1FAE5;
  color: #065F46;
}

/* ========================================
   MARKETS PAGE
   ======================================== */

.markets-grid {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.market-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--card-bg, #fff);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.market-icon {
  font-size: 2rem;
}

.market-info {
  flex: 1;
}

.market-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.market-address {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0.25rem 0 0;
}

/* ========================================
   ITEM PRICE BUTTON
   ======================================== */

.item-price-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 60px;
  text-align: center;
  transition: all 0.2s;
}

.item-price-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.item-price-btn:active {
  transform: scale(0.98);
}


/* ========================================
   CHECK-IN MODAL MARKETS LIST
   ======================================== */

.market-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  margin: 0.5rem 0;
  background: var(--card-bg, #f8f9fa);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.market-option:hover {
  background: var(--card-hover, #e9ecef);
}

.market-option input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary, #1E3A6E);
}

.market-option .market-name {
  font-weight: 600;
  flex: 1;
}

.market-option .market-address {
  font-size: 0.85rem;
  color: var(--text-secondary);
}


/* ========================================
   PRICE HISTORY WITH COLORS (US-2)
   ======================================== */

.price-history-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  background: var(--card-bg, #f8f9fa);
  border-radius: 8px;
  border-left: 4px solid #6c757d; /* gray default */
}

.price-history-item.green {
  border-left-color: #10b981;
  background: #ecfdf5;
}

.price-history-item.red {
  border-left-color: #ef4444;
  background: #fef2f2;
}

.price-history-item .price-date {
  font-size: 0.85rem;
  color: var(--text-secondary);
  min-width: 80px;
}

.price-history-item .tag-own,
.price-history-item .tag-other {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

.price-history-item .tag-own {
  background: #1E3A6E;
  color: white;
}

.price-history-item .tag-other {
  background: #e9ecef;
  color: #495057;
}

/* US-16: Community price badge (GPS confirmed at market) */
.price-history-item .tag-community {
  font-size: 0.8rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  background: #d1fae5;
  color: #065f46;
  font-weight: 600;
  title: 'Preço registrado no mercado';
}

.price-history-item .price-market {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}

.price-history-item .price-value {
  font-weight: 700;
  font-size: 1.1rem;
  margin-left: auto;
}

.price-history-item .price-diff {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.price-history-item.green .price-diff {
  color: #10b981;
  background: #d1fae5;
}

.price-history-item.red .price-diff {
  color: #ef4444;
  background: #fee2e2;
}

/* ========================================
   PRICE CONSENSUS (US-6)
   ======================================== */

.price-consensus {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  margin: 1rem 0;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-radius: 8px;
  border-left: 4px solid #f59e0b;
}

.consensus-label {
  font-weight: 600;
  color: #92400e;
}

.consensus-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #92400e;
}

.consensus-votes {
  font-size: 0.85rem;
  color: #78350f;
}

/* ========================================
   PRICE SUMMARY (US-2)
   ======================================== */

.price-summary {
  display: flex;
  gap: 1.5rem;
  padding: 1rem;
  margin: 1rem 0;
  background: var(--card-bg, #f8f9fa);
  border-radius: 8px;
}

.price-stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.price-stat .label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
}

.price-stat .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ========================================
   PRICE CALCULATIONS (US-1)
   ======================================== */

.price-calculations {
  padding: 1rem;
  margin-top: 1rem;
  background: #eff6ff;
  border-radius: 8px;
  border-left: 4px solid #3b82f6;
}

.calc-result {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.calc-label {
  font-weight: 600;
  color: #1e40af;
}

.calc-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e40af;
}

/* ========================================
   FORM ROWS (PRICE ENTRY)
   ======================================== */

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-row .form-group {
  margin-bottom: 0;
}

.form-row small {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ========================================
   RESPONSIVE (MOBILE)
   ======================================== */

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .price-summary {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .price-history-item {
    flex-wrap: wrap;
  }
  
  .price-history-item .price-value {
    margin-left: 0;
    width: 100%;
    text-align: right;
  }
}

/* Version Badge */
.version-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 10px;
  color: #999;
  background: #f5f5f5;
  padding: 4px 8px;
  border-radius: 3px;
  font-family: monospace;
  border: 1px solid #ddd;
}

/* Brand Autocomplete (US-12) */
.brand-autocomplete-wrapper {
  position: relative;
}
.brand-suggestions {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 180px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.brand-suggestions.active {
  display: block;
}
.brand-suggestion-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}
.brand-suggestion-item:last-child {
  border-bottom: none;
}
.brand-suggestion-item:hover,
.brand-suggestion-item.selected {
  background: #e8f4fd;
}
.brand-suggestion-item.create-new {
  color: #2196F3;
  font-weight: 600;
}
.brand-suggestion-item.create-new::before {
  content: '+ ';
}

/* Quantity in list badge (US-14) */
.qty-badge {
  display: inline-block;
  background: #ff6b35;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  vertical-align: middle;
  margin-right: 2px;
}
