:root {
  /* Sidebar en petróleo oscuro */
  --bg-sidebar: #12373d;
  --text-sidebar-primary: #f3fafb;
  --text-sidebar-secondary: #cfe6e9;

  /* Contenido principal y fondos suaves (tintados de teal) */
  --bg-main: #f4f9fa;
  --bg-main-alt: #e8f2f4;
  --bg-card: #fdffff;

  --text-primary: #2f3a3c;
  --text-secondary: #475c60;

  /* Acento sobre fondos claros (botones, fechas, bordes) */
  --accent: #0f7c8a;
  --accent-hover: #0b6470;

  /* Acento sobre la sidebar oscura (iconos, hover, avatar) */
  --accent-sidebar: #aab4ff;

  --border: #d9e8ea;
  --border-sidebar: rgba(255, 255, 255, 0.22);

  --font-sans: "Inter", sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

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

/* Multi-language Logic via CSS */
body.lang-en-active .lang-es {
  display: none !important;
}

body.lang-es-active .lang-en {
  display: none !important;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background-color: var(--bg-sidebar);
  color: var(--text-sidebar-primary);
  position: fixed;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2rem;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-top {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 1rem;
  width: 100%;
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-sidebar);
  color: var(--text-sidebar-primary);
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}

.mobile-menu-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.lang-toggle-container {
  display: flex;
  justify-content: flex-end;
}

.lang-btn {
  background: transparent;
  border: 1px solid var(--border-sidebar);
  color: var(--text-sidebar-secondary);
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}

.lang-btn:hover {
  border-color: var(--text-sidebar-primary);
}

.lang-btn .active {
  color: var(--text-sidebar-primary);
}

.profile {
  text-align: center;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.avatar {
  width: 165px;
  height: 165px;
  min-width: 165px;
  min-height: 165px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 24%;
  border: 3px solid var(--accent-sidebar);
  margin-bottom: 1rem;
  display: block;
  image-rendering: auto;
  background: rgba(170, 180, 255, 0.2);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  box-shadow: 0 8px 24px rgba(18, 55, 61, 0.25);
}

.profile h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.profile .title {
  color: var(--text-sidebar-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.badge {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  background: rgba(170, 180, 255, 0.18);
  color: var(--accent-sidebar);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  position: relative; /* added for subbadge positioning */
}

.subbadge {
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 0.65rem;
  background: var(--accent);
  color: #fff;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  cursor: help;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
}

.side-nav a {
  text-decoration: none;
  color: var(--text-sidebar-secondary);
  padding: 0.8rem 1rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-weight: 500;
}

.side-nav a:hover,
.side-nav a.active {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-sidebar-primary);
}

.side-nav a i {
  width: 20px;
  text-align: center;
  color: var(--accent-sidebar);
}

.contact-links {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-sidebar);
}

.contact-links a {
  text-decoration: none;
  color: var(--text-sidebar-secondary);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  transition: color 0.2s;
}

.contact-links a:hover {
  color: var(--accent-sidebar);
}

/* Main Content */
.main-content {
  margin-left: 320px;
  flex-grow: 1;
  padding: 6rem 10% 4rem 10%; /* Increased top padding for top bar */
  background-color: var(--bg-main);
}

/* Top Bar */
.top-bar {
  position: fixed;
  top: 0;
  left: 320px;
  width: calc(100% - 320px);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(5px);
  padding: 1rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 90;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  border-bottom: 1px solid var(--border);
}

.top-certs {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.cert-badge-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  background: rgba(15, 124, 138, 0.12);
  color: #0b6470;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition:
    transform 0.2s,
    background 0.2s;
  flex-shrink: 0;
}

.cert-badge-link:hover {
  transform: scale(1.05);
  background: rgba(15, 124, 138, 0.22);
}

.cert-badge-img {
  width: 22px;
  height: 22px;
  border-radius: 3px;
  object-fit: contain;
}

.top-download {
  display: flex;
  align-items: center;
}

.flag-link {
  text-decoration: none;
  font-size: 1.4rem;
  margin: 0 0.3rem;
  transition: transform 0.2s;
  display: inline-block;
}

.flag-link:hover {
  transform: scale(1.15);
}

.section {
  margin-bottom: 5rem;
  scroll-margin-top: 6rem; /* Offsets scroll to account for the fixed top bar */
}

.section-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--text-primary);
  border-bottom: 2px solid var(--bg-main-alt);
  padding-bottom: 0.5rem;
  display: inline-block;
}

.text-content p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
  font-size: 1.05rem;
}

.text-content ul {
  margin-top: 1rem;
  margin-left: 1.5rem;
  color: var(--text-secondary);
}

.text-content li {
  margin-bottom: 0.5rem;
}

/* Skills */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.skill-group {
  background: var(--bg-main-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.skill-group:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 124, 138, 0.45);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.skill-group h3 {
  margin-bottom: 1rem;
  font-size: 1.08rem;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tags span {
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.2;
}

.tags span:hover {
  border-color: rgba(15, 124, 138, 0.5);
  color: var(--text-primary);
}

.tags i {
  margin-right: 0.5rem;
  min-width: 12px;
}

/* Timeline (Experience / Education) */
.timeline {
  position: relative;
  max-width: 800px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-left: 3rem;
  margin-bottom: 3rem;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--accent);
}

.timeline-meta {
  margin-bottom: 0.5rem;
}

.timeline-date {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}

.timeline-body h3 {
  font-size: 1.2rem;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.timeline-body h4 {
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 1rem;
}

.project-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.project-header h3 {
  font-size: 1.1rem;
  margin-bottom: 0.8rem;
  color: var(--text-primary);
}

.project-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Contact */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
}

.contact-detail {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.contact-detail i {
  color: var(--accent);
}

.social-row {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.social-row a {
  color: var(--text-secondary);
  font-size: 1.5rem;
  transition: color 0.2s;
}

.social-row a:hover {
  color: var(--accent);
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  padding: 0.8rem;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 1rem;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.contact-form button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 1rem;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.contact-form button:hover {
  background: var(--accent-hover);
}

/* Responsive */
@media (max-width: 1024px) {
  .main-content {
    padding: 4rem 5%;
  }
  .contact-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    padding: 1.5rem;
  }
  .sidebar-top {
    justify-content: space-between;
    margin-bottom: 0.5rem;
  }
  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
  }
  .side-nav {
    display: none;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-sidebar);
    animation: slideDown 0.3s ease-in-out;
  }
  .side-nav.active {
    display: flex;
  }
  .top-bar {
    position: relative;
    left: 0;
    width: 100%;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
  }
  .main-content {
    margin-left: 0;
    padding: 2rem 5%;
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* GDPR & Cookie Banner */
.gdpr-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.gdpr-checkbox input {
  width: auto;
  margin-top: 0.3rem;
  cursor: pointer;
}

.captcha-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.captcha-group label {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 500;
}

.captcha-group input {
  width: 150px;
}

.gdpr-checkbox label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.gdpr-checkbox a {
  color: var(--accent);
  text-decoration: none;
}

.gdpr-checkbox a:hover {
  text-decoration: underline;
}

.cookie-banner {
  position: fixed;
  bottom: -100px;
  left: 0;
  width: 100%;
  background-color: var(--bg-sidebar);
  color: var(--text-sidebar-primary);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  z-index: 1000;
  box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
  transition: bottom 0.4s ease-in-out;
}

.cookie-banner.show {
  bottom: 0;
}

.cookie-content {
  font-size: 0.9rem;
  color: var(--text-sidebar-secondary);
}

.cookie-btn {
  background: var(--accent-sidebar);
  color: var(--bg-sidebar);
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.cookie-btn:hover {
  background: #fff;
}

@media (max-width: 768px) {
  .cookie-banner {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }
}

/* --- Back to Top Button --- */
#backToTop {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 999;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(1rem);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease,
    background 0.2s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

#backToTop.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#backToTop:hover {
  background: var(--accent-hover);
}
