/* assets/css/style.css - Modern TMS Design System (Light Theme) */

:root {
  --bg-dark: #f8f9fa; /* Background is now light */
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --border-color: #e5e7eb;
  --primary: #262626;
  --primary-hover: #404040;
  --accent: #c69a48; /* Gold/brown accent from image */
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --radius: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Layout */
.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: 70px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 1000;
  overflow-y: hidden;
  overflow-x: hidden;
  white-space: nowrap;
  transition: all 0.3s ease;
}

/* Scrollbar tuning for Webkit (Chrome, Edge, Safari) */
.sidebar::-webkit-scrollbar {
  width: 5px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
}
.sidebar-logo {
  max-width: 100%;
  height: auto;
  max-height: 80px;
  transition: all 0.3s ease;
}

.sidebar.sidebar-pinned {
  width: 260px;
  box-shadow: 4px 0 15px rgba(0,0,0,0.1);
  overflow-y: auto;
}

.sidebar:not(.sidebar-pinned) .sidebar-brand {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}
.sidebar:not(.sidebar-pinned) .sidebar-logo {
  max-height: 35px;
}

.sidebar:not(.sidebar-pinned) .sidebar-subtitle,
.sidebar:not(.sidebar-pinned) .sidebar-section {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.sidebar:not(.sidebar-pinned) .nav-link {
  width: auto;
  overflow: hidden;
  padding: 0.85rem;
  justify-content: center;
}

.sidebar:not(.sidebar-pinned) .nav-text {
  display: none;
}

.sidebar:not(.sidebar-pinned) .lang-switcher {
  flex-direction: column;
  padding: 0 0.2rem !important;
  align-items: center;
}

.sidebar:not(.sidebar-pinned) .lang-text {
  display: none;
}

.sidebar-header {
  padding-bottom: 1.5rem;
  margin-bottom: 1rem;
  text-align: center;
}

.sidebar-brand {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #1f2937;
  text-transform: uppercase;
}

.sidebar-subtitle {
  color: var(--text-secondary);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.5rem;
}

.sidebar-section {
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  padding-left: 0.75rem;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: #4b5563;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 0.2rem;
}

.nav-link:hover {
  background-color: #f3f4f6;
  color: #111827;
}

.nav-link.active {
  font-weight: 600;
  color: #111827;
  background-color: #f3f4f6;
}

/* Main Content Area */
.main-content { transition: margin-left 0.3s ease, width 0.3s ease;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  margin-left: 70px;
  width: calc(100vw - 70px);
}

/* Header */
.navbar {
  height: 64px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-badge {
  background: #f3f4f6;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-logout {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--danger);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-logout:hover {
  background-color: rgba(239, 68, 68, 0.05);
  border-color: var(--danger);
}

/* Content Container */
.content-wrapper {
  padding: 2rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--accent); /* Gold color from image */
}

/* Cards & Grid */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.kpi-icon.purple { background-color: #f3e8ff; color: #9333ea; }
.kpi-icon.green { background-color: #dcfce7; color: #16a34a; }
.kpi-icon.orange { background-color: #ffedd5; color: #ea580c; }
.kpi-icon.brown { background-color: #fef3c7; color: #b45309; }

.kpi-content {
  display: flex;
  flex-direction: column;
}

.kpi-title {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  margin-top: 0.25rem;
}

.kpi-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--accent);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #f3f4f6;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

/* Table */
.table-container {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.table-header-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1.5rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th {
  padding: 1rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

.table td {
  padding: 1rem 0.5rem;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.9rem;
  color: #4b5563;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover {
  background-color: #f9fafb;
}

/* Status Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active, .badge-completada {
  background: #22c55e;
  color: white;
}

.badge-en_transito, .badge-maintenance {
  background: #f59e0b;
  color: white;
}

.badge-pendiente, .badge-inactive {
  background: #ef4444;
  color: white;
}

/* Forms and Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background-color: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

/* Auth Login Page */
.login-body {
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100vw;
}

.login-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 2.5rem;
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}

.alert-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
}

/* Map Containers */
#map {
  width: 100%;
  height: 600px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

.main-content.sidebar-pinned { margin-left: 260px; width: calc(100vw - 260px); }


.preload * { transition: none !important; }
