/* Variables de color */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #0ea5e9;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --tag-bg: #dbeafe;
  --tag-text: #1e40af;
  --toast-success: #10b981;
}

body.dark {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --secondary: #10b981;
  --danger: #ef4444;
  --info: #0ea5e9;
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f1f5f9;
  --text-light: #94a3b8;
  --border: #334155;
  --tag-bg: #1e3a8a;
  --tag-text: #93c5fd;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.3s ease, color 0.3s ease;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
  gap: 15px;
}

.header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-size: 18px;
}

.icon-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

/* Cards */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: background 0.3s ease;
}

/* Form groups */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.label-hint {
  font-weight: normal;
  font-size: 12px;
  color: var(--text-light);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: var(--card);
  color: var(--text);
  transition: all 0.2s ease;
}

/* Input con botón para agregar tecnología */
.input-button-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-button-wrapper input {
  flex: 1;
}

.btn-add-tech {
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--secondary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 18px;
}

.btn-add-tech:hover {
  background: #0d9468;
  transform: scale(1.05);
}

.btn-add-tech:active {
  transform: scale(0.95);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Autocompletado */
.input-with-suggestions {
  position: relative;
}

.tech-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card);
  border: 2px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.tech-suggestions.active {
  display: block;
}

.suggestion-item {
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: 14px;
  color: var(--text);
}

.suggestion-item:hover {
  background: var(--tag-bg);
}

/* Tags container */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 45px;
  padding: 10px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  align-items: center;
  background: var(--bg);
}

.tags-placeholder {
  color: var(--text-light);
  font-size: 13px;
  font-style: italic;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.tag:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tag-remove {
  cursor: pointer;
  color: var(--danger);
  font-weight: bold;
  font-size: 18px;
  line-height: 1;
  transition: transform 0.2s ease;
}

.tag-remove:hover {
  transform: scale(1.3);
}

/* Checkbox */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.checkbox-group:hover {
  background: var(--border);
}

.checkbox-group input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* Preview section */
.preview-section {
  background: var(--bg);
  padding: 15px;
  border-radius: 8px;
  margin-top: 20px;
  border: 1px solid var(--border);
}

.preview-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.preview-query {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
  line-height: 1.8;
  padding: 10px;
  background: var(--card);
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* Buttons */
.btn {
  padding: 14px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-info {
  background: var(--info);
  color: white;
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-small:hover {
  transform: translateY(-1px);
  opacity: 0.9;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* History section */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 15px;
  flex-wrap: wrap;
}

.history-header h2 {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-search {
  flex: 1;
  max-width: 300px;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--card);
  color: var(--text);
  transition: all 0.2s ease;
}

.history-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.history-item {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 12px;
  transition: all 0.2s ease;
}

.history-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 10px;
  gap: 10px;
}

.history-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  flex: 1;
  transition: color 0.2s ease;
}

.history-title:hover {
  color: var(--primary);
}

.history-date {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
}

.history-query {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 12px;
  word-break: break-all;
  font-family: 'Courier New', monospace;
  background: var(--bg);
  padding: 8px;
  border-radius: 4px;
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 15px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 16px;
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--card);
  color: var(--text);
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 1000;
  animation: slideIn 0.3s ease;
  border: 2px solid var(--toast-success);
}

.toast.show {
  display: flex;
}

.toast i {
  color: var(--toast-success);
  font-size: 20px;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Footer */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--text-light);
  font-size: 14px;
}

.footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

.footer a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .header {
    flex-direction: column;
    align-items: center;
    margin-top: 15px;
  }

  .header h1 {
    font-size: 22px;
  }

  .card {
    padding: 20px;
  }

  .history-header {
    flex-direction: column;
    align-items: stretch;
  }

  .history-search {
    max-width: 100%;
  }

  .history-item-header {
    flex-direction: column;
    gap: 5px;
  }

  .history-date {
    align-self: flex-start;
  }

  .history-actions {
    justify-content: flex-start;
  }

  .toast {
    bottom: 10px;
    right: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
  }
}

/* Driver.js customization */
.driver-popover {
  background: var(--card) !important;
  color: var(--text) !important;
}

.driver-popover-title {
  color: var(--text) !important;
  font-weight: 700 !important;
}

.driver-popover-description {
  color: var(--text-light) !important;
}

.driver-popover-footer button {
  background: var(--primary) !important;
  color: white !important;
  border: none !important;
  padding: 8px 16px !important;
  border-radius: 6px !important;
  font-weight: 600 !important;
  transition: all 0.2s ease !important;
}

.driver-popover-footer button:hover {
  background: var(--primary-hover) !important;
  transform: translateY(-1px) !important;
}

.driver-popover-prev-btn,
.driver-popover-next-btn {
  text-shadow: none !important;
}

.driver-popover-close-btn {
  color: var(--text-light) !important;
}

.driver-popover-close-btn:hover {
  color: var(--danger) !important;
}