/* ========================================
   Variabili Custom
   ======================================== */
:root {
  --primary-color: #0d6efd;
  --secondary-color: #6c757d;
  --dark-color: #212529;
  --light-color: #f8f9fa;
  --border-color: #dee2e6;
  --transition: all 0.3s ease;
  --ai-primary: #007bff; /* Il colore "brand" dell'AI */
  --ai-card-bg: var(--tertiary-color); 
  --ai-body-bg: var(--dark-color);
  --ai-text: var(--primary-color);
  --ai-input-bg: var(--tertiary-color);
  --ai-border: rgba(0,0,0,0.1);
  --ai-shadow: 0 8px 30px rgba(0,0,0,0.15);
  [data-theme="dark"] {
  --ai-border: rgba(255,255,255,0.1);
  --ai-shadow: 0 8px 30px rgba(0,0,0,0.5);
  }
}

/* ========================================
   Typography
   ======================================== */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.7;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 1rem;
}

/* ========================================
   Hero Section
   ======================================== */
.hero-section {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 1rem;
  margin-bottom: 3rem;
}

.hero-section h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
}

.hero-section .lead {
  font-size: clamp(1rem, 2vw, 1.25rem);
  max-width: 700px;
  margin: 0 auto 2rem;
}

/* ========================================
   Navbar
   ======================================== */
.navbar {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
  transition: var(--transition);
}

.navbar-brand {
  font-size: 1.5rem;
  transition: var(--transition);
}

.navbar-brand:hover {
  transform: translateY(-2px);
}

.nav-link {
  position: relative;
  font-weight: 500;
  transition: var(--transition);
}

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

.nav-link.active {
  color: var(--primary-color) !important;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 3px;
  background-color: var(--primary-color);
  border-radius: 2px;
}

/* ========================================
   Cards & Content
   ======================================== */
.card {
  border: 1px solid var(--border-color);
  transition: var(--transition);
  height: 100%;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.card.shadow-sm {
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

.card.shadow-sm:hover {
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* Blog Post Links */
article h2 a,
article h4 a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition);
}

article h2 a:hover,
article h4 a:hover {
  color: var(--primary-color);
}

/* ========================================
   Badges & Tags
   ======================================== */
.badge {
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  transition: var(--transition);
}

.badge:hover {
  transform: scale(1.05);
  text-decoration: none;
}

.badge.bg-light {
  border: 1px solid var(--border-color);
}

/* ========================================
   Code Blocks
   ======================================== */
code {
  background-color: #f8f9fa;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-size: 0.875em;
}

[data-bs-theme="dark"] code {
  background-color: #2d3748;
  color: #fc8181;
}

pre {
  background-color: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
}

[data-bs-theme="dark"] pre {
  background-color: #2d3748;
  border-color: #4a5568;
}

:not(pre)>code {
  background-color: #f8f9fa;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-size: 0.875em;
  color: #e83e8c;
}

pre code {
  background-color: transparent;
  padding: 0;
  color: inherit;
  font-size: 0.875em;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  font-weight: 500;
  transition: var(--transition);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
}

/* ========================================
   Skills Section
   ======================================== */
.bg-light {
  transition: var(--transition);
}

[data-bs-theme="dark"] .bg-light {
  background-color: #2d3748 !important;
}

[data-bs-theme="dark"] .badge.bg-white {
  background-color: #4a5568 !important;
  border-color: #718096 !important;
}

/* ========================================
   Footer
   ======================================== */
footer {
  margin-top: auto;
}

footer a {
  transition: var(--transition);
}

footer a:hover {
  color: var(--primary-color) !important;
}

footer svg {
  transition: var(--transition);
}

footer a:hover svg {
  transform: translateY(-3px);
}

/* ========================================
   Search bar
   ======================================== */
#search-input {
  padding-left: 0.75rem !important;
}

#search-input:focus {
  box-shadow: none;
}

/* ========================================
   AI assistant widget
   ======================================== */

.ai-assistant-wrapper {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  font-family: system-ui, -apple-system, sans-serif;
}

.ai-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dark-color);
  background-color: var(--light-color);
  border: 1px solid var(--primary-color);
  border-radius: 4rem;
  padding: 0;
  width: 32px;
  height: 32px;
}

.ai-welcome-msg {
  color: var(--secondary-color);
}

/* Bottone Pulsante */
.ai-btn-pulse {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ai-primary);
  color: var(--tertiary-color);
  border: none;
  box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
  font-size: 1.5rem;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
}

.ai-btn-pulse:hover {
  
  transform: scale(1.1);
}

/* Card della Chat */
.ai-card {
  width: 350px;
  max-height: 500px;
  background: var(--ai-bg);
  border-radius: 16px;
  box-shadow: var(--ai-shadow);
  position: absolute;
  bottom: 75px;
  right: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease-out;
}

.ai-card-header {
  background: var(--ai-primary);
  color: var(--tertiary-color);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-chat-body {
  height: 350px;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background-color: var(--light-color);
}

.ai-welcome-msg{
  color: var(--dark-color);
}

/* Bolle Messaggi */
.ai-msg {
  padding: 0.75rem 1rem;
  border-radius: 15px;
  font-size: 0.9rem;
  max-width: 85%;
  line-height: 1.4;
}

.ai-msg-user {
  align-self: flex-end;
  background: var(--ai-primary);
  color: var(--tertiary-color);;
  border-bottom-right-radius: 2px;
}

.ai-msg-bot {
  align-self: flex-start;
  background: var(--tertiary-color);;
  color: var(--ai-text);
  border-bottom-left-radius: 2px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.ai-card-footer {
  padding: 1rem;
  display: flex;
  gap: 0.5rem;
  background-color: var(--light-color);
  border-top: 1px solid var(--tertiary-color);
}

.ai-card-footer input {
  flex: 1;
  border: 1px solid var(--primary-color);
  border-radius: 25px;
  padding: 0.5rem 1rem;
  outline: none;
}

.ai-card-footer button {
  background: none;
  border: none;
  color: var(--ai-primary);
  font-size: 1.2rem;
  cursor: pointer;
}

#ai-title {
  color: var(--light-color);
}

#ai-toggle {
  color: var(--light-color);
}

#ai-input {
  color: var(--dark-color);
  background-color: var(--light-color);
  border: 1px solid var(--primary-color);
}

#ai-send {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--primary-color);
  border-radius: 2rem;
  padding: 0;
  width: 45px;
  height: 45px;
}

/* ========================================
   Utilities
   ======================================== */

/* Smooth Scroll */
html {
  scroll-behavior: smooth;
}

/* Selection */
::selection {
  background-color: var(--primary-color);
  color: white;
}

/* Focus Visible */
:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* HR Custom */
hr {
  border-top: 2px solid var(--border-color);
  opacity: 1;
}

/* Truncate text utility */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-truncate-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  .navbar-brand {
    font-size: 1.25rem;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  .hero-section {
    padding: 2rem 1rem !important;
  }

  .btn-lg {
    font-size: 1rem;
    padding: 0.5rem 1rem;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   Dark Mode Improvements
   ======================================== */
[data-bs-theme="dark"] .card {
  background-color: #2d3748;
  border-color: #4a5568;
}

[data-bs-theme="dark"] .card-footer {
  background-color: #2d3748;
  border-color: #4a5568;
}

[data-bs-theme="dark"] .hero-section {
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
}

[data-bs-theme="dark"] .text-muted {
  color: #a0aec0 !important;
}

[data-bs-theme="dark"] .border {
  border-color: #4a5568 !important;
}

[data-bs-theme="dark"] .ai-chat-body {
  background-color: var(--dark-color);
}

[data-bs-theme="dark"] .ai-card-footer{
  background-color: var(--dark-color);
}

[data-bs-theme="dark"] .ai-welcome-msg{
  color: var(--light-color);
}

[data-bs-theme="dark"] .ai-close-btn {
  color: var(--light-color);
  background-color: var(--dark-color);
  border: 1px solid var(--primary-color);
}

[data-bs-theme="dark"] #ai-title {
  color: var(--dark-color);
}

[data-bs-theme="dark"] #ai-toggle {
  color: var(--dark-color);
}

[data-bs-theme="dark"] #ai-input {
  color: var(--light-color);
  background-color: var(--dark-color);
  border: 1px solid var(--primary-color);
}