/* /// VARIABLES */
:root {
  --bg: #eef2f5;
  --sidebar-bg: #0f2b30;
  --sidebar-text: #c6e6e9;
  --sidebar-muted: #7fa4ab;

  --main-bg: #ffffff;
  --main-text: #1a2028;
  --main-muted: #64748b;

  --accent: #0d9488;
  --accent-2: #06b6d4;
  --accent-glow: rgba(6, 182, 212, 0.15);

  --line: #e2e8f0;
  --tag-bg: #e0f2f4;
  --tag-text: #0f766e;
  --tag-border: #bfe6ea;
  --soft-bg: #f8fafc;

  --shadow: rgba(0, 0, 0, 0.1);
  --btn-pdf: #e11d48;
  --btn-port: #0891b2;
  --btn-carta: #0d9488;
}

html[data-theme="dark"] {
  --bg: #071418;
  --sidebar-bg: #0a1a1f;
  --sidebar-text: #c6e6e9;
  --sidebar-muted: #7fa4ab;

  --main-bg: #0e1f24;
  --main-text: #e3f4f6;
  --main-muted: #8b949e;

  --accent: #2dd4bf;
  --accent-2: #22d3ee;

  --line: #1e3a41;
  --tag-bg: rgba(45, 212, 191, 0.12);
  --tag-text: #5eead4;
  --tag-border: rgba(45, 212, 191, 0.3);
  --soft-bg: #12272d;
}

/* /// RESET & LAYOUT BASE */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100vh;
  overflow: hidden;
}

body {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--main-text);
  line-height: 1.4;
  padding: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.35s ease;
}

/* /// TOGGLE TEMA */
.theme-toggle {
  position: fixed;
  top: 15px;
  right: 15px;
  z-index: 100;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--main-bg);
  color: var(--main-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--shadow);
  transition:
    transform 0.2s ease,
    background 0.35s ease;
}

.theme-toggle:hover {
  transform: scale(1.1) rotate(15deg);
}

.theme-toggle .fa-sun,
.theme-toggle .fa-moon {
  display: none;
}

html[data-theme="light"] .theme-toggle .fa-moon {
  display: block;
}

html[data-theme="dark"] .theme-toggle .fa-sun {
  display: block;
}

/* /// CONTENEDOR PRINCIPAL */
.cv {
  width: 100%;
  max-width: 1000px;
  height: 100%;
  max-height: 95vh;
  background: var(--main-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 15px 40px var(--shadow);
  display: flex;
  transition: background 0.35s ease;
}

/* /// SIDEBAR IZQUIERDO */
.sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: background 0.35s ease;
}

.sidebar::before {
  content: "";
  position: absolute;
  top: -50px;
  right: -50px;
  width: 200px;
  height: 200px;
  background: radial-gradient(
    circle,
    rgba(34, 211, 238, 0.15),
    transparent 60%
  );
  filter: blur(10px);
}

.sb-header {
  padding: 25px 20px 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  z-index: 2;
}

.avatar-wrap {
  display: inline-block;
  padding: 4px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  margin-bottom: 10px;
  position: relative;
}

.avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 3px solid var(--sidebar-bg);
  background: #cfe9ec;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.status {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 14px;
  height: 14px;
  background: #10b981;
  border: 2px solid var(--sidebar-bg);
  border-radius: 50%;
  z-index: 3;
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.sb-header h1 {
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.sb-header .role {
  font-size: 0.8rem;
  color: var(--accent-2);
  font-weight: 700;
  margin-top: 2px;
}

.sb-body {
  padding: 15px 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 15px;
  overflow-y: auto;
  position: relative;
  z-index: 2;
}

.sb-body::-webkit-scrollbar {
  display: none;
}

.sb-body {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.sb-section h2 {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--sidebar-muted);
  margin-bottom: 8px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 4px;
}

.contact-list {
  list-style: none;
  font-size: 0.75rem;
}

.contact-list li {
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.contact-list i {
  color: var(--accent-2);
  font-size: 0.85rem;
  width: 14px;
  text-align: center;
}

.contact-list a {
  color: var(--sidebar-text);
  text-decoration: none;
  transition: color 0.2s;
}

.contact-list a:hover {
  color: #fff;
}

.sb-about {
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--sidebar-text);
  opacity: 0.9;
  text-align: justify;
}

.edu-item {
  margin-bottom: 10px;
}

.edu-item .t {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

.edu-item .l {
  font-size: 0.65rem;
  color: var(--accent-2);
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 2px;
}

.edu-item .d {
  font-size: 0.65rem;
  color: var(--sidebar-muted);
  margin-top: 1px;
}

.apt-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  list-style: none;
}

.apt-list li {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.apt-list i {
  color: var(--accent-2);
  font-size: 0.7rem;
}

/* Botones PDF en Sidebar */
.sidebar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.dl-btn {
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 16px;
  border: 1px solid transparent;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  transition:
    transform 0.15s ease,
    filter 0.15s ease;
}

.dl-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.dl-btn-cv {
  background: var(--btn-pdf);
}

.dl-btn-port {
  background: var(--btn-port);
}

.dl-btn-carta {
  background: var(--btn-carta);
}

/* /// ÁREA PRINCIPAL (DERECHA) */
.main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--main-bg);
  position: relative;
  transition: background 0.35s ease;
}

.main-body {
  padding: 25px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.main-body::-webkit-scrollbar {
  display: none;
}

.main-body {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.main-section h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  font-weight: 800;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 14px;
  position: relative;
  transition:
    color 0.35s ease,
    border-color 0.35s ease;
}

.main-section h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 40px;
  height: 2px;
  background: var(--accent);
  transition: background 0.35s ease;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-weight: 600;
  border: 1px solid var(--tag-border);
  transition:
    background 0.35s ease,
    border-color 0.35s ease;
}

.timeline {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-left: 6px;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 0;
  left: 12px;
  width: 2px;
  background: var(--line);
  z-index: 1;
  transition: background 0.35s ease;
}

.tl-item {
  position: relative;
  padding-left: 30px;
  margin-bottom: 16px;
  z-index: 2;
}

.tl-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--main-bg);
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  z-index: 3;
  transition: all 0.2s ease;
}

.tl-item:hover::before {
  background: var(--accent);
  transform: scale(1.2);
}

.tl-content {
  background: var(--soft-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.78rem;
  transition:
    border-color 0.2s ease,
    transform 0.2s ease,
    background 0.35s ease;
}

.tl-item:hover .tl-content {
  border-color: var(--accent-2);
  transform: translateX(3px);
}

.tl-content .top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}

.tl-content .title {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--main-text);
}

.tl-content .date {
  font-size: 0.7rem;
  color: var(--main-muted);
  white-space: nowrap;
  font-weight: 600;
}

.tl-content .sub {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 4px;
}

.tl-content ul {
  list-style: none;
  margin-top: 2px;
}
.tl-content ul li {
  padding-left: 12px;
  position: relative;
  margin-bottom: 3px;
  line-height: 1.3;
  color: var(--main-muted);
  font-size: 0.75rem;
}
.tl-content ul li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--accent-2);
  font-weight: bold;
}

.tl-content p {
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--main-muted);
  margin-top: 2px;
}

.btn-link {
  text-decoration: none;
  color: --var(--main-text);
}

.btn-cv-link {
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.072rem;
  font-weight: 200;
  display: none;
}

/* /// IMPRESIÓN /// */
@media print {
  @page {
    margin: 10mm;
    size: letter portrait;
  }
  body {
    height: auto;
    overflow: visible;
    background: #fff !important;
    padding: 0;
    display: block;
  }
  .cv {
    height: auto;
    max-height: none;
    box-shadow: none !important;
    border-radius: 0 !important;
    max-width: 100%;
    display: block;
  }

  .theme-toggle,
  .sidebar-actions,
  .main-header {
    display: none !important;
  }

  .sidebar {
    width: 100%;
    break-inside: avoid;
    padding: 20px;
  }
  .sb-body {
    overflow: visible;
    display: block;
  }
  .main {
    overflow: visible;
  }
  .main-body {
    padding: 20px 0;
    overflow: visible;
    display: block;
  }

  .tl-item {
    break-inside: avoid;
  }

  .sidebar {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    background: var(--sidebar-bg) !important;
  }
  .avatar,
  .status,
  .tag,
  .main-section h2::after,
  .tl-item::before {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Filtros PDF */
  html.print-mode-cv .print-portafolio,
  html.print-mode-cv .print-carta,
  html.print-mode-port .print-cv,
  html.print-mode-port .print-carta,
  html.print-mode-carta .print-cv,
  html.print-mode-carta .print-portafolio {
    display: none !important;
  }

  html.print-mode-cv .print-cv,
  html.print-mode-cv .btn-cv-link {
    display: block !important;
  }

  html.print-mode-port .print-portafolio,
  html.print-mode-port .btn-cv-link {
    display: block !important;
  }

  html.print-mode-carta .sidebar,
  html.print-mode-carta .avatar-wrap {
    display: none !important;
  }
  html.print-mode-carta .main {
    padding: 30px;
  }
  html.print-mode-carta .letter {
    display: block !important;
  }
  html.print-mode-carta .main-body {
    display: none !important;
  }

  .sb-section-descargar,
  .toast,
  .btn-link {
    display: none !important;
  }
}

.letter {
  display: none;
  padding: 20px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #000;
}

.letter p {
  margin-bottom: 15px;
  text-align: justify;
}

/* /// PDF SIEMPRE EN MODO LIGHT */
@media print {
  :root,
  html,
  html[data-theme="dark"],
  html[data-theme="light"] {
    --bg: #eef2f5;
    --sidebar-bg: #0f2b30;
    --sidebar-text: #c6e6e9;
    --sidebar-muted: #7fa4ab;

    --main-bg: #ffffff;
    --main-text: #1a2028;
    --main-muted: #64748b;

    --accent: #0d9488;
    --accent-2: #06b6d4;
    --accent-glow: rgba(6, 182, 212, 0.15);

    --line: #e2e8f0;
    --tag-bg: #e0f2f4;
    --tag-text: #0f766e;
    --tag-border: #bfe6ea;
    --soft-bg: #f8fafc;

    --shadow: rgba(0, 0, 0, 0.1);

    color-scheme: light !important;
  }

  html,
  body {
    background: #ffffff !important;
    color: #1a2028 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .cv,
  .main,
  .main-body {
    background: #ffffff !important;
    color: #1a2028 !important;
  }

  .sidebar {
    background: #0f2b30 !important;
    color: #c6e6e9 !important;
  }

  .tl-content {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
  }

  .tag {
    background: #e0f2f4 !important;
    color: #0f766e !important;
    border-color: #bfe6ea !important;
  }

  * {
    animation: none !important;
    transition: none !important;
  }
}
