/* Design System - Casa Xitla */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --primary-color: #2d6a4f; /* Verde bosque */
  --primary-hover: #1b4332;
  --secondary-color: #d68c45; /* Arcilla / Terracota */
  --secondary-hover: #b87331;
  --bg-color: #f7f9f6; /* Off-white cálido */
  --card-bg: #ffffff;
  --text-color: #2d3748;
  --text-muted: #718096;
  --border-color: #e2e8f0;
  --success-color: #38a169;
  --warning-color: #dd6b20;
  --danger-color: #e53e3e;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --sidebar-width: 260px;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Layout */
#sidebar {
  width: var(--sidebar-width);
  background-color: #1e352f; /* Fondo oscuro foresta */
  color: #ecf3f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  padding: 1.5rem 1rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

#sidebar::-webkit-scrollbar {
  width: 6px;
}

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

#sidebar::-webkit-scrollbar-thumb {
  background-color: rgba(255,255,255,0.2);
  border-radius: 3px;
}

#main-content {
  margin-left: var(--sidebar-width);
  flex-grow: 1;
  padding: 2.5rem 3rem;
  max-width: 1400px;
  width: calc(100% - var(--sidebar-width));
}

/* Brand logo */
.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 2.5rem;
}

.brand-icon {
  background-color: var(--secondary-color);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 1.2rem;
}

.brand-name {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: white;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

/* Navigation */
.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.85rem 1rem;
  color: #b7cdc3;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: white;
}

.nav-link.active {
  background-color: var(--primary-color);
  color: white;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Breadcrumbs Component */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb-separator {
  color: #cbd5e1;
  font-size: 0.75rem;
}

/* Navigation Dropdowns */
.nav-dropdown {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  color: #b7cdc3;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s ease;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  outline: none;
}

.nav-dropdown-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: white;
}

.nav-dropdown-btn .arrow {
  margin-left: auto;
  font-size: 0.6rem;
  transition: transform 0.2s ease;
  color: #8fa89d;
}

.nav-dropdown.open .nav-dropdown-btn .arrow {
  transform: rotate(180deg);
}

.nav-dropdown-content {
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  padding-left: 1rem;
  margin-left: 1rem;
  margin-top: 0.2rem;
  margin-bottom: 0.4rem;
}

.nav-dropdown.open .nav-dropdown-content {
  display: flex;
}

.nav-sub-link {
  display: block;
  padding: 0.5rem 0.8rem;
  color: #9eb5ac;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-sub-link:hover {
  color: white;
  background-color: rgba(255, 255, 255, 0.05);
}

.nav-sub-link.active {
  color: white;
  background-color: rgba(255, 255, 255, 0.12);
  font-weight: 600;
}

/* Page Headers */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-title h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1a2a24;
}

.page-title p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Cards & Containers */
.card {
  background-color: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  padding: 2rem;
  margin-bottom: 2rem;
  transition: transform 0.2s, box-shadow 0.2s;
  min-width: 0; /* Prevents grid blowout */
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: #1e352f;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Buttons */
.btn, a.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none !important;
}

.btn:hover, a.btn:hover, button.btn:hover,
.btn:focus, a.btn:focus, button.btn:focus,
.btn:active, a.btn:active, button.btn:active {
  text-decoration: none !important;
}

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

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

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

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

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

.btn-outline:hover {
  background-color: #f7f9f6;
  border-color: var(--text-muted);
  color: var(--text-color);
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #3b4e47;
}

input, select, textarea {
  font-family: var(--font-family);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
  outline: none;
  background-color: #fbfcfb;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.15);
  background-color: white;
}

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th, td {
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border-color);
}

th {
  background-color: #f2f5f1;
  font-weight: 600;
  color: #3b4e47;
}

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

tr:hover td {
  background-color: #fcfdfc;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-new { background-color: #ebf8ff; color: #2b6cb0; }
.badge-progress { background-color: #fffaf0; color: #dd6b20; }
.badge-sent { background-color: #e6fffa; color: #319795; }
.badge-confirmed { background-color: #f0fff4; color: #38a169; }
.badge-cancelled { background-color: #fff5f5; color: #e53e3e; }

/* Grid Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.metric-card {
  background-color: white;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.metric-info {
  display: flex;
  flex-direction: column;
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #1a2a24;
}

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

/* Indicators and HTMX Loading effects */
.htmx-indicator {
  opacity: 0;
  transition: opacity 150ms ease-in;
}
.htmx-request .htmx-indicator {
  opacity: 1;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive adjustment */
@media (max-width: 1024px) {
  .split-layout {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  #sidebar {
    display: none; /* In final app we will add toggle sidebar for mobile */
  }
  #main-content {
    margin-left: 0;
    width: 100%;
    padding: 1.5rem;
  }
}

/* Utilities for tables and wrapping */
.nowrap {
  white-space: nowrap;
}
.action-buttons {
  display: flex;
  gap: 0.8rem;
  flex-direction: column;
}

/* ==========================================
   SYSTEM DESIGN: MONOCHROMATIC MINIMALIST ICONS
   ========================================== */
.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #a3c2b5;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
  color: #ffffff;
}

.metric-icon {
  background-color: #f1f5f9 !important;
  color: #1e293b !important;
  border: 1px solid #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.icon-mono, .mono-icon {
  filter: grayscale(100%) opacity(0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mono-emoji {
  filter: grayscale(100%) opacity(0.8);
  display: inline-block;
}
