/* css/main.css - Estilos Base Mobile-First y Variables Globales */
:root {
  --primary: #147a45;
  --primary-hover: #0e5a32;
  --primary-light: #e8f5e9;
  --primary-border: #147a45;
  
  --secondary: #495057;
  --bg-body: #f4f6f8;
  --bg-card: #ffffff;
  --text-main: #212529;
  --text-muted: #6c757d;
  --border-color: #dee2e6;
  
  /* Status Colors */
  --status-draft: #6c757d;
  --status-pending: #fd7e14;
  --status-approved: #0d6efd;
  --status-paid: #198754;
  --status-rejected: #dc3545;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --radius: 8px;
  --font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  max-width: 100%;
  overflow-x: clip;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 15px;
  max-width: 100%;
  overflow-x: clip;
  padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px)); /* Espacio para barra de navegación móvil con safe-area */
}

@media (max-width: 768px) {
  body {
    overscroll-behavior-y: contain;
  }
}

@media (min-width: 992px) {
  body {
    padding-bottom: 0;
    overscroll-behavior-y: auto;
  }
}

/* Layout Principal */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
}

/* Header Superior */
.top-header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .top-header {
    padding: 8px 12px;
    gap: 8px;
  }
  .brand-title {
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .brand-subtitle {
    display: none;
  }
  #session-user-badge-container {
    padding: 4px 8px !important;
    gap: 6px !important;
  }
  #header-user-company-badge {
    display: none;
  }
  .btn-logout-text {
    display: none;
  }
}

.brand-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  height: 36px;
  width: auto;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

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

/* Selector de Rol en Header */
.role-selector-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--primary-light);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid rgba(20, 122, 69, 0.2);
}

.role-selector-container label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  display: none;
}

@media (min-width: 576px) {
  .role-selector-container label {
    display: inline;
  }
}

.role-select {
  border: none;
  background: transparent;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary);
  cursor: pointer;
  outline: none;
}

/* Layout Adaptativo con Nav Lateral en Desktop */
.main-wrapper {
  display: flex;
  flex: 1;
}

.sidebar-nav {
  display: none; /* En móvil se usa bottom-nav */
  width: 240px;
  background-color: #ffffff;
  border-right: 1px solid var(--border-color);
  padding: 20px 0;
  flex-shrink: 0;
}

@media (min-width: 992px) {
  .sidebar-nav {
    display: block;
  }
}

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

.nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: var(--secondary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  border-left: 4px solid transparent;
}

.nav-item a:hover,
.nav-item.active a {
  color: var(--primary);
  background-color: var(--primary-light);
  border-left-color: var(--primary);
}

.nav-item .icon {
  font-size: 1.2rem;
}

/* Contenido Principal */
.content-area {
  flex: 1;
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 768px) {
  .content-area {
    padding: 24px;
  }
}

/* Navigation Bar Inferior para Móviles */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #ffffff;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px)) 0;
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

@media (min-width: 992px) {
  .bottom-nav {
    display: none;
  }
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  gap: 4px;
}

.bottom-nav-item .icon {
  font-size: 1.3rem;
}

.bottom-nav-item.active {
  color: var(--primary);
}

/* Utilidades generales */
.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-draft { background-color: #e9ecef; color: var(--status-draft); }
.badge-pending { background-color: #fff3cd; color: var(--status-pending); }
.badge-approved { background-color: #cfe2ff; color: var(--status-approved); }
.badge-paid { background-color: #d1e7dd; color: var(--status-paid); }
.badge-rejected { background-color: #f8d7da; color: var(--status-rejected); }
