/* === POLYGONUM CUSTOM STYLES === */

/* Variables for brand colors */
:root {
  --polygonum-primary: #4169E1;    /* Royal Blue */
  --polygonum-secondary: #B6D0E2;  /* Light Blue */
  --polygonum-primary-rgb: 65, 105, 225;
  --polygonum-secondary-rgb: 182, 208, 226;

  /* Variants */
  --polygonum-primary-dark: #2E4BC7;
  --polygonum-primary-light: #6B8AE8;
  --polygonum-secondary-dark: #9ABDD8;
  --polygonum-secondary-light: #D4E7F0;
}

/* === NAVBAR CUSTOM === */
.navbar-polygonum {
  background: linear-gradient(135deg, var(--polygonum-primary) 0%, var(--polygonum-primary-dark) 100%);
  box-shadow: 0 2px 10px rgba(var(--polygonum-primary-rgb), 0.3);
  border: none;
}

.navbar-brand {
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  font-size: 1.8rem;
  color: white !important;
  text-decoration: none;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
}

.navbar-brand img {
  transition: all 0.3s ease;
}

.navbar-brand:hover {
  color: var(--polygonum-secondary-light) !important;
}

.navbar-nav .nav-link {
  color: rgba(255, 255, 255, 0.9) !important;
  font-weight: 500;
  padding: 0.7rem 1rem !important;
  border-radius: 6px;
  margin: 0 2px;
  transition: all 0.3s ease;
}

.navbar-nav .nav-link:hover {
  color: white !important;
  background-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

/* Navbar togglers */
.navbar-toggler {
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 4px 8px;
}

.navbar-toggler:focus {
  box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Search form in navbar */
.navbar-nav form.d-flex {
  margin: 0.5rem 0;
}

.navbar-nav form.d-flex .form-control {
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 0.9rem;
  border-radius: 25px;
  padding-right: 80px; /* Space for both icons */
}

.navbar-nav form.d-flex .form-control::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.navbar-nav form.d-flex .form-control:focus {
  background-color: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  color: white;
  box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25);
}

/* Search and advanced search icons */
.navbar-nav form.d-flex .btn-outline-primary {
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.8);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.navbar-nav form.d-flex .btn-outline-primary:hover {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  transform: scale(1.1);
}

/* Dropdown menus */
.dropdown-menu {
  border: none;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
}

.dropdown-item {
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
}

.dropdown-item:hover {
  background-color: var(--polygonum-secondary);
  color: var(--polygonum-primary);
}

/* Bottone Crea Annuncio minimale con espansione */
a.btn-create-ad-minimal.nav-link,
a.btn-create-ad-minimal,
.btn-create-ad-minimal {
  background: white !important;
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
  border-radius: 6px !important;
  font-weight: 600 !important;
  color: var(--polygonum-primary) !important;
  text-decoration: none !important;
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
  box-shadow: 0 3px 10px rgba(255, 255, 255, 0.2) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 40px !important;
  height: 40px !important;
  padding: 0 !important;
  margin: 0 2px !important;
  min-width: 40px !important;
  transform-origin: right center !important;
}

.btn-create-ad-minimal .btn-text {
  opacity: 0;
  transform: translateX(-20px);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: absolute;
  left: 12px;
  font-size: 0.85rem;
  white-space: nowrap;
  pointer-events: none;
  color: var(--polygonum-primary) !important;
  font-weight: 600;
}

.btn-create-ad-minimal .btn-icon {
  position: absolute;
  right: 12px;
  transition: none;
  font-size: 1.1rem;
  z-index: 10;
  color: var(--polygonum-primary) !important;
}

a.btn-create-ad-minimal.nav-link:hover,
a.btn-create-ad-minimal:hover,
.btn-create-ad-minimal:hover {
  background: rgba(255, 255, 255, 0.98) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 5px 15px rgba(255, 255, 255, 0.4) !important;
  color: var(--polygonum-primary) !important;
  border-color: rgba(255, 255, 255, 0.8) !important;
  width: 155px !important;
  padding: 0 !important;
}

.btn-create-ad-minimal:hover .btn-text {
  opacity: 1;
  transform: translateX(0);
  transition-delay: 0.05s;
  color: var(--polygonum-primary) !important;
}

.btn-create-ad-minimal:hover .btn-icon {
  right: 12px; /* Icon stays in exact same position */
  color: var(--polygonum-primary) !important;
}

.btn-create-ad-minimal:active {
  transform: translateY(-1px);
}

/* Navbar alignment fixes */
.navbar-collapse {
  align-items: center;
}

.navbar-nav {
  align-items: center;
}

/* Ensure consistent spacing */
.navbar-nav.ms-auto {
  gap: 0.25rem;
}

/* Fix dropdown alignment */
.nav-item.dropdown {
  display: flex;
  align-items: center;
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
  .navbar-nav form.d-flex {
    width: 100%;
    margin: 1rem 0;
  }

  .navbar-nav form.d-flex .form-control {
    min-width: auto;
    flex: 1;
    padding-right: 80px; /* Maintain space for icons on mobile */
  }

  /* Nasconde il bottone centrale su mobile e lo sposta nel menu */
  .btn-create-ad-minimal {
    display: none;
  }

  /* Fix mobile navbar stacking */
  .navbar-nav.ms-auto {
    gap: 0;
  }

  /* Adjust search icons position on mobile */
  .navbar-nav form.d-flex .btn-outline-primary {
    width: 30px;
    height: 30px;
  }
}

/* Additional hover refinements */
@media (min-width: 992px) {
  .btn-create-ad-minimal:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--polygonum-primary-rgb), 0.3);
  }

  .btn-create-ad-minimal:focus:hover {
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.4), 0 0 0 3px rgba(var(--polygonum-primary-rgb), 0.3);
  }
}

/* === BUTTONS === */
.btn-primary {
  background: linear-gradient(135deg, var(--polygonum-primary) 0%, var(--polygonum-primary-dark) 100%);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  padding: 0.7rem 1.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(var(--polygonum-primary-rgb), 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--polygonum-primary-dark) 0%, var(--polygonum-primary) 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(var(--polygonum-primary-rgb), 0.4);
}

.btn-outline-primary {
  border-color: var(--polygonum-primary);
  color: var(--polygonum-primary);
  border-width: 2px;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.btn-outline-primary:hover {
  background-color: var(--polygonum-primary);
  border-color: var(--polygonum-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(var(--polygonum-primary-rgb), 0.3);
}

.btn-secondary {
  background-color: var(--polygonum-secondary);
  border-color: var(--polygonum-secondary);
  color: var(--polygonum-primary);
  border-radius: 8px;
  font-weight: 600;
}

.btn-secondary:hover {
  background-color: var(--polygonum-secondary-dark);
  border-color: var(--polygonum-secondary-dark);
  color: var(--polygonum-primary-dark);
}

/* === CARDS === */
.card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  overflow: hidden;
}

.card:hover,
.card-hover:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.card-hover {
  transition: all 0.3s ease;
}

.card-header {
  background: linear-gradient(135deg, var(--polygonum-secondary) 0%, var(--polygonum-secondary-light) 100%);
  border-bottom: none;
  font-weight: 600;
  color: var(--polygonum-primary);
}

/* Card borders for ad types */
.card.border-success {
  border-left: 4px solid #28a745 !important;
}

.card.border-info {
  border-left: 4px solid #17a2b8 !important;
}

.card.border-warning {
  border-left: 4px solid #ffc107 !important;
}

.card.border-primary {
  border-left: 4px solid var(--polygonum-primary) !important;
}

/* === ALERTS === */
.alert-light {
  background-color: var(--polygonum-secondary-light);
  border-color: var(--polygonum-secondary);
  color: var(--polygonum-primary-dark);
  border-radius: 10px;
}

.alert-info {
  background-color: rgba(var(--polygonum-primary-rgb), 0.1);
  border-color: var(--polygonum-primary);
  color: var(--polygonum-primary-dark);
  border-radius: 10px;
}

/* === HERO SECTION === */
.hero-section {
  background: linear-gradient(135deg, var(--polygonum-primary) 0%, var(--polygonum-primary-dark) 100%);
  color: white;
  padding: 4rem 0;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="white" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="white" opacity="0.1"/><circle cx="50" cy="10" r="0.5" fill="white" opacity="0.1"/><circle cx="90" cy="40" r="0.5" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  opacity: 0.3;
}

.hero-content {
  position: relative;
  z-index: 1;
}

/* === FORMS === */
.form-control {
  border-radius: 8px;
  border: 2px solid #e9ecef;
  padding: 0.75rem 1rem;
  transition: all 0.3s ease;
}

.form-control:focus {
  border-color: var(--polygonum-primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--polygonum-primary-rgb), 0.25);
}

.form-label {
  font-weight: 600;
  color: var(--polygonum-primary-dark);
  margin-bottom: 0.5rem;
}

/* === BADGES === */
.badge.bg-success {
  background-color: #28a745 !important;
}

.badge.bg-info {
  background-color: #17a2b8 !important;
}

.badge.bg-primary {
  background-color: var(--polygonum-primary) !important;
}

.badge.bg-secondary {
  background-color: var(--polygonum-secondary-dark) !important;
  color: var(--polygonum-primary) !important;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .navbar-brand {
    font-size: 1.4rem;
    letter-spacing: 0.5px;
  }

  .hero-section {
    padding: 2rem 0;
  }

  .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

/* === UTILITIES === */
.text-polygonum-primary {
  color: var(--polygonum-primary) !important;
}

.text-polygonum-secondary {
  color: var(--polygonum-secondary-dark) !important;
}

.bg-polygonum-primary {
  background-color: var(--polygonum-primary) !important;
}

.bg-polygonum-secondary {
  background-color: var(--polygonum-secondary) !important;
}

/* === TEXTURE BACKGROUNDS === */
.bg-texture-light {
  background-color: #fafafa;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23e8e8e8' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.bg-texture-white {
  background-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23f0f0f0' fill-opacity='0.08' fill-rule='evenodd'%3E%3Cpath d='M0 40L40 0H20L0 20M40 40V20L20 40'/%3E%3C/g%3E%3C/svg%3E");
}

.bg-texture-dots {
  background-color: #fafafa;
  background-image: radial-gradient(circle, #e0e0e0 0.5px, transparent 0.5px);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}

.bg-texture-geometric {
  background-color: #fbfbfb;
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23eeeeee' fill-opacity='0.1'%3E%3Cpath d='M50 50c0-5.5-4.5-10-10-10s-10 4.5-10 10 4.5 10 10 10 10-4.5 10-10zM10 10c0-5.5-4.5-10-10-10s-10 4.5-10 10 4.5 10 10 10 10-4.5 10-10zm60 60c0-5.5-4.5-10-10-10s-10 4.5-10 10 4.5 10 10 10 10-4.5 10-10z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

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

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

/* === LOADING STATES === */
.btn-loading {
  position: relative;
  pointer-events: none;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  margin: auto;
  border: 2px solid transparent;
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* === MOBILE NAVBAR LAYOUT === */
@media (max-width: 991.98px) {
  /* Mobile: spazio tra logo e icone profilo/notifiche */
  .navbar-brand {
    flex-grow: 1;
  }

  /* Mobile: le icone notifiche e profilo hanno padding corretto */
  .navbar .dropdown .nav-link {
    padding: 0.75rem;
    color: white !important;
  }

  /* Mobile: hover effect per le icone */
  .navbar .dropdown .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
  }

  /* Mobile: badge notifiche posizionato correttamente */
  .navbar .position-relative .badge {
    font-size: 0.65em;
  }

  /* Mobile: Fix dropdown notifiche che esce dallo schermo */
  .navbar .dropdown-menu {
    position: fixed !important;
    top: 60px !important;
    right: 10px !important;
    left: auto !important;
    transform: none !important;
    max-width: calc(100vw - 20px) !important;
    min-width: 280px !important;
  }

  /* Mobile: dropdown delle notifiche più piccolo */
  #notificheDropdownMobile + .dropdown-menu {
    width: 320px !important;
    max-width: calc(100vw - 20px) !important;
  }
}