/* =========================================================
   Sistema de Proveedores — Leche Mukki
   Paleta: naranja de marca #EB671B, crema #FFF8F2, tinta #2B2622
   ========================================================= */

:root {
  --mukki-orange: #EB671B;
  --mukki-orange-dark: #C74F0E;
  --mukki-orange-light: #FDECE0;
  --cream: #FFF8F2;
  --ink: #2B2622;
  --ink-soft: #6B615A;
  --line: #EDE1D6;
  --white: #FFFFFF;
  --ok: #2E7D4F;
  --ok-bg: #E7F5EC;
  --warn: #B5541A;
  --warn-bg: #FBEADD;
  --danger: #C13A2E;
  --danger-bg: #FBE8E5;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(43, 38, 34, 0.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

img { max-width: 100%; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 15%, var(--mukki-orange-light) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, var(--mukki-orange-light) 0%, transparent 45%),
    var(--cream);
  padding: 20px;
}
.login-wrap { width: 100%; display: flex; justify-content: center; }
.login-card {
  background: var(--white);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  border: 1px solid var(--line);
}
.login-logo { width: 190px; margin-bottom: 22px; }
.login-title { font-size: 20px; margin: 0 0 22px; color: var(--ink); font-weight: 700; }
.login-sub { color: var(--ink-soft); font-size: 14px; margin-top: -14px; margin-bottom: 22px; }

.field { text-align: left; margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-family: var(--font);
  background: var(--white);
  color: var(--ink);
  transition: border-color .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--mukki-orange);
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--mukki-orange); color: var(--white); }
.btn-primary:hover { background: var(--mukki-orange-dark); }
.btn-secondary { background: var(--white); color: var(--ink); border: 1.5px solid var(--line); }
.btn-secondary:hover { border-color: var(--mukki-orange); color: var(--mukki-orange); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--white); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.alert { padding: 14px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; text-align: left; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-info { background: var(--mukki-orange-light); color: var(--mukki-orange-dark); }

.cred-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.cred-table th, .cred-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.cred-table code { background: var(--white); padding: 3px 7px; border-radius: 6px; border: 1px solid var(--line); }

/* ---------- App shell ---------- */
.app-header {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header .brand { display: flex; align-items: center; gap: 10px; }
.app-header .brand img { height: 34px; }
.app-header .who { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.who .badge {
  background: var(--mukki-orange-light);
  color: var(--mukki-orange-dark);
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.app-main { max-width: 1160px; margin: 0 auto; padding: 24px 20px 60px; }

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-title h1 { font-size: 22px; margin: 0; }
.page-title .count { color: var(--ink-soft); font-size: 14px; }

/* ---------- Search bar ---------- */
.search-bar {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.search-bar input[type=text] {
  flex: 1;
  min-width: 220px;
  border: none;
  font-size: 15.5px;
  padding: 8px 4px;
  font-family: var(--font);
  color: var(--ink);
}
.search-bar input[type=text]:focus { outline: none; }
.search-bar .icon { color: var(--mukki-orange); font-size: 18px; }
.search-bar select {
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--ink-soft);
  background: var(--white);
}

/* ---------- Provider cards ---------- */
.prov-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.prov-card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.prov-card:hover { transform: translateY(-2px); border-color: var(--mukki-orange); }
.prov-card .name { font-weight: 700; font-size: 16px; color: var(--ink); }
.prov-card .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--mukki-orange-light);
  color: var(--mukki-orange-dark);
  text-transform: uppercase;
  letter-spacing: .02em;
}
.tag.country { background: #EEF1FB; color: #3A4DA6; }
.prov-card .meta { font-size: 13px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.prov-card .meta span { display: flex; gap: 6px; align-items: baseline; min-width: 0; overflow-wrap: anywhere; }
.prov-card .meta .lbl { color: #B2A79C; min-width: 16px; }
.prov-card .materials-preview { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; line-height: 1.4; overflow-wrap: anywhere; }
.prov-card { min-width: 0; }
.prov-card .name { overflow-wrap: anywhere; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
}
.empty-state .isotipo { width: 80px; opacity: .35; margin-bottom: 14px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(43, 38, 34, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 30px 16px;
  z-index: 100;
  overflow-y: auto;
}
.modal {
  background: var(--white);
  border-radius: 18px;
  width: 100%;
  max-width: 720px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: modalIn .15s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; gap: 10px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--ink-soft); cursor: pointer; line-height: 1; padding: 4px; }
.modal-close:hover { color: var(--mukki-orange); }

.detail-section { margin-bottom: 18px; }
.detail-section h3 {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--mukki-orange-dark); margin: 0 0 10px; font-weight: 800;
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.item { font-size: 14px; }
.item .lbl { color: var(--ink-soft); font-size: 12px; display: block; margin-bottom: 2px; }

.mat-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.mat-table th { text-align: left; padding: 8px 10px; color: var(--ink-soft); font-size: 11.5px; text-transform: uppercase; border-bottom: 2px solid var(--line); }
.mat-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.risk { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.risk-alto { background: var(--danger-bg); color: var(--danger); }
.risk-medio { background: var(--warn-bg); color: var(--warn); }
.risk-bajo { background: var(--ok-bg); color: var(--ok); }

.check-row { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 6px; }
.check-pill { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.check-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: inline-block; }
.check-pill.on .dot { background: var(--ok); }
.check-pill.on { color: var(--ink); font-weight: 600; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ---------- Materials editor (form) ---------- */
.mat-editor-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.mat-editor-row input, .mat-editor-row select { margin: 0; }
.mat-remove-btn {
  background: var(--danger-bg); color: var(--danger); border: none;
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 16px;
}
.add-mat-btn { margin-top: 4px; }

.fab {
  position: fixed; bottom: 26px; right: 26px;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--mukki-orange); color: var(--white);
  font-size: 28px; border: none; box-shadow: 0 8px 24px rgba(235,103,27,.4);
  cursor: pointer; z-index: 40;
  display: flex; align-items: center; justify-content: center;
}
.fab:hover { background: var(--mukki-orange-dark); }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--white); padding: 12px 22px;
  border-radius: 10px; font-size: 14px; z-index: 200; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, bottom .2s ease;
}
.toast.show { opacity: 1; bottom: 40px; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .app-header { padding: 10px 14px; }
  .app-header .brand img { height: 26px; }
  .who span.name-txt { display: none; }
  .app-main { padding: 16px 12px 80px; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal { padding: 20px; border-radius: 14px; }
  .mat-editor-row { grid-template-columns: 1fr 1fr; }
  .mat-editor-row select { grid-column: span 1; }
  .mat-remove-btn { grid-column: span 2; width: 100%; }
  .prov-grid { grid-template-columns: 1fr; }
  .fab { bottom: 18px; right: 18px; width: 52px; height: 52px; font-size: 24px; }
}
