/**
 * TachoLab - Estilos del Dashboard
 * Tema claro profesional
 */

/* === CSS Variables === */
:root {
  --bg-primary: #f5f7fa;
  --bg-sidebar: #1e293b;
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  --bg-hover: #e2e8f0;
  --bg-modal: rgba(0, 0, 0, 0.5);

  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --accent-primary: #3b82f6;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --accent-info: #06b6d4;

  --border-color: #e2e8f0;
  --border-radius: 8px;
  --border-radius-lg: 12px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);

  --sidebar-width: 260px;
  --transition: all 0.2s ease;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
}

#tacholab-app {
  height: 100%;
}

/* === App Layout === */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  margin-left: var(--sidebar-width);
}

/* === Sidebar === */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  z-index: 100;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--accent-primary);
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
  margin-bottom: 4px;
  cursor: pointer;
}

.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--accent-primary);
  color: white;
}

.nav-icon {
  width: 20px;
  height: 20px;
}

.nav-label {
  font-size: 14px;
  font-weight: 500;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

.logout-item:hover {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--accent-danger);
}

/* === Login === */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  margin-bottom: 16px;
}

.login-icon {
  width: 48px;
  height: 48px;
  color: var(--accent-primary);
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--border-radius);
  color: var(--accent-danger);
  font-size: 13px;
}

.error-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* === Forms === */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-wrapper {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  padding-left: 40px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-family);
  transition: var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  width: 100%;
  padding: 10px 12px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-family);
  transition: var(--transition);
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-family);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background-color: #2563eb;
}

.btn-secondary {
  background-color: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-card);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-back {
  margin-bottom: 16px;
}

.btn-icon {
  width: 16px;
  height: 16px;
}

/* === Cards === */
.card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

/* === KPI Grid === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.kpi-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius);
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--accent-primary);
}

.kpi-icon-warning {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--accent-warning);
}

.kpi-icon-success {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--accent-success);
}

.kpi-content {
  display: flex;
  flex-direction: column;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-value-warning {
  color: var(--accent-warning);
}

.kpi-value-success {
  color: var(--accent-success);
}

.kpi-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* === Charts === */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.chart-card {
  min-height: 300px;
}

.chart-container {
  position: relative;
  height: 250px;
}

/* === Tables === */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  text-align: left;
  padding: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  letter-spacing: 0.5px;
}

.data-table tbody td {
  padding: 12px;
  border-bottom: 1px solid rgba(30, 58, 95, 0.5);
  color: var(--text-primary);
  font-size: 13px;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table-hover tbody tr {
  transition: var(--transition);
}

.data-table-hover tbody tr:hover {
  background-color: var(--bg-hover);
}

.clickable-row {
  cursor: pointer;
}

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-minor {
  background-color: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.badge-serious {
  background-color: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.badge-very-serious {
  background-color: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.badge-most-serious {
  background-color: rgba(153, 27, 27, 0.2);
  color: #fca5a5;
}

.badge-default {
  background-color: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
}

.badge-pending {
  background-color: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.badge-parsing {
  background-color: rgba(6, 182, 212, 0.15);
  color: #06b6d4;
}

.badge-completed {
  background-color: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.badge-failed {
  background-color: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.activity-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: white;
}

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  margin-top: 16px;
}

.pagination-info {
  font-size: 13px;
  color: var(--text-secondary);
}

/* === Toolbar === */
.toolbar {
  margin-bottom: 16px;
}

.search-wrapper {
  position: relative;
  max-width: 360px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 10px 12px 10px 40px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-family);
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* === Filters === */
.filters-card {
  padding: 16px 24px;
}

.filters-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.filter-group .form-input,
.filter-group .form-select {
  padding-left: 12px;
}

/* === Tabs === */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-family);
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

/* === Driver/Vehicle Info Grid === */
.driver-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

/* === Upload / Drop Zone === */
.upload-card {
  margin-bottom: 20px;
}

.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.drop-zone:hover,
.drop-zone-active {
  border-color: var(--accent-primary);
  background-color: rgba(59, 130, 246, 0.05);
}

.drop-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.drop-text {
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.drop-hint {
  font-size: 13px;
  color: var(--text-muted);
}

.file-input-hidden {
  display: none;
}

.upload-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px;
  background-color: rgba(59, 130, 246, 0.1);
  border-radius: var(--border-radius);
  color: var(--accent-primary);
}

.upload-error {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px;
  background-color: rgba(239, 68, 68, 0.1);
  border-radius: var(--border-radius);
  color: var(--accent-danger);
}

.upload-success {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px;
  background-color: rgba(16, 185, 129, 0.1);
  border-radius: var(--border-radius);
  color: var(--accent-success);
}

.success-icon {
  width: 16px;
  height: 16px;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

.modal-body {
  padding: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-full {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-value {
  font-size: 14px;
  color: var(--text-primary);
}

.highlight-bad {
  color: var(--accent-danger);
  font-weight: 600;
}

.highlight-good {
  color: var(--accent-success);
  font-weight: 600;
}

/* === Timeline === */
.timeline-legend {
  padding: 12px 24px;
}

.legend-items {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.timeline-container {
  position: relative;
  padding: 40px 0 20px;
  margin-bottom: 24px;
}

.time-axis {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  height: 20px;
}

.time-label {
  position: absolute;
  font-size: 10px;
  color: var(--text-muted);
  transform: translateX(-50%);
}

.timeline-track {
  position: relative;
  height: 40px;
  background-color: var(--bg-primary);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.timeline-block {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 3px;
  opacity: 0.9;
  transition: opacity 0.2s;
}

.timeline-block:hover {
  opacity: 1;
}

.timeline-grid {
  position: absolute;
  top: 30px;
  left: 0;
  right: 0;
  bottom: 20px;
  pointer-events: none;
}

.grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background-color: rgba(148, 163, 184, 0.1);
}

.activities-table-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* === States === */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-secondary);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  text-align: center;
}

.empty-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(26, 26, 46, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 500;
  color: var(--text-secondary);
}

/* === Spinner === */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-large {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* === View Titles === */
.view-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
}

/* === Responsive === */
@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: 200px;
  }

  .main-content {
    padding: 16px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .filters-grid {
    flex-direction: column;
  }

  .filter-group {
    min-width: 100%;
  }

  .driver-info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .sidebar {
    width: 60px;
  }

  .nav-label,
  .logo-text {
    display: none;
  }

  .main-content {
    margin-left: 60px;
  }

  .sidebar-logo {
    justify-content: center;
  }

  .nav-item {
    justify-content: center;
    padding: 12px;
  }
}

/* === DB Status Bar === */
.db-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--border-radius);
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
}

.db-status-bar i {
  width: 18px;
  height: 18px;
}

.db-connected {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.db-disconnected {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

