/* ============================================================
   Agrolution Modern Design System
   Basado en el rediseño propuesto por v0.app
   ============================================================ */

/* ============================================================
   CSS Custom Properties (Design Tokens)
   ============================================================ */
:root {
  --ag-primary:        #227725;
  --ag-primary-dark:   #1b5f1d;
  --ag-primary-light:  rgba(34, 119, 37, 0.10);
  --ag-primary-fg:     #fdfdfd;
  --ag-background:     #f7faf5;
  --ag-foreground:     #1d2c18;
  --ag-card:           #ffffff;
  --ag-card-fg:        #1d2c18;
  --ag-muted:          #eef4ea;
  --ag-muted-fg:       #50584f;
  --ag-border:         #d5e7cc;
  --ag-accent:         #e6f0e0;
  --ag-accent-fg:      #2a3d20;
  --ag-destructive:    #dc2626;
  --ag-radius:         0.75rem;
  --ag-font:           'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  /* Status colors */
  --ag-emerald:        #059669;
  --ag-emerald-bg:     #ecfdf5;
  --ag-blue:           #2563eb;
  --ag-blue-bg:        #eff6ff;
  --ag-amber:          #d97706;
  --ag-amber-bg:       #fffbeb;
  --ag-purple:         #7c3aed;
  --ag-purple-bg:      #f5f3ff;
}

/* ============================================================
   Global Base
   ============================================================ */
body {
  font-family: var(--ag-font) !important;
  background-color: var(--ag-background) !important;
  color: var(--ag-foreground) !important;
  margin-bottom: 0 !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--ag-primary);
}

/* ============================================================
   Navbar
   ============================================================ */
.ag-navbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  width: 100%;
  border-bottom: 1px solid rgba(213, 231, 204, 0.4);
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
}

.ag-nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
}

@media (min-width: 640px) {
  .ag-nav-inner { padding: 0 1.5rem; }
}

@media (min-width: 1024px) {
  .ag-nav-inner { padding: 0 2rem; }
}

/* Brand / Logo */
.ag-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none !important;
  color: var(--ag-foreground) !important;
  flex-shrink: 0;
}

.ag-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  background-color: var(--ag-primary);
  flex-shrink: 0;
}

.ag-brand-icon svg {
  width: 1.5rem;
  height: 1.5rem;
  stroke: var(--ag-primary-fg);
}

.ag-brand-text {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ag-foreground);
  white-space: nowrap;
}

.ag-brand-subtitle {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--ag-muted-fg);
  margin-left: 0.5rem;
  white-space: nowrap;
}

@media (max-width: 575px) {
  .ag-brand-subtitle { display: none; }
  .ag-brand-text { font-size: 1rem; }
}

/* Desktop navigation container */
.ag-nav-desktop {
  display: flex;
  align-items: center;
  gap: 0;
}

.ag-nav-links {
  display: flex;
  align-items: center;
  gap: 0.125rem;
}

.ag-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ag-muted-fg) !important;
  text-decoration: none !important;
  border-radius: 0.5rem;
  transition: color 0.15s ease, background-color 0.15s ease;
  white-space: nowrap;
  line-height: 1;
}

.ag-nav-link:hover {
  color: var(--ag-foreground) !important;
  background-color: var(--ag-accent);
  text-decoration: none !important;
}

.ag-nav-link.ag-nav-active {
  color: var(--ag-primary) !important;
}

.ag-nav-link.ag-nav-active:hover {
  color: var(--ag-primary) !important;
  background-color: var(--ag-accent);
}

.ag-nav-link svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* Right side user area */
.ag-nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.75rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--ag-border);
}

.ag-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  background-color: rgba(230, 240, 224, 0.5);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ag-muted-fg);
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ag-user-badge svg {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
}

.ag-btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ag-muted-fg) !important;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  text-decoration: none !important;
  transition: color 0.15s ease, background-color 0.15s ease;
  white-space: nowrap;
  cursor: pointer;
}

.ag-btn-logout:hover {
  color: var(--ag-destructive) !important;
  background-color: #fef2f2;
  text-decoration: none !important;
}

.ag-btn-logout svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.ag-btn-login {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ag-primary-fg) !important;
  background-color: var(--ag-primary);
  border: none;
  border-radius: 0.5rem;
  text-decoration: none !important;
  transition: background-color 0.15s ease;
  white-space: nowrap;
  cursor: pointer;
}

.ag-btn-login:hover {
  background-color: var(--ag-primary-dark) !important;
  color: var(--ag-primary-fg) !important;
  text-decoration: none !important;
}

.ag-btn-login svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* Mobile Toggler */
.ag-navbar-toggler {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: transparent;
  border-radius: 0.5rem;
  cursor: pointer;
  color: var(--ag-muted-fg);
  padding: 0;
  line-height: 1;
}

.ag-navbar-toggler:hover {
  background-color: var(--ag-accent);
}

.ag-navbar-toggler svg {
  width: 1.5rem;
  height: 1.5rem;
  display: block;
}

/* Mobile dropdown */
.ag-mobile-nav {
  border-top: 1px solid rgba(213, 231, 204, 0.5);
  background-color: var(--ag-card);
}

.ag-mobile-nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
}

.ag-mobile-nav .ag-nav-link {
  display: flex;
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 0.125rem;
}

.ag-mobile-nav-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  margin-top: 0.375rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--ag-border);
}

@media (max-width: 767px) {
  .ag-navbar-toggler { display: flex; }
  .ag-nav-desktop { display: none !important; }
}

/* ============================================================
   Footer
   ============================================================ */
.ag-footer {
  border-top: 1px solid var(--ag-border);
  background-color: var(--ag-card);
  margin-top: 3rem;
}

.ag-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 3rem 1.5rem 1.5rem;
}

.ag-footer-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 2rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 640px) {
  .ag-footer-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .ag-footer-grid { grid-template-columns: repeat(4, 1fr); }
}

.ag-footer-logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none !important;
  margin-bottom: 0.625rem;
}

.ag-footer-tagline {
  font-size: 0.875rem;
  color: var(--ag-muted-fg);
  max-width: 18rem;
  margin: 0;
  line-height: 1.5;
}

.ag-footer-heading {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ag-foreground);
  margin-top: 0;
  margin-bottom: 0.625rem;
}

.ag-footer-text {
  font-size: 0.875rem;
  color: var(--ag-muted-fg);
  line-height: 1.6;
  margin: 0;
}

.ag-footer-link {
  font-size: 0.875rem;
  color: var(--ag-primary) !important;
  text-decoration: none !important;
}

.ag-footer-link:hover {
  text-decoration: underline !important;
}

.ag-footer-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ag-footer-list li {
  margin-bottom: 0.375rem;
}

.ag-footer-bottom {
  padding-top: 1.5rem;
  border-top: 1px solid var(--ag-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

@media (min-width: 640px) {
  .ag-footer-bottom {
    flex-direction: row;
    justify-content: space-between;
  }
}

.ag-footer-copy {
  font-size: 0.875rem;
  color: var(--ag-muted-fg);
  margin: 0;
}

.ag-social-links {
  display: flex;
  gap: 0.375rem;
}

.ag-social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  color: var(--ag-muted-fg) !important;
  border: 1px solid var(--ag-border);
  text-decoration: none !important;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.ag-social-link:hover {
  color: var(--ag-primary) !important;
  border-color: var(--ag-primary);
  background-color: var(--ag-accent);
}

.ag-social-link svg {
  width: 1rem;
  height: 1rem;
}

/* ============================================================
   Login Page
   ============================================================ */
.ag-login-outer {
  min-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
}

.ag-login-main {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.ag-login-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(34, 119, 37, 0.06) 0%,
    var(--ag-background) 50%,
    rgba(230, 240, 224, 0.4) 100%
  );
  pointer-events: none;
}

.ag-login-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23000000' fill-opacity='1' fill-rule='evenodd'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.ag-login-content {
  position: relative;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.ag-login-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
  align-items: center;
}

@media (min-width: 1024px) {
  .ag-login-grid {
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
  }
}

/* Hero (left side) */
.ag-login-hero {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.ag-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  background-color: var(--ag-primary-light);
  color: var(--ag-primary);
  font-size: 0.875rem;
  font-weight: 500;
  width: fit-content;
}

.ag-badge svg {
  width: 1rem;
  height: 1rem;
}

.ag-login-title {
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ag-foreground);
  line-height: 1.1;
  margin: 0;
}

.ag-login-subtitle {
  font-size: 1.1875rem;
  color: var(--ag-muted-fg);
  max-width: 36rem;
  margin: 0;
  line-height: 1.65;
}

.ag-feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}

@media (max-width: 500px) {
  .ag-feature-grid { grid-template-columns: 1fr; }
}

.ag-feature-card {
  display: flex;
  gap: 0.875rem;
  padding: 1rem;
  border-radius: var(--ag-radius);
  background-color: var(--ag-card);
  border: 1px solid rgba(213, 231, 204, 0.6);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.ag-feature-icon {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  background-color: var(--ag-primary-light);
  color: var(--ag-primary);
}

.ag-feature-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.ag-feature-body h3 {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ag-foreground);
  margin: 0 0 0.25rem;
}

.ag-feature-body p {
  font-size: 0.8125rem;
  color: var(--ag-muted-fg);
  margin: 0;
  line-height: 1.5;
}

/* Login form card (right side) */
.ag-login-form-wrapper {
  width: 100%;
  max-width: 28rem;
  margin-left: auto;
}

@media (max-width: 1023px) {
  .ag-login-form-wrapper {
    max-width: 100%;
    margin: 0 auto;
  }
}

.ag-card {
  background-color: var(--ag-card);
  border-radius: var(--ag-radius);
  border: 1px solid rgba(213, 231, 204, 0.6);
  box-shadow:
    0 10px 25px rgba(0, 0, 0, 0.07),
    0 4px 6px rgba(0, 0, 0, 0.04);
}

.ag-card-header {
  padding: 1.5rem 1.5rem 1.125rem;
}

.ag-card-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ag-foreground);
  margin: 0 0 0.375rem;
}

.ag-card-header p {
  font-size: 0.9375rem;
  color: var(--ag-muted-fg);
  margin: 0;
}

.ag-card-body {
  padding: 0 1.5rem 1.5rem;
}

/* Form controls */
.ag-form-group {
  margin-bottom: 1.125rem;
}

.ag-form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ag-foreground);
  margin-bottom: 0.375rem;
}

.ag-form-input {
  display: block;
  width: 100%;
  height: 2.75rem;
  padding: 0 0.875rem;
  font-size: 0.9375rem;
  font-family: var(--ag-font);
  color: var(--ag-foreground);
  background-color: var(--ag-muted);
  border: 1px solid var(--ag-border);
  border-radius: calc(var(--ag-radius) - 0.25rem);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  box-sizing: border-box;
}

.ag-form-input:focus {
  border-color: var(--ag-primary);
  background-color: var(--ag-card);
  box-shadow: 0 0 0 3px rgba(34, 119, 37, 0.15);
}

.ag-form-input::placeholder {
  color: var(--ag-muted-fg);
  opacity: 0.7;
}

.ag-btn-submit {
  display: block;
  width: 100%;
  height: 2.75rem;
  padding: 0 1rem;
  font-size: 1rem;
  font-weight: 500;
  font-family: var(--ag-font);
  color: var(--ag-primary-fg) !important;
  background-color: var(--ag-primary);
  border: none;
  border-radius: calc(var(--ag-radius) - 0.25rem);
  cursor: pointer;
  transition: background-color 0.15s ease;
  margin-top: 0.5rem;
  text-align: center;
}

.ag-btn-submit:hover {
  background-color: var(--ag-primary-dark);
}

.ag-btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Validation errors */
.ag-validation-errors {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: calc(var(--ag-radius) - 0.25rem);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.ag-validation-errors ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ag-validation-errors li,
.ag-validation-errors span {
  font-size: 0.875rem;
  color: var(--ag-destructive);
}

/* ============================================================
   Dashboard / Index Page
   ============================================================ */
.ag-dashboard-wrap {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  overflow-x: hidden;
  box-sizing: border-box;
}

@media (min-width: 640px) {
  .ag-dashboard-wrap { padding: 1.5rem 1.5rem 3rem; }
}

@media (min-width: 1024px) {
  .ag-dashboard-wrap { padding: 1.5rem 2rem 3rem; }
}

.ag-dashboard-search {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.ag-search-icon {
  color: var(--ag-muted-fg);
  flex-shrink: 0;
}

.ag-search-input {
  height: 2.5rem;
  padding: 0 0.875rem;
  font-size: 0.9375rem;
  font-family: var(--ag-font);
  color: var(--ag-foreground);
  background-color: var(--ag-card);
  border: 1px solid var(--ag-border);
  border-radius: calc(var(--ag-radius) - 0.25rem);
  outline: none;
  min-width: 280px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ag-search-input:focus {
  border-color: var(--ag-primary);
  box-shadow: 0 0 0 3px rgba(34, 119, 37, 0.15);
}

.ag-section-card {
  background-color: var(--ag-card);
  border-radius: var(--ag-radius);
  border: 1px solid var(--ag-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.ag-section-card-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--ag-foreground);
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--ag-border);
  background-color: rgba(34, 119, 37, 0.04);
  margin: 0;
}

.ag-section-card-body {
  padding: 1.25rem;
}

.ag-tables-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

/* Prevent grid items from overflowing their track */
.ag-tables-grid > .ag-section-card {
  min-width: 0;
}

@media (min-width: 768px) {
  .ag-tables-grid { grid-template-columns: 1fr 1fr; }
}

/* DataTables wrapper scrolls horizontally inside its card */
.ag-section-card .dataTables_wrapper {
  overflow-x: auto;
  min-width: 0;
}

/* ============================================================
   Map Card (integrated header, toggle, legend)
   ============================================================ */

/* Header row: search on left, title on right */
.ag-map-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--ag-border);
}

.ag-map-search {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--ag-muted-fg);
  flex-shrink: 0;
}

.ag-map-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ag-foreground);
  margin: 0 0 0 auto;
  font-family: var(--ag-font);
}

@media (max-width: 575px) {
  .ag-map-title { margin-left: 0; }
}

/* Map container — position relative so overlays work */
.ag-map-wrap {
  position: relative;
}

/* Map type toggle — top-left overlay */
.ag-map-toggle {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 1000;
  display: flex;
  overflow: hidden;
  border-radius: 0.5rem;
  border: 1px solid var(--ag-border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}

.ag-map-toggle-btn {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: var(--ag-font);
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  background-color: var(--ag-muted);
  color: var(--ag-muted-fg);
  line-height: 1.4;
}

.ag-map-toggle-btn:hover {
  background-color: rgba(34, 119, 37, 0.08);
}

.ag-map-toggle-btn.active {
  background-color: var(--ag-card);
  color: var(--ag-foreground);
}

/* Status legend — bottom-left overlay */
.ag-map-legend {
  position: absolute;
  bottom: 1.5rem;
  left: 1rem;
  z-index: 1000;
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 0.5rem;
  border: 1px solid var(--ag-border);
  padding: 0.625rem 0.75rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}

.ag-map-legend-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ag-muted-fg);
  margin-bottom: 0.375rem;
  font-family: var(--ag-font);
}

.ag-map-legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 0.875rem;
}

.ag-map-legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--ag-foreground);
  font-family: var(--ag-font);
  white-space: nowrap;
}

.ag-map-legend-dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

/* Map */
#map {
  height: 500px;
  width: 100%;
  border-radius: 0;
}

/* ============================================================
   Summary Card (platforms-summary prototype)
   ============================================================ */

.ag-summary-header {
  padding: 1rem 1.5rem;
  background: rgba(34, 119, 37, 0.05);
  border-bottom: 1px solid var(--ag-border);
  border-radius: var(--ag-radius) var(--ag-radius) 0 0;
}
.ag-summary-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ag-foreground);
  margin: 0 0 0.125rem;
}
.ag-summary-subtitle {
  font-size: 0.8125rem;
  color: var(--ag-muted-fg);
  margin: 0;
}

/* Mobile cards */
.ag-summary-mobile {
  display: block;
  padding: 0.5rem 0.75rem;
}
@media (min-width: 768px) {
  .ag-summary-mobile { display: none; }
}
.ag-summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--ag-border);
}
.ag-summary-item:last-child { border-bottom: none; }
.ag-summary-item-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.ag-summary-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ag-summary-icon svg {
  width: 1.125rem;
  height: 1.125rem;
}
.ag-summary-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ag-foreground);
  margin: 0 0 0.125rem;
}
.ag-summary-total {
  font-size: 0.75rem;
  color: var(--ag-muted-fg);
  margin: 0;
}
.ag-summary-counts {
  display: flex;
  gap: 1rem;
  text-align: right;
}
.ag-count {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ag-foreground);
  margin: 0 0 0.0625rem;
}
.ag-count--alert { color: #dc2626; }
.ag-count--muted { color: var(--ag-muted-fg); }
.ag-count-label {
  font-size: 0.6875rem;
  color: var(--ag-muted-fg);
  margin: 0;
}

/* Desktop table */
.ag-summary-desktop {
  display: none;
  overflow-x: auto;
}
@media (min-width: 768px) {
  .ag-summary-desktop { display: block; }
}
.ag-summary-thead-row { background: rgba(238, 244, 234, 0.3); }
.ag-summary-th {
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ag-foreground);
  border-bottom: 1px solid var(--ag-border);
  white-space: nowrap;
  text-align: left;
}
.ag-th-alert { color: #dc2626 !important; }
.ag-th-muted { color: var(--ag-muted-fg) !important; font-weight: 500 !important; }
.ag-summary-row { border-bottom: 1px solid var(--ag-border); transition: background-color 0.15s ease; }
.ag-summary-row:hover { background-color: rgba(230, 240, 224, 0.3); }
.ag-summary-row:last-child { border-bottom: none; }
.ag-summary-td {
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  vertical-align: middle;
}
.ag-summary-td-icon {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.ag-td-num {
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--ag-foreground);
  vertical-align: middle;
}

/* ============================================================
   Table Overrides
   ============================================================ */

/* Existing functional classes — just update colors */
.table-toolbar {
  color: #ffffff !important;
  background: var(--ag-primary) !important;
  text-align: left !important;
  padding: 0.75rem 1rem !important;
  margin-bottom: 0 !important;
  font-weight: 600 !important;
  font-family: var(--ag-font) !important;
  font-size: 0.875rem !important;
  border-radius: 0;
}

/* Per-table color variants */
.table-toolbar-campo    { background: var(--ag-emerald) !important; }
.table-toolbar-fabrica  { background: var(--ag-blue)    !important; }
.table-toolbar-transito { background: var(--ag-amber)   !important; }
.table-toolbar-descarga { background: var(--ag-purple)  !important; }
.table-toolbar-monitor  { background: var(--ag-primary) !important; }

.thead-green th {
  color: #fff !important;
  background-color: var(--ag-primary) !important;
  border-color: var(--ag-primary) !important;
  text-align: center !important;
}

/* Bootstrap table overrides */
.table {
  font-family: var(--ag-font);
  font-size: 0.875rem;
  color: var(--ag-foreground);
  margin-bottom: 0;
}

.table th {
  font-weight: 600;
  color: var(--ag-muted-fg);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--ag-border) !important;
  background-color: var(--ag-muted);
  padding: 0.625rem 0.875rem;
  white-space: nowrap;
}

.table td {
  vertical-align: middle !important;
  padding: 0.5625rem 0.875rem;
  border-bottom: 1px solid rgba(213, 231, 204, 0.5) !important;
  color: var(--ag-foreground);
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(34, 119, 37, 0.025);
}

.table-striped tbody tr:hover,
tr.pointer:hover {
  background-color: var(--ag-accent) !important;
  cursor: pointer;
}

.table-bordered {
  border: 1px solid var(--ag-border) !important;
}

.table-bordered td,
.table-bordered th {
  border: 1px solid rgba(213, 231, 204, 0.5) !important;
}

/* Device thumbnail in tables */
.enfabrica-photo {
  display: inline-block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-size: 32px 35px;
  background-position: center center;
  vertical-align: middle;
  line-height: 32px;
  box-shadow: inset 0 0 1px #999, inset 0 0 8px rgba(0,0,0,.15);
  margin-left: 3px;
}

.dispositivo-den {
  display: inline-block;
  vertical-align: middle;
  line-height: 32px;
  padding-left: 8px;
  font-weight: 500;
}

tr.pointer { cursor: pointer; }

/* Status colors */
.warningllenadoverde        { color: #16a34a !important; }
.warningllenadorojo         { color: var(--ag-destructive) !important; }
.warningllenadorojosimple   { color: var(--ag-destructive) !important; font-weight: 600; }
.acumuladostyle             { color: var(--ag-amber) !important; display: inline-block; vertical-align: middle; line-height: 32px; padding-left: 2px; }
.online  { color: #16a34a !important; }
.offline { color: var(--ag-amber) !important; }

/* Google Maps InfoWindow classes */
.fondoRojoInfoWindow    { color: var(--ag-destructive); font-weight: bold; }
.fondoVerdeInfoWindow   { color: #16a34a; font-weight: bold; }
.fondoAmarilloInfoWindow{ color: var(--ag-amber); font-weight: bold; }
.fondoAzulInfoWindow    { color: var(--ag-blue); font-weight: bold; }

/* ============================================================
   DataTables Overrides
   ============================================================ */
.dataTables_wrapper {
  font-family: var(--ag-font);
  padding: 0.5rem;
}

.dataTables_filter label,
.dataTables_length label {
  font-size: 0.875rem;
  color: var(--ag-muted-fg);
}

.dataTables_filter input {
  border: 1px solid var(--ag-border) !important;
  border-radius: calc(var(--ag-radius) - 0.375rem) !important;
  padding: 0.25rem 0.625rem !important;
  font-family: var(--ag-font);
  font-size: 0.875rem;
  outline: none;
  background-color: var(--ag-card);
  color: var(--ag-foreground);
}

.dataTables_filter input:focus {
  border-color: var(--ag-primary) !important;
  box-shadow: 0 0 0 2px rgba(34, 119, 37, 0.15);
}

.dataTables_info {
  font-size: 0.8125rem;
  color: var(--ag-muted-fg);
}

.page-item.active .page-link {
  background-color: var(--ag-primary) !important;
  border-color: var(--ag-primary) !important;
  color: #fff !important;
}

.page-link {
  color: var(--ag-primary) !important;
  border-color: var(--ag-border) !important;
}

.page-link:hover {
  background-color: var(--ag-accent) !important;
}

.page-link:focus {
  box-shadow: 0 0 0 0.2rem rgba(34, 119, 37, 0.25) !important;
}

/* ============================================================
   jQuery UI Autocomplete
   ============================================================ */
.ui-autocomplete {
  font-family: var(--ag-font);
  border: 1px solid var(--ag-border) !important;
  border-radius: var(--ag-radius) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
  background: var(--ag-card) !important;
  z-index: 1040 !important;
}

.ui-menu-item-wrapper {
  padding: 0.5rem 0.875rem !important;
  font-size: 0.875rem;
  color: var(--ag-foreground) !important;
}

.ui-menu-item-wrapper:hover,
.ui-state-active,
.ui-menu-item-wrapper.ui-state-active {
  background-color: var(--ag-accent) !important;
  color: var(--ag-foreground) !important;
  border: none !important;
  margin: 0 !important;
}

/* ============================================================
   NProgress Bar
   ============================================================ */
#nprogress .bar {
  background: var(--ag-primary) !important;
  height: 3px !important;
}

#nprogress .peg {
  box-shadow: 0 0 10px var(--ag-primary), 0 0 5px var(--ag-primary) !important;
}

#nprogress .spinner-icon {
  border-top-color: var(--ag-primary) !important;
  border-left-color: var(--ag-primary) !important;
}

/* ============================================================
   Bootstrap btn overrides (only for .btn-primary)
   ============================================================ */
.btn-primary {
  background-color: var(--ag-primary) !important;
  border-color: var(--ag-primary) !important;
  color: var(--ag-primary-fg) !important;
  font-family: var(--ag-font);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--ag-primary-dark) !important;
  border-color: var(--ag-primary-dark) !important;
}

/* Remove default body margin-bottom from site.css */
body { margin-bottom: 0 !important; }
