/* ============================================================
   PARTES-CLOUD v3 — White / Orange / Black
   Clean, breathable, professional
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  /* ─── CORE PALETTE ─────────────────────────── */
  --white:       #FFFFFF;
  --off-white:   #F7F8FA;
  --light-gray:  #EEF0F4;
  --mid-gray:    #D1D5DE;
  --text:        #1A1D26;
  --text-soft:   #5A6070;
  --text-dim:    #8C92A0;

  --orange:      #E8862D;
  --orange-dark: #CF7424;
  --orange-light:#FFF4EB;
  --orange-glow: rgba(232,134,45,0.10);

  --black:       #1A1D26;
  --dark:        #24272F;
  --sidebar-bg:  #1A1D26;

  --success:     #1DB469;
  --success-bg:  #EDFBF3;
  --danger:      #DC3B3B;
  --danger-bg:   #FDF0F0;
  --info:        #3B7FDC;
  --info-bg:     #EDF3FD;
  --purple:      #8B5CF6;

  /* ─── STRUCTURE ────────────────────────────── */
  --radius:      8px;
  --radius-lg:   12px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.06);
  --shadow:      0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg:   0 4px 20px rgba(0,0,0,0.10);
  --font:        'Inter', -apple-system, sans-serif;
  --font-mono:   'JetBrains Mono', monospace;
  --transition:  all 0.15s ease;
  --sidebar-w:   230px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14.5px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--off-white); color: var(--text); line-height: 1.6; min-height: 100vh; -webkit-font-smoothing: antialiased; }

/* ═══════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════ */
.app-layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ═══════════════════════════════════════════════
   SIDEBAR — dark contrast
   ═══════════════════════════════════════════════ */
.sidebar {
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto; z-index: 50;
}

.sidebar-header {
  padding: 1.4rem 1.2rem;
  display: flex; align-items: center; gap: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-logo {
  width: 40px; height: 40px; border-radius: 10px;
  overflow: hidden; background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-logo .initials { font-weight: 700; font-size: 0.8rem; color: var(--orange); letter-spacing: 1px; }
.sidebar-info h2 { font-size: 0.88rem; font-weight: 700; color: #fff; line-height: 1.2; text-transform: uppercase; letter-spacing: 0.3px; }
.sidebar-info .sub { font-size: 0.7rem; color: rgba(255,255,255,0.45); }

.sidebar-section-label {
  padding: 1.5rem 1.2rem 0.5rem;
  font-size: 0.6rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: rgba(255,255,255,0.3);
}

.sidebar-nav { flex: 1; padding: 0.25rem 0; }

.nav-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.55rem 1.2rem; margin: 2px 0.6rem;
  border-radius: var(--radius); color: rgba(255,255,255,0.55);
  text-decoration: none; font-size: 0.84rem; font-weight: 500;
  transition: var(--transition);
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.5; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.85); }
.nav-item:hover svg { opacity: 0.8; }
.nav-item.active { background: var(--orange); color: #fff; font-weight: 600; }
.nav-item.active svg { opacity: 1; stroke: #fff; }

.sidebar-footer {
  padding: 1rem 1.2rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; gap: 0.6rem;
}
.sidebar-footer .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,0.08); display: flex;
  align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.65rem; color: var(--orange); flex-shrink: 0;
}
.sidebar-footer .user-info { flex: 1; min-width: 0; }
.sidebar-footer .user-name { font-size: 0.78rem; font-weight: 600; color: rgba(255,255,255,0.8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .logout-btn { color: rgba(255,255,255,0.35); text-decoration: none; font-size: 0.7rem; display: flex; align-items: center; gap: 0.3rem; transition: var(--transition); }
.sidebar-footer .logout-btn:hover { color: var(--danger); }

/* ═══════════════════════════════════════════════
   MAIN CONTENT — light & clean
   ═══════════════════════════════════════════════ */
.main-content { padding: 2rem 2.5rem; max-width: 1300px; overflow-x: hidden; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.75rem; }
.topbar h2 { font-size: 1.3rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 0.5rem; }
.topbar-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ═══════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════ */
.badge { display: inline-flex; align-items: center; padding: 0.2rem 0.55rem; border-radius: 5px; font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.badge-user, .badge-operario { background: var(--info-bg); color: var(--info); }
.badge-admin { background: var(--orange-light); color: var(--orange); }
.badge-superadmin { background: var(--danger-bg); color: var(--danger); }
.badge-enviado { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--danger-bg); color: var(--danger); }
.badge-borrador { background: var(--info-bg); color: var(--info); }

/* ═══════════════════════════════════════════════
   CARDS — white, subtle shadow
   ═══════════════════════════════════════════════ */
.card {
  background: var(--white); border: 1px solid var(--light-gray);
  border-radius: var(--radius-lg); overflow: hidden;
  margin-bottom: 1.25rem; box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-inner { padding: 1.25rem 1.5rem; }
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--light-gray);
  background: var(--white);
}
.card-title { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

/* ═══════════════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════════════ */
.stat-card {
  background: var(--white); border: 1px solid var(--light-gray);
  border-radius: var(--radius-lg); padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-sm); transition: var(--transition);
}
.stat-card:hover { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-glow); }
.stat-label { font-size: 0.68rem; color: var(--text-dim); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.25rem; }
.stat-number { font-size: 2rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub { font-size: 0.68rem; color: var(--text-dim); margin-top: 0.2rem; }
.stat-sub .up { color: var(--success); }

/* ═══════════════════════════════════════════════
   SECTION BARS — orange header strips
   ═══════════════════════════════════════════════ */
.section-bar {
  background: var(--black); color: var(--orange);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0.6rem 1.1rem; font-size: 0.78rem; font-weight: 700;
  display: flex; align-items: center; gap: 0.5rem; letter-spacing: 0.3px;
}
.section-body {
  border: 1px solid var(--light-gray); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1.1rem 1.25rem; background: var(--white);
  margin-bottom: 1.25rem;
}

/* ═══════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════ */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block; font-size: 0.68rem; font-weight: 600;
  color: var(--text-soft); text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 0.35rem;
}
.form-control {
  width: 100%; padding: 0.6rem 0.85rem;
  background: var(--white); border: 1px solid var(--mid-gray);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--font); font-size: 0.88rem;
  transition: var(--transition); outline: none;
}
.form-control:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-glow); }
.form-control::placeholder { color: var(--text-dim); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238C92A0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.85rem center; padding-right: 2.5rem;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.form-row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 0.85rem; }

/* ═══════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: var(--radius);
  font-family: var(--font); font-size: 0.82rem; font-weight: 600;
  border: none; cursor: pointer; transition: var(--transition);
  text-decoration: none; line-height: 1.4;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(232,134,45,0.25); }
.btn-secondary { background: var(--white); color: var(--text); border: 1px solid var(--mid-gray); }
.btn-secondary:hover { border-color: var(--text-soft); background: var(--off-white); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #C43030; }
.btn-ghost { background: transparent; color: var(--text-dim); padding: 0.35rem 0.5rem; }
.btn-ghost:hover { color: var(--orange); background: var(--orange-light); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.72rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { width: 30px; height: 30px; padding: 0; justify-content: center; border-radius: 7px; }

/* ═══════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 0.6rem 1rem;
  font-size: 0.65rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-dim); background: var(--off-white);
  border-bottom: 1px solid var(--light-gray);
}
td { padding: 0.65rem 1rem; border-bottom: 1px solid var(--light-gray); font-size: 0.85rem; color: var(--text); }
tr:hover td { background: var(--off-white); }
tr:last-child td { border-bottom: none; }

/* Dynamic tables */
.dynamic-table { width: 100%; border-collapse: collapse; }
.dynamic-table th { text-align: left; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--light-gray); }
.dynamic-table td { padding: 0.3rem 0.2rem; }
.dynamic-table input {
  width: 100%; background: var(--off-white); border: 1px solid var(--mid-gray);
  border-radius: 6px; padding: 0.5rem 0.65rem; color: var(--text);
  font-family: var(--font); font-size: 0.85rem; outline: none; transition: var(--transition);
}
.dynamic-table input:focus { border-color: var(--orange); background: var(--white); }
.add-row-btn {
  background: transparent; border: 1px dashed var(--mid-gray);
  border-radius: 7px; color: var(--orange); padding: 0.4rem 0.85rem;
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  margin-top: 0.5rem; transition: var(--transition); font-family: var(--font);
}
.add-row-btn:hover { border-color: var(--orange); background: var(--orange-light); }
.total-row { text-align: right; padding: 0.6rem 0.5rem; font-weight: 700; font-size: 0.88rem; color: var(--text-soft); }
.total-number { color: var(--orange); font-family: var(--font-mono); font-size: 1.1rem; font-weight: 700; }

/* ═══════════════════════════════════════════════
   SIGNATURE PADS
   ═══════════════════════════════════════════════ */
.sig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.sig-box { background: var(--off-white); border: 1px solid var(--light-gray); border-radius: var(--radius); overflow: hidden; }
.sig-box-header { display: flex; justify-content: space-between; align-items: center; padding: 0.45rem 0.75rem; border-bottom: 1px solid var(--light-gray); background: var(--white); }
.sig-box-header label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text); }
.signature-pad { display: block; width: 100%; cursor: crosshair; touch-action: none; background: var(--white); }

/* ═══════════════════════════════════════════════
   PROGRESS BARS
   ═══════════════════════════════════════════════ */
.progress-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.45rem 0; }
.progress-label { font-size: 0.82rem; font-weight: 600; min-width: 90px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-bar { flex: 1; height: 6px; background: var(--light-gray); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.progress-fill.blue { background: var(--info); }
.progress-fill.green { background: var(--success); }
.progress-fill.orange { background: var(--orange); }
.progress-fill.purple { background: var(--purple); }
.progress-value { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 600; color: var(--orange); min-width: 40px; text-align: right; }

/* ═══════════════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════════════ */
.alert { padding: 0.7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.85rem; border: 1px solid; display: flex; align-items: center; gap: 0.5rem; }
.alert-success { background: var(--success-bg); border-color: #BBE5D0; color: #0E7B43; }
.alert-danger { background: var(--danger-bg); border-color: #F0C0C0; color: #A02020; }
.alert-info { background: var(--info-bg); border-color: #C0D4F0; color: #1E5BB0; }

/* ═══════════════════════════════════════════════
   LOGIN / LANDING
   ═══════════════════════════════════════════════ */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--off-white);
}
.login-box { width: 100%; max-width: 400px; padding: 2.5rem; background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.login-box h1 { font-size: 1.5rem; color: var(--orange); letter-spacing: 2px; text-transform: uppercase; font-weight: 700; margin-bottom: 0.25rem; }
.login-box .subtitle { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 1.75rem; }

.landing-hero {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; text-align: center; padding: 2rem;
  background: var(--white);
}
.landing-hero h1 { font-size: clamp(1.8rem, 5vw, 3rem); color: var(--text); letter-spacing: 2px; text-transform: uppercase; font-weight: 700; margin-bottom: 0.5rem; }
.landing-hero h1 span { color: var(--orange); }
.landing-hero p { font-size: 1rem; color: var(--text-soft); max-width: 480px; margin: 0 auto 2rem; }
.landing-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════
   TEMPLATE SWITCHER
   ═══════════════════════════════════════════════ */
.tpl-switcher { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.tpl-btn {
  flex: 1; padding: 0.7rem 1rem; border: 2px solid var(--light-gray);
  border-radius: var(--radius); background: var(--white); color: var(--text-soft);
  font-family: var(--font); font-size: 0.82rem; font-weight: 600; cursor: pointer;
  text-align: center; transition: var(--transition);
}
.tpl-btn:hover { border-color: var(--mid-gray); }
.tpl-btn.active { border-color: var(--orange); color: var(--orange); background: var(--orange-light); }
.tpl-btn .tpl-desc { font-size: 0.68rem; font-weight: 400; color: var(--text-dim); }
.tpl-btn.active .tpl-desc { color: var(--orange-dark); }
.plantilla-panel { display: none; }
.plantilla-panel.visible { display: block; }

.plantilla-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 0.5rem 0; }
.plantilla-option { border: 2px solid var(--light-gray); border-radius: var(--radius); padding: 0.85rem; cursor: pointer; text-align: center; transition: var(--transition); background: var(--white); }
.plantilla-option:hover { border-color: var(--mid-gray); }
.plantilla-option.selected { border-color: var(--orange); background: var(--orange-light); }
.plantilla-option h4 { margin: 0 0 0.2rem; font-size: 0.85rem; }
.plantilla-option p { margin: 0; font-size: 0.68rem; color: var(--text-dim); }
.plantilla-option input[type=radio] { display: none; }

/* ═══════════════════════════════════════════════
   LOGO UPLOAD
   ═══════════════════════════════════════════════ */
.logo-upload { display: flex; align-items: center; gap: 1rem; }
.logo-preview { width: 68px; height: 68px; border-radius: var(--radius); border: 2px dashed var(--mid-gray); display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--off-white); flex-shrink: 0; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-current { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.logo-current img { max-height: 50px; border-radius: var(--radius); border: 1px solid var(--light-gray); padding: 4px; background: var(--white); }

/* ═══════════════════════════════════════════════
   SEARCH BAR
   ═══════════════════════════════════════════════ */
.search-bar { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.search-bar input, .search-bar select {
  background: var(--white); border: 1px solid var(--mid-gray);
  border-radius: var(--radius); padding: 0.5rem 0.8rem;
  color: var(--text); font-family: var(--font); font-size: 0.82rem;
  outline: none; transition: var(--transition);
}
.search-bar input:focus, .search-bar select:focus { border-color: var(--orange); }
.search-bar input { flex: 1; min-width: 200px; }
.search-bar select {
  min-width: 140px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238C92A0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.7rem center; padding-right: 2rem;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: calc(-1 * var(--sidebar-w) - 10px); z-index: 999; transition: left 0.3s ease; width: var(--sidebar-w); }
  .sidebar.open { left: 0; }
  .main-content { padding: 1.25rem; }
  .form-row, .form-row-4 { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .sig-grid { grid-template-columns: 1fr; }
  .mobile-toggle { display: flex !important; }
  .search-bar { flex-direction: column; }
  .search-bar input, .search-bar select { width: 100%; }
}
.mobile-toggle {
  display: none; position: fixed; top: 0.75rem; left: 0.75rem;
  z-index: 1000; background: var(--white); border: 1px solid var(--light-gray);
  border-radius: var(--radius); padding: 0.45rem; color: var(--orange); cursor: pointer;
  box-shadow: var(--shadow);
}

/* ═══════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════ */
.text-accent { color: var(--orange); }
.text-dim { color: var(--text-dim); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
