/* ─── Variables y Reset ────────────────────────────────────────────────── */
:root {
  --primary: #1a56db;
  --primary-dark: #1342a8;
  --primary-light: #e8f0fe;
  --secondary: #0e9f6e;
  --accent: #ff6b35;
  --bg: #f0f4f8;
  --card-bg: #ffffff;
  --text: #1a202c;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #e53e3e;
  --success: #38a169;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.18s ease;
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Navbar ───────────────────────────────────────────────────────────── */
.navbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.navbar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
}

.navbar-links a, .navbar-links button {
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text);
  font-family: var(--font);
}

.navbar-links a:hover, .navbar-links button:hover {
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}

.navbar-links .btn-nav-primary {
  background: var(--primary);
  color: white;
}

.navbar-links .btn-nav-primary:hover {
  background: var(--primary-dark);
  color: white;
}

/* ─── Hero / Banner ────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 60%, #0b2e86 100%);
  color: white;
  padding: 4rem 1.5rem 3rem;
  text-align: center;
}

.hero h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
}

.hero p {
  font-size: 1.1rem;
  opacity: 0.88;
  max-width: 560px;
  margin: 0 auto 2rem;
}

/* ─── Filtros de búsqueda ──────────────────────────────────────────────── */
.search-bar {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: -1.5rem auto 2rem;
  max-width: 900px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.search-bar .field {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.search-bar label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.search-bar input, .search-bar select {
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  transition: var(--transition);
  outline: none;
}

.search-bar input:focus, .search-bar select:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(26,86,219,0.12);
}

/* ─── Botones ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow); }

.btn-secondary {
  background: var(--primary-light);
  color: var(--primary);
}
.btn-secondary:hover { background: #d1e0fd; }

.btn-success {
  background: var(--secondary);
  color: white;
}
.btn-success:hover { background: #0b7a55; }

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

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.btn-full { width: 100%; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

/* ─── Contenedor principal ─────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.page-subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* ─── Grid de tarjetas de proveedores ──────────────────────────────────── */
.proveedores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.card-proveedor {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.card-proveedor:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.card-logo {
  height: 140px;
  background: linear-gradient(135deg, var(--primary-light), #dbeafe);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-logo .logo-placeholder {
  width: 72px;
  height: 72px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.8rem;
  font-weight: 700;
}

.card-body {
  padding: 1.1rem 1.25rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-body h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  color: var(--text);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  margin-bottom: 0.6rem;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-accent { background: #fff0eb; color: #c04a1b; }

.card-desc {
  font-size: 0.87rem;
  color: var(--text-muted);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

.card-footer {
  margin-top: auto;
}

/* ─── Estado vacío ─────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

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

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

/* ─── Formularios ──────────────────────────────────────────────────────── */
.form-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 2rem;
  max-width: 520px;
  margin: 2rem auto;
  box-shadow: var(--shadow);
}

.form-card h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.form-card .subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}

.form-group {
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  transition: var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(26,86,219,0.12);
}

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

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

.form-divider {
  text-align: center;
  margin: 1.2rem 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  position: relative;
}

.form-divider::before, .form-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 2rem);
  height: 1px;
  background: var(--border);
}
.form-divider::before { left: 0; }
.form-divider::after { right: 0; }

/* ─── Alertas ──────────────────────────────────────────────────────────── */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.92rem;
  display: none;
  align-items: center;
  gap: 0.5rem;
}
.alert.show { display: flex; }
.alert-error { background: #fff5f5; border: 1.5px solid #fed7d7; color: var(--danger); }
.alert-success { background: #f0fff4; border: 1.5px solid #c6f6d5; color: var(--success); }
.alert-info { background: var(--primary-light); border: 1.5px solid #bfdbfe; color: var(--primary); }

/* ─── Página de detalle ────────────────────────────────────────────────── */
.detalle-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 2.5rem 1.5rem;
}

.detalle-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.detalle-logo {
  width: 140px;
  height: 140px;
  flex-shrink: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.detalle-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detalle-logo .logo-placeholder {
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary);
}

.detalle-info h1 {
  font-size: 1.9rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
}

.detalle-info .meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-top: 0.75rem;
}

.detalle-info .meta-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.detalle-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 2rem;
}

.detalle-descripcion {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.75rem;
}

.detalle-descripcion h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}

.detalle-descripcion p {
  color: var(--text-muted);
  line-height: 1.8;
}

.contacto-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.75rem;
  height: fit-content;
  position: sticky;
  top: 80px;
}

.contacto-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

/* ─── Perfil proveedor ─────────────────────────────────────────────────── */
.perfil-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 2rem;
}

.perfil-sidebar {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.5rem;
  height: fit-content;
  text-align: center;
}

.perfil-logo-preview {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  overflow: hidden;
  font-size: 2.5rem;
  color: var(--primary);
  font-weight: 700;
}

.perfil-sidebar .upload-label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

#logo-preview-img { width: 100%; height: 100%; object-fit: cover; }

.perfil-form-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.75rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--border);
}

/* ─── Loading spinner ──────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.loading-full {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem;
}

.loading-full .spinner {
  border-color: var(--border);
  border-top-color: var(--primary);
  width: 36px;
  height: 36px;
}

/* ─── Resultados count ─────────────────────────────────────────────────── */
.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.results-count {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ─── Footer ───────────────────────────────────────────────────────────── */
.footer {
  background: var(--text);
  color: rgba(255,255,255,0.7);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.85rem;
  margin-top: 4rem;
}

.footer a { color: rgba(255,255,255,0.85); }

/* ─── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .search-bar { flex-direction: column; margin: -1rem 1rem 1.5rem; }
  .search-bar .field { min-width: unset; width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .detalle-header-inner { flex-direction: column; }
  .detalle-logo { width: 100px; height: 100px; }
  .detalle-content { grid-template-columns: 1fr; }
  .contacto-card { position: static; }
  .perfil-layout { grid-template-columns: 1fr; }
  .perfil-sidebar { text-align: left; display: flex; align-items: center; gap: 1.5rem; }
  .perfil-logo-preview { width: 90px; height: 90px; flex-shrink: 0; }
  .navbar-links .hide-mobile { display: none; }
}

@media (max-width: 480px) {
  .hero { padding: 2.5rem 1rem 2rem; }
  .form-card { margin: 1rem; padding: 1.5rem; }
}
