/* ── Klozter Curve Extractor — Tema claro ───────────────── */
/* Fondo blanco · texto negro · sidebar navy · acento teal  */
/* Poppins font                                              */

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

:root {
  --navy:      #003D5B;
  --navy-lt:   #004d73;
  --teal:      #006A81;
  --teal-lt:   #0a7d96;
  --black:     #0D0D0D;
  --gray-dk:   #4A4A4A;
  --gray:      #787878;
  --gray-lt:   #B0B0B0;
  --border:    #E2E8ED;
  --border-dk: #CDD5DC;
  --surface:   #F5F7F9;
  --surface-2: #EEF2F5;
  --white:     #FFFFFF;
  --danger:    #D94040;
  --danger-lt: #FDF0F0;
  --success:   #1A9E6E;
  --success-lt:#F0FAF6;
  --warning:   #C47A00;
  --sidebar-w: 210px;
  --radius:    8px;
  --radius-lg: 12px;
  font-family: 'Poppins', sans-serif;
}

body {
  background: var(--surface);
  color: var(--black);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

/* ── Screens ─────────────────────────────────────────────── */
.screen { position: fixed; inset: 0; }
.screen.hidden { display: none; }
.screen.active { display: flex; flex-direction: column; }
#screen-app.active { flex-direction: row; }

/* ── LOGIN ───────────────────────────────────────────────── */
#screen-login {
  align-items: center;
  justify-content: center;
  background: var(--surface);
}

.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px rgba(0,61,91,0.08);
  padding: 40px;
  width: 380px;
}

.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 6px;
}
.isologo { width: 34px; height: 34px; }
.brand-name {
  font-size: 22px; font-weight: 600; letter-spacing: -0.3px;
  color: var(--navy);
}
.login-subtitle {
  color: var(--gray); font-size: 13px; margin-bottom: 28px;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }

/* ── Fields & Inputs ─────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12px; font-weight: 500;
  color: var(--gray-dk); text-transform: uppercase; letter-spacing: 0.06em;
}
.input, input[type="email"], input[type="password"],
input[type="text"], input[type="number"], .select {
  background: var(--white);
  border: 1px solid var(--border-dk);
  border-radius: var(--radius);
  color: var(--black);
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.input:focus, input:focus, .select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,106,129,0.1);
}
.input::placeholder, input::placeholder { color: var(--gray-lt); }
.select { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23787878' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  background: var(--teal);
  border: none; border-radius: var(--radius);
  color: var(--white); cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-size: 14px; font-weight: 500;
  padding: 11px 20px;
  transition: background 0.15s, transform 0.1s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
}
.btn-primary:hover { background: var(--teal-lt); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--white);
  border: 1px solid var(--border-dk);
  border-radius: var(--radius);
  color: var(--gray-dk); cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-size: 13px; font-weight: 400;
  padding: 9px 18px;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover { border-color: var(--teal); color: var(--teal); }

.btn-icon {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--gray); cursor: pointer;
  font-size: 14px; padding: 5px 9px;
  transition: border-color 0.15s, color 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { border-color: var(--border-dk); color: var(--black); }
.btn-icon:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-upload {
  background: transparent;
  border: 1px solid var(--teal);
  border-radius: var(--radius);
  color: var(--teal); cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-size: 13px; padding: 7px 16px;
  transition: background 0.15s, color 0.15s;
}
.btn-upload:hover { background: var(--teal); color: var(--white); }

.btn-logout {
  background: transparent; border: none;
  color: rgba(255,255,255,0.5); cursor: pointer;
  padding: 6px; border-radius: 6px;
  transition: color 0.15s;
  display: flex; align-items: center;
}
.btn-logout:hover { color: #ffaaaa; }

/* ── Messages ────────────────────────────────────────────── */
.error-msg {
  background: var(--danger-lt);
  border: 1px solid rgba(217,64,64,0.25);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 13px; padding: 10px 14px;
}
.hidden { display: none !important; }

/* ── APP LAYOUT ──────────────────────────────────────────── */
#screen-app { display: flex; flex-direction: row; height: 100vh; overflow: hidden; }

/* ── Sidebar (se mantiene oscuro — ancla de marca) ───────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 20px 0;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex; justify-content: center;
  padding: 0 20px 24px;
}
.isologo-sm { width: 42px; height: 42px; }

.sidebar-nav {
  display: flex; flex-direction: column; gap: 2px;
  padding: 0 10px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: none;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-size: 13px; font-weight: 400;
  padding: 9px 12px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  width: 100%;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.nav-item.active {
  background: rgba(0,106,129,0.3);
  color: var(--white);
  border-left: 2px solid var(--teal);
}

.sidebar-bottom { padding: 0 10px; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 8px;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--teal);
  color: var(--white); font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; color: var(--white); }
.user-role { font-size: 11px; color: rgba(255,255,255,0.45); text-transform: capitalize; }

/* ── Main content ────────────────────────────────────────── */
.main-content {
  flex: 1; overflow-y: auto;
  background: var(--surface);
  display: flex; flex-direction: column;
}

.view { display: none; flex: 1; flex-direction: column; }
.view.active { display: flex; }

.view-header {
  padding: 24px 28px 18px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.view-title { font-size: 18px; font-weight: 500; color: var(--black); }
.view-subtitle { font-size: 13px; color: var(--gray); margin-top: 3px; }

/* ── Extractor layout ────────────────────────────────────── */
.extractor-layout {
  display: flex; flex: 1; overflow: hidden; min-height: 0;
}

/* Panel de controles */
.panel-controls {
  width: 300px; flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}

.step-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: opacity 0.2s;
}
.step-card.disabled { opacity: 0.4; pointer-events: none; }

.step-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.step-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--teal);
  color: var(--white); font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.step-label { font-size: 13px; font-weight: 500; color: var(--black); }
.step-help { font-size: 12px; color: var(--gray); margin-bottom: 12px; }

/* Upload zone */
.upload-zone {
  border: 1.5px dashed var(--border-dk);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  color: var(--gray); font-size: 13px;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
  text-align: center;
}
.upload-zone:hover { border-color: var(--teal); background: rgba(0,106,129,0.03); }
.upload-zone.drag-over {
  border-color: var(--teal);
  background: rgba(0,106,129,0.05);
}

.file-info {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px; color: var(--black);
  margin-top: 8px;
}
#file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Axis grid */
.axis-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-bottom: 10px;
}

/* Instruction box */
.instruction-box {
  display: flex; align-items: flex-start; gap: 8px;
  background: rgba(0,106,129,0.06);
  border: 1px solid rgba(0,106,129,0.2);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 12px;
}
.instruction-icon { color: var(--teal); flex-shrink: 0; margin-top: 1px; }
#instruction-text { font-size: 12px; color: var(--gray-dk); line-height: 1.5; }

/* Points table */
.points-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px; margin-bottom: 14px;
}
.points-table th {
  text-align: left; font-weight: 500;
  color: var(--gray); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.points-table td {
  padding: 7px 8px;
  color: var(--black);
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.points-table tr:last-child td { border-bottom: none; }

.result-actions { display: flex; gap: 8px; }
.result-actions .btn-primary,
.result-actions .btn-secondary { width: auto; flex: 1; }

/* ── Panel visor ─────────────────────────────────────────── */
.panel-viewer {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

.viewer-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
}
.page-nav { display: flex; align-items: center; gap: 8px; }
#page-indicator { font-size: 13px; color: var(--gray); min-width: 60px; text-align: center; }
.viewer-actions { display: flex; align-items: center; gap: 6px; }
#zoom-level { font-size: 12px; color: var(--gray); min-width: 40px; text-align: right; }

.viewer-canvas-wrap {
  flex: 1; overflow: auto;
  position: relative;
  background: var(--surface-2);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 16px;
}

.viewer-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; color: var(--gray-lt);
  font-size: 14px;
  height: 100%; width: 100%;
}
.viewer-empty svg { opacity: 0.3; }

.viewer-canvas {
  position: relative; display: inline-block;
  cursor: crosshair;
  box-shadow: 0 2px 16px rgba(0,61,91,0.12);
  border-radius: 4px; overflow: hidden;
}
#pdf-canvas { display: block; }

.overlay-svg {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.overlay-svg.accepting-clicks { pointer-events: all; }

/* Rectángulo de área de ploteo */
.plot-rect {
  fill: rgba(0,106,129,0.05);
  stroke: var(--teal);
  stroke-width: 1.5;
  stroke-dasharray: 6 3;
}

/* Marcadores de clic */
.click-marker { fill: none; stroke: #E8A000; stroke-width: 2; }
.click-marker-dot { fill: #E8A000; }

/* Puntos resultado */
.result-pt { fill: var(--teal); stroke: var(--white); stroke-width: 1.5; }
.result-label { fill: var(--black); font-family: 'Poppins', sans-serif; font-size: 11px; font-weight: 500; }

/* Click status bar */
.click-status {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: rgba(0,106,129,0.06);
  border-top: 1px solid rgba(0,106,129,0.15);
  font-size: 13px; color: var(--gray-dk);
  flex-shrink: 0;
}
.click-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--teal);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

/* ── Placeholder views ───────────────────────────────────── */
.placeholder-view {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; color: var(--gray-lt);
}
.placeholder-view svg { opacity: 0.2; }
.placeholder-view p { font-size: 14px; }

/* ── Spinner ─────────────────────────────────────────────── */
.btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dk); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-lt); }
