/* ============================================
   Directorio de Artesanos - Design System
   ============================================ */

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

:root {
  --bg-primary: #0b1121;
  --bg-secondary: #111827;
  --bg-tertiary: #1e293b;
  --surface: rgba(17, 24, 39, 0.85);
  --surface-hover: rgba(30, 41, 59, 0.9);
  --surface-border: rgba(148, 163, 184, 0.08);

  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --accent-dark: #d97706;
  --accent-subtle: rgba(245, 158, 11, 0.1);
  --accent-glow: 0 0 20px rgba(245, 158, 11, 0.15);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border: rgba(148, 163, 184, 0.1);
  --border-accent: rgba(245, 158, 11, 0.25);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);

  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 16px 64px rgba(0, 0, 0, 0.45);

  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Login Screen ===== */
.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.login-container {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header h2 {
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.login-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.login-footer a {
  color: var(--accent);
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

.admin-only {
  display: none !important;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Subtle background gradient */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(245, 158, 11, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(139, 92, 246, 0.02) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ===== Header ===== */
header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(11, 17, 33, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
}

.header-content {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  background: var(--accent-subtle);
  border-radius: var(--radius);
  border: 1px solid var(--border-accent);
}

.logo-area h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-area p {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  font-size: 0.84rem;
  font-weight: 500;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #000;
  font-weight: 600;
  box-shadow: var(--accent-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  transform: translateY(-1px);
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.25);
}

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

.btn-secondary:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem;
}

.btn-ghost:hover {
  background: var(--surface);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.76rem;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

/* ===== Search Section ===== */
.search-section {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.search-bar {
  flex: 1;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.search-input-wrapper {
  flex: 1;
  position: relative;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.95rem;
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 0.7rem 1rem 0.7rem 2.75rem;
  font-size: 0.88rem;
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  transition: var(--transition);
  backdrop-filter: blur(10px);
}

#search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

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

#filter-linea {
  padding: 0.7rem 2.25rem 0.7rem 1rem;
  font-size: 0.84rem;
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  min-width: 200px;
}

#filter-linea:focus {
  outline: none;
  border-color: var(--accent);
}

#filter-linea option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.stats-badge {
  padding: 0.5rem 1rem;
  background: var(--accent-subtle);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-light);
  white-space: nowrap;
}

/* ===== Main Layout ===== */
main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 1.5rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 1.25rem;
  height: calc(100vh - 130px);
  position: relative;
  z-index: 1;
}

/* ===== Map ===== */
#map-container {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  box-shadow: var(--shadow);
}

#map {
  width: 100%;
  height: 100%;
  min-height: 400px;
  background: var(--bg-secondary);
}

.map-mode-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--accent);
  color: #000;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: none;
  align-items: center;
  gap: 0.5rem;
  animation: pulse-glow 2s ease-in-out infinite;
}

.map-mode-banner.active {
  display: flex;
}

@keyframes pulse-glow {

  0%,
  100% {
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
  }

  50% {
    box-shadow: 0 0 25px rgba(245, 158, 11, 0.5);
  }
}

/* ===== Panel ===== */
#panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}

.panel-header {
  padding: 0 0 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h2 {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

#artisan-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-right: 4px;
}

/* ===== Artisan Cards ===== */
.artisan-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1rem;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.artisan-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  border-radius: 4px 0 0 4px;
}

.artisan-card:hover {
  border-color: var(--border-accent);
  transform: translateX(-2px);
  box-shadow: var(--shadow);
}

.artisan-card.highlighted {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.15);
}

.artisan-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.artisan-card-info h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.1rem;
}

.artisan-card-info .dni {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  letter-spacing: 0.03em;
}

.artisan-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.18rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 100px;
  border: 1px solid;
  white-space: nowrap;
}

.artisan-card-notes {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.5rem;
  padding: 0.35rem 0.55rem;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-xs);
  border-left: 2px solid var(--text-muted);
  line-height: 1.4;
}

.artisan-card-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
}

/* ===== Empty State ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  height: 100%;
}

.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.84rem;
  color: var(--text-muted);
  max-width: 260px;
  line-height: 1.5;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  padding: 1.5rem;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95) translateY(10px);
  transition: var(--transition);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

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

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ===== Form ===== */
.form-group {
  margin-bottom: 1.1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group label .required {
  color: var(--accent);
  margin-left: 0.1rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-size: 0.88rem;
  font-family: inherit;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

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

.form-group textarea {
  resize: vertical;
  min-height: 65px;
}

.form-group select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.form-group select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-hint {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.form-group-custom-linea {
  margin-top: 0.5rem;
  display: none;
}

.form-group-custom-linea.visible {
  display: block;
}

/* Coordinate Status */
.coord-status {
  font-size: 0.76rem;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-xs);
  margin-top: 0.35rem;
  display: none;
  align-items: center;
  gap: 0.35rem;
}

.coord-status.success {
  display: flex;
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.coord-status.error {
  display: flex;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.coord-status.info {
  display: flex;
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease-out, fadeOut 0.3s ease-in 2.7s forwards;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toast.success {
  background: var(--success);
  color: white;
}

.toast.error {
  background: var(--danger);
  color: white;
}

.toast.info {
  background: #3b82f6;
  color: white;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ===== Confirm Dialog ===== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.confirm-overlay.active {
  opacity: 1;
  visibility: visible;
}

.confirm-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  max-width: 380px;
  box-shadow: var(--shadow-xl);
}

.confirm-dialog h3 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.confirm-dialog p {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.confirm-dialog-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

/* ===== Leaflet Overrides ===== */
.leaflet-popup-content-wrapper {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-lg) !important;
  color: var(--text-primary) !important;
}

.leaflet-popup-tip {
  background: var(--bg-secondary) !important;
}

.leaflet-popup-content {
  margin: 0.75rem 1rem !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 0.84rem !important;
  line-height: 1.5 !important;
}

.leaflet-popup-close-button {
  color: var(--text-muted) !important;
  font-size: 1.2rem !important;
}

.leaflet-popup-close-button:hover {
  color: var(--text-primary) !important;
}

.popup-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
}

.popup-detail {
  color: var(--text-secondary);
  font-size: 0.78rem;
  margin-bottom: 0.15rem;
}

.popup-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

/* Leaflet controls dark theme */
.leaflet-control-zoom a {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-tertiary) !important;
}

.leaflet-control-attribution {
  background: rgba(11, 17, 33, 0.7) !important;
  color: var(--text-muted) !important;
  font-size: 0.65rem !important;
}

.leaflet-control-attribution a {
  color: var(--text-secondary) !important;
}

/* ===== Hidden File Input ===== */
#import-file {
  display: none;
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.artisan-card {
  animation: fadeInUp 0.3s ease-out both;
}

.artisan-card:nth-child(1) {
  animation-delay: 0.02s;
}

.artisan-card:nth-child(2) {
  animation-delay: 0.05s;
}

.artisan-card:nth-child(3) {
  animation-delay: 0.08s;
}

.artisan-card:nth-child(4) {
  animation-delay: 0.11s;
}

.artisan-card:nth-child(5) {
  animation-delay: 0.14s;
}

.artisan-card:nth-child(6) {
  animation-delay: 0.17s;
}

.artisan-card:nth-child(7) {
  animation-delay: 0.20s;
}

.artisan-card:nth-child(8) {
  animation-delay: 0.23s;
}

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

  #map-container {
    height: 50vh;
  }

  #panel {
    max-height: 50vh;
  }
}

@media (max-width: 768px) {
  header {
    padding: 0.6rem 1rem;
  }

  .header-content {
    flex-wrap: wrap;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .search-section {
    flex-direction: column;
    padding: 0.75rem 1rem;
    align-items: stretch;
  }

  .search-bar {
    flex-direction: column;
  }

  #filter-linea {
    min-width: unset;
    width: 100%;
  }

  main {
    padding: 0 1rem 1rem;
  }

  #map-container {
    height: 45vh;
  }

  .modal {
    max-width: 100%;
    max-height: 95vh;
    border-radius: var(--radius-lg);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .stats-badge {
    width: 100%;
    text-align: center;
  }
}