/* ==========================================================================
   CSS Reset & Base Styles
   ========================================================================== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
  transition: all 0.3s ease-in-out;
}

/* ==========================================================================
   CSS Variables for Light/Dark Mode
   ========================================================================== */
:root {
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #dbeafe;
  --secondary: #8b5cf6;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --elev-1: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --elev-2: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --elev-3: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --elev-4: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --elev-5: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --radius-sm: 0.25rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --header-height: 70px;
  --section-padding: 5rem 0;
  --container-max-width: 1280px;
  --container-padding: 0 1.5rem;
}

.dark {
  --surface: #0f172a;
  --surface-2: #1e293b;
  --surface-3: #334155;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --muted: #94a3b8;
  --border: #475569;
  --border-light: #334155;
  --primary: #60a5fa;
  --primary-dark: #3b82f6;
  --primary-light: #1e3a8a;
  --secondary: #a78bfa;
  --accent: #22d3ee;
  --success: #34d399;
  --warning: #fbbf24;
  --error: #f87171;
  --elev-1: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
  --elev-2: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --elev-3: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --elev-4: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  --elev-5: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Custom Animations
   ========================================================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes bounce-slow {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-15px);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes mobileMenuSlide {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes mobileMenuClose {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Animation Classes */
.animate-fade-in-up {
  animation: fadeInUp 0.8s ease-out;
}

.animate-fade-in-down {
  animation: fadeInDown 0.8s ease-out;
}

.animate-fade-in-left {
  animation: fadeInLeft 0.8s ease-out;
}

.animate-fade-in-right {
  animation: fadeInRight 0.8s ease-out;
}

.animate-fade-in {
  animation: fadeIn 0.8s ease-out;
}

.animate-zoom-in {
  animation: zoomIn 0.5s ease-out;
}

.animate-slide-in-up {
  animation: slideInUp 0.5s ease-out;
}

.animate-slide-in-down {
  animation: slideInDown 0.5s ease-out;
}

.animate-slide-in-left {
  animation: slideInLeft 0.5s ease-out;
}

.animate-slide-in-right {
  animation: slideInRight 0.5s ease-out;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-bounce-slow {
  animation: bounce-slow 2s ease-in-out infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* ==========================================================================
   Mobile Menu - COMPLETELY FIXED
   ========================================================================== */

/* Mobile Menu Button - ALWAYS VISIBLE ON MOBILE/TABLET */
#mobileMenuButton {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  background: var(--surface-2);
  border-radius: var(--radius);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 1001;
}

#mobileMenuButton:hover {
  background: var(--primary);
  color: white;
  transform: scale(1.05);
}

#mobileMenuButton.active {
  background: var(--primary);
  color: white;
}

/* Mobile Menu Container */
#mobileMenu {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100%;
  height: calc(100vh - var(--header-height));
  background: var(--surface);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding: 1rem 0;
}

#mobileMenu.active {
  transform: translateX(0);
}

/* Mobile Menu Links */
.mobile-nav-link {
  display: block;
  padding: 1rem 1.5rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition);
  position: relative;
  font-size: 1.1rem;
}

.mobile-nav-link:hover {
  background: var(--surface-2);
  color: var(--primary);
  padding-left: 2rem;
}

.mobile-nav-link:active {
  background: var(--primary-light);
  color: var(--primary);
}

.mobile-nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: var(--transition);
}

.mobile-nav-link:hover::after {
  width: 100%;
}

/* Mobile Download CV Button */
.mobile-download-cv {
  display: none;
  margin: 1rem 1.5rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  text-decoration: none;
  border-radius: var(--radius-lg);
  font-weight: 600;
  text-align: center;
  transition: var(--transition);
  border: none;
  cursor: pointer;
}

.mobile-download-cv:hover {
  transform: translateY(-2px);
  box-shadow: var(--elev-3);
  background: linear-gradient(135deg, var(--primary-dark), var(--secondary));
}

.mobile-download-cv i {
  margin-right: 0.5rem;
}

/* ==========================================================================
   Certification Section - FIXED
   ========================================================================== */

/* Certification Grid */
.certifications-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

/* View All Certifications Button - PERFECTLY CENTERED */
.certifications-view-all {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-top: 2rem;
  padding: 2rem 0;
  grid-column: 1 / -1;
}

.certifications-view-all a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  text-decoration: none;
  border-radius: var(--radius-lg);
  font-weight: 600;
  transition: var(--transition);
  box-shadow: var(--elev-3);
  min-width: 280px;
  text-align: center;
  border: none;
  cursor: pointer;
}

.certifications-view-all a:hover {
  transform: translateY(-3px);
  box-shadow: var(--elev-4);
  background: linear-gradient(135deg, var(--primary-dark), var(--secondary));
}

.certifications-view-all a i {
  margin-right: 0.75rem;
  font-size: 1.25rem;
}

/* ==========================================================================
   Component Styles
   ========================================================================== */

/* Section Title Styling */
.section-title {
  position: relative;
  color: var(--text);
  text-align: center;
  font-weight: 600;
  margin-bottom: 3rem;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 2px;
}

/* Navigation Link Hover Effect */
.nav-link {
  position: relative;
  padding-bottom: 5px;
  transition: var(--transition);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: var(--transition);
}

.nav-link:hover::after {
  width: 100%;
}

.nav-link:hover {
  color: var(--primary);
}

/* Button Hover Effects */
.btn-primary,
.btn-secondary,
.download-btn {
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-primary:hover,
.btn-secondary:hover,
.download-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--elev-3);
}

/* Skill Progress Bars */
.skill-progress {
  width: 0;
  transition: width 1.5s ease-in-out;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

/* ==========================================================================
   Responsive Design - Mobile First Approach
   ========================================================================== */

/* Extra small devices (phones, less than 576px) */
@media (max-width: 575.98px) {
  :root {
    --section-padding: 2.5rem 0;
    --header-height: 60px;
    --container-padding: 0 1rem;
  }

  /* Header adjustments */
  header {
    padding: 0.5rem 0;
  }

  .logo span {
    font-size: 1.1rem;
  }

  /* Show mobile menu button on mobile */
  #mobileMenuButton {
    display: flex;
  }

  /* Hide desktop navigation on mobile */
  header nav {
    display: none !important;
  }

  /* Hide desktop Download CV button on mobile */
  #downloadCV {
    display: none !important;
  }

  /* Show mobile Download CV button */
  .mobile-download-cv {
    display: block;
  }

  /* Hero section */
  #home {
    padding-top: 4rem;
    padding-bottom: 2rem;
    min-height: auto;
  }

  #home h1 {
    font-size: 1.8rem;
    line-height: 1.2;
    margin-bottom: 1rem;
  }

  #home h2 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
  }

  #home p {
    font-size: 0.95rem;
    margin-bottom: 2rem;
  }

  .hero-image-container {
    width: 180px;
    height: 180px;
    margin: 1.5rem auto;
  }

  /* Button groups */
  .btn-group {
    flex-direction: column;
    gap: 1rem;
  }

  .btn-group .btn {
    width: 100%;
    text-align: center;
    padding: 0.875rem 1.5rem;
    font-size: 0.9rem;
  }

  /* About section */
  #about .flex-col {
    gap: 2rem;
  }

  .about-image {
    width: 220px;
    height: 220px;
  }

  .grid-cols-1.sm\:grid-cols-2 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Skills section */
  .skill-item {
    padding: 0.875rem;
  }

  .skill-item .flex.items-center.space-x-3 {
    gap: 0.75rem;
  }

  .skill-item .w-10.h-10 {
    width: 2.25rem;
    height: 2.25rem;
    min-width: 2.25rem;
  }

  /* Tools grid */
  .grid.grid-cols-2.sm\:grid-cols-3.md\:grid-cols-4.lg\:grid-cols-6 {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .tool-item {
    padding: 0.875rem;
  }

  .tool-item i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }

  /* Experience timeline */
  .timeline-line {
    display: none;
  }

  .timeline-dot {
    display: none;
  }

  .timeline-item {
    margin-bottom: 2rem;
  }

  .timeline-item > div:first-child {
    text-align: left !important;
    margin-bottom: 0.5rem;
  }

  .timeline-item > div:last-child {
    padding-left: 0 !important;
  }

  /* Projects grid */
  .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-3 {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .project-card {
    margin-bottom: 1rem;
  }

  .project-image {
    height: 160px;
  }

  /* Certifications grid - FIXED */
  .certifications-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
  }

  .certification-card {
    padding: 1.25rem;
  }

  .certifications-view-all {
    margin-top: 1rem;
    padding: 1rem 0;
  }

  .certifications-view-all a {
    min-width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 0.9rem;
  }

  /* Contact section */
  #contact .flex-col.lg\:flex-row {
    gap: 2rem;
  }

  #contact .lg\:w-2\/5,
  #contact .lg\:w-3\/5 {
    width: 100%;
  }

  .contact-info .space-y-8 {
    gap: 1.5rem;
  }

  .contact-info .flex.items-start.space-x-4 {
    gap: 1rem;
  }

  .contact-info .w-12.h-12 {
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
  }

  .social-links {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Form adjustments */
  .grid.grid-cols-1.sm\:grid-cols-2 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  form .space-y-6 {
    gap: 1.5rem;
  }

  /* Footer */
  footer .flex-col.lg\:flex-row {
    gap: 1.5rem;
    text-align: center;
  }

  footer .flex.space-x-6 {
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
  }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
  :root {
    --section-padding: 3rem 0;
    --container-padding: 0 1.5rem;
  }

  /* Show mobile menu button */
  #mobileMenuButton {
    display: flex;
  }

  /* Hide desktop navigation */
  header nav {
    display: none !important;
  }

  /* Hide desktop Download CV button on tablet */
  #downloadCV {
    display: none !important;
  }

  /* Show mobile Download CV button */
  .mobile-download-cv {
    display: block;
  }

  /* Hero section */
  #home h1 {
    font-size: 2.25rem;
  }

  #home h2 {
    font-size: 1.35rem;
  }

  /* Skills grid */
  .grid.grid-cols-1.lg\:grid-cols-2 {
    grid-template-columns: 1fr;
  }

  /* Tools grid */
  .grid.grid-cols-2.sm\:grid-cols-3.md\:grid-cols-4.lg\:grid-cols-6 {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Projects grid */
  .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Certifications grid - FIXED */
  .certifications-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .certifications-view-all {
    margin-top: 1.5rem;
  }

  .certifications-view-all a {
    min-width: 300px;
  }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
  :root {
    --section-padding: 4rem 0;
  }

  /* Show mobile menu button for tablets */
  #mobileMenuButton {
    display: flex;
  }

  /* Hide desktop navigation on tablets */
  header nav {
    display: none !important;
  }

  /* Hide desktop Download CV button on tablet */
  #downloadCV {
    display: none !important;
  }

  /* Show mobile Download CV button */
  .mobile-download-cv {
    display: block;
  }

  /* Hero section */
  #home h1 {
    font-size: 2.75rem;
  }

  #home h2 {
    font-size: 1.5rem;
  }

  /* About section */
  #about .flex-col.lg\:flex-row {
    gap: 3rem;
  }

  /* Projects grid */
  .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Certifications grid - FIXED */
  .certifications-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }

  /* Contact section */
  #contact .flex-col.lg\:flex-row {
    gap: 3rem;
  }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
  /* Hide mobile menu button on desktop */
  #mobileMenuButton {
    display: none !important;
  }

  /* Show desktop navigation */
  header nav {
    display: flex !important;
  }

  /* Hide mobile menu on desktop */
  #mobileMenu {
    display: none !important;
  }

  /* Show desktop Download CV button */
  #downloadCV {
    display: flex !important;
  }

  /* Hide mobile Download CV button */
  .mobile-download-cv {
    display: none !important;
  }

  /* Certifications grid - FIXED */
  .certifications-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ==========================================================================
   Back to Top Button
   ========================================================================== */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--primary);
  color: white;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  z-index: 1000;
  box-shadow: var(--elev-3);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

/* Mobile back to top button */
@media (max-width: 768px) {
  .back-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 45px;
    height: 45px;
  }
}

/* ==========================================================================
   JavaScript Classes for Interactive Elements
   ========================================================================== */
.mobile-menu-open {
  overflow: hidden;
}

.mobile-menu-open body {
  overflow: hidden;
}

/* Active navigation link */
.nav-link.active,
.mobile-nav-link.active {
  color: var(--primary);
}

.nav-link.active::after,
.mobile-nav-link.active::after {
  width: 100%;
}

/* Loading states */
.loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.text-gradient {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus styles for accessibility */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}