/* ============================================================
   SMARTTROUT.CO - Estilos principales
   Paleta: Verde agua + Azul petróleo (acuicultura)
   ============================================================ */

:root {
  --verde:      #0d7a5f;
  --verde-claro:#1aa383;
  --verde-bg:   #e8f7f3;
  --azul:       #0a4d6e;
  --azul-claro: #1278a0;
  --azul-bg:    #e8f3f8;
  --naranja:    #e87420;
  --rojo:       #c0392b;
  --rojo-bg:    #fdecea;
  --gris-1:     #f4f6f7;
  --gris-2:     #e8ecee;
  --gris-3:     #b0bec5;
  --gris-text:  #546e7a;
  --dark:       #1a2e35;
  --white:      #ffffff;
  --shadow:     0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg:  0 4px 20px rgba(0,0,0,0.12);
  --radius:     10px;
  --radius-sm:  6px;
  --font:       'Inter', system-ui, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--gris-1);
  color: var(--dark);
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

/* TOPBAR */
.topbar {
  grid-column: 1 / -1;
  background: var(--azul);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  box-shadow: var(--shadow);
  z-index: 100;
}
.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-weight: 700;
  font-size: 16px;
  text-decoration: none;
}
.topbar-logo span { color: #7de8cf; }
.topbar-granja {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.granja-selector {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
}
.granja-selector option { background: var(--azul); }
.btn-user {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--verde-claro);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}

/* SIDEBAR */
.sidebar {
  background: var(--dark);
  overflow-y: auto;
  padding: 12px 0;
}
.nav-section {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gris-3);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: #b0bec5;
  text-decoration: none;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  font-size: 13px;
}
.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,0.07);
  color: white;
  border-left-color: var(--verde-claro);
}
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }

/* CONTENIDO PRINCIPAL */
.main-content {
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============================================================
   CARDS Y COMPONENTES
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gris-2);
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--dark);
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--verde);
}
.kpi-card.warn  { border-left-color: var(--naranja); }
.kpi-card.alert { border-left-color: var(--rojo); }
.kpi-card.info  { border-left-color: var(--azul-claro); }
.kpi-label { font-size: 11px; color: var(--gris-text); font-weight: 600; text-transform: uppercase; margin-bottom: 6px; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--dark); }
.kpi-sub   { font-size: 11px; color: var(--gris-text); margin-top: 4px; }

/* TABLA */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  padding: 10px 12px;
  background: var(--gris-1);
  color: var(--gris-text);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gris-2);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--gris-2); }
tr:hover td { background: var(--verde-bg); }
.empty-state { text-align: center; padding: 40px; color: var(--gris-text); }

/* BADGES */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green  { background: var(--verde-bg); color: var(--verde); }
.badge-orange { background: #fef3e8; color: var(--naranja); }
.badge-red    { background: var(--rojo-bg); color: var(--rojo); }
.badge-blue   { background: var(--azul-bg); color: var(--azul-claro); }
.badge-gray   { background: var(--gris-2); color: var(--gris-text); }

/* BOTONES */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.btn-primary   { background: var(--verde); color: white; }
.btn-primary:hover { background: var(--verde-claro); }
.btn-secondary { background: var(--gris-2); color: var(--dark); }
.btn-secondary:hover { background: var(--gris-3); }
.btn-danger    { background: var(--rojo-bg); color: var(--rojo); }
.btn-danger:hover { background: var(--rojo); color: white; }
.btn-icon      { padding: 6px; background: transparent; border-radius: 4px; }
.btn-icon:hover { background: var(--gris-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-whatsapp { background: #25d366; color: white; }
.btn-whatsapp:hover { background: #128c7e; }

/* FORMULARIOS */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--gris-text); }
.form-control {
  padding: 8px 12px;
  border: 1.5px solid var(--gris-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: border-color 0.15s;
  background: white;
}
.form-control:focus { outline: none; border-color: var(--verde-claro); }
.form-control.error { border-color: var(--rojo); }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gris-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body  { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--gris-2);
}
.modal-hidden { display: none; }

/* TOAST */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease;
}
.toast-success { background: var(--verde); }
.toast-error   { background: var(--rojo); }
.toast-info    { background: var(--azul-claro); }
@keyframes slideIn { from { transform: translateX(100%); opacity:0 } to { transform: translateX(0); opacity:1 } }

/* PÁGINA LOGIN */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--azul) 0%, var(--verde) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 26px; font-weight: 800; color: var(--azul); }
.login-logo h1 span { color: var(--verde); }
.login-logo p { font-size: 13px; color: var(--gris-text); margin-top: 4px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-btn { padding: 12px; font-size: 15px; width: 100%; justify-content: center; }

/* RESPONSIVE */
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; grid-template-rows: 56px auto 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: block; position: fixed; top: 56px; left: 0; bottom: 0; width: 240px; z-index: 200; }
  .main-content { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
