/* ========================================
   FIXITY — Design System & Components
   ======================================== */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---------- CSS Variables ---------- */
:root {
  /* Palette */
  --primary: #F5B800;
  --primary-hover: #E0A800;
  --primary-light: #FFF8E1;
  --surface: #FFFFFF;
  --surface-alt: #F5F5F5;
  --surface-hover: #EFEFEF;
  --border: #E8E8E8;
  --text: #1A1A1A;
  --text-secondary: #6B6B6B;
  --text-muted: #9E9E9E;
  --overlay: rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .08), 0 2px 6px rgba(0, 0, 0, .04);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .12), 0 4px 12px rgba(0, 0, 0, .06);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, .15);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Spacing */
  --gap: 24px;
  --gap-sm: 12px;
  --gap-xs: 8px;

  /* Transitions */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --duration: .25s;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--surface);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

img {
  display: block;
  max-width: 100%;
}

ul,
ol {
  list-style: none;
}

input,
select,
textarea {
  font-family: inherit;
}

/* ---------- Layout ---------- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* ========================================
   HEADER
   ======================================== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.header__inner {
  display: flex;
  align-items: center;
  gap: var(--gap);
}

.header__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--text);
  flex-shrink: 0;
}

.header__logo .logo-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.header__logo span {
  color: var(--text);
}

.header__logo span b {
  color: var(--primary);
  font-weight: 800;
}

/* Search */
.search-bar {
  flex: 1;
  max-width: 520px;
  position: relative;
}

.search-bar input {
  width: 100%;
  height: 46px;
  border: 2px solid var(--border);
  border-radius: 50px;
  padding: 0 52px 0 20px;
  font-size: .95rem;
  background: var(--surface);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  outline: none;
}

.search-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245, 184, 0, .18);
}

.search-bar__btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration) var(--ease);
}

.search-bar__btn:hover {
  background: var(--primary-hover);
}

.search-bar__btn svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
  fill: none;
}

/* Header actions */
.header__actions {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  margin-left: auto;
}

/* Artisan CTA Button */
.header__artisan-btn {
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  border-radius: 50px;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(245, 184, 0, .25);
}

.header__artisan-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 184, 0, .35);
}

.header__icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background var(--duration) var(--ease);
}

.header__icon-btn:hover {
  background: var(--surface-alt);
}

.header__icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: var(--text);
  fill: none;
}

.header__icon-btn .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========================================
   CATEGORY PILLS
   ======================================== */
.categories-bar {
  padding: 16px 0 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.categories-bar::-webkit-scrollbar {
  display: none;
}

.categories-bar__inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-pill {
  white-space: nowrap;
  padding: 10px 22px;
  border-radius: 50px;
  border: 1.5px solid var(--border);
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  transition: all var(--duration) var(--ease);
  flex-shrink: 0;
}

.category-pill:hover {
  background: var(--surface-alt);
  border-color: #ccc;
}

.category-pill.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.category-pill--filter {
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
}

.category-pill--filter svg {
  width: 16px;
  height: 16px;
  stroke: var(--text);
  fill: none;
}

/* ========================================
   CARD GRID
   ======================================== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gap);
  padding: 20px 0 40px;
}

/* ========================================
   PROFESSIONAL CARD
   ======================================== */
.card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  cursor: pointer;
  position: relative;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* Card image */
.card__img-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--surface-alt);
}

.card__img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s var(--ease);
}

.card:hover .card__img-wrap img {
  transform: scale(1.04);
}

.card__fav {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--duration) var(--ease), background var(--duration) var(--ease);
  z-index: 2;
}

.card__fav:hover {
  transform: scale(1.12);
  background: #fff;
}

.card__fav svg {
  width: 18px;
  height: 18px;
  stroke: var(--text);
  fill: none;
  stroke-width: 2;
}

.card__fav.active svg {
  fill: #e74c3c;
  stroke: #e74c3c;
}

/* Card body */
.card__body {
  padding: 14px 16px 18px;
}

.card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2px;
}

.card__name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.card__rating {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.card__rating svg {
  width: 14px;
  height: 14px;
  fill: var(--text);
}

.card__city {
  font-size: .87rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.card__price {
  font-size: .92rem;
  color: var(--text);
}

.card__price strong {
  font-weight: 700;
}

/* Distance badge — shown for nearby artisans outside the searched city */
.card__distance-badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 50px;
  backdrop-filter: blur(4px);
  z-index: 2;
  letter-spacing: .01em;
}


/* ========================================
   FILTER POPUP
   ======================================== */
.popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s var(--ease), visibility .3s;
}

.popup-overlay.open {
  opacity: 1;
  visibility: visible;
}

.popup {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px 32px 24px;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px) scale(.97);
  transition: transform .3s var(--ease);
}

.popup-overlay.open .popup {
  transform: translateY(0) scale(1);
}

/* Tabs */
.popup__tabs {
  display: flex;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 24px;
}

.popup__tab {
  flex: 1;
  text-align: center;
  padding: 12px 8px 10px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--duration) var(--ease);
  line-height: 1.2;
}

.popup__tab small {
  display: block;
  font-size: .72rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}

.popup__tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.popup__tab:hover:not(.active) {
  color: var(--text);
}

/* Tab panels */
.popup__panel {
  display: none;
}

.popup__panel.active {
  display: block;
}

/* Category grid inside popup */
.popup__categories {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.popup__cat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 6px;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  border: 2px solid transparent;
  transition: all var(--duration) var(--ease);
  cursor: pointer;
}

.popup__cat-item:hover {
  background: var(--surface-hover);
}

.popup__cat-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.popup__cat-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.popup__cat-label {
  font-size: .72rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  line-height: 1.2;
}

/* Dove panel */
.popup__input-group {
  margin-bottom: 16px;
}

.popup__input-group label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.popup__input {
  width: 100%;
  height: 48px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 16px;
  font-size: .92rem;
  outline: none;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.popup__input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245, 184, 0, .18);
}

/* Disponibilità panel */
.popup__availability {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.popup__avail-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  font-size: .9rem;
  font-weight: 500;
}

.popup__avail-option:hover {
  background: var(--surface-hover);
}

.popup__avail-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* Popup actions */
.popup__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.btn {
  padding: 12px 28px;
  border-radius: 50px;
  font-size: .9rem;
  font-weight: 600;
  transition: all var(--duration) var(--ease);
}

.btn--outline {
  border: 1.5px solid var(--border);
  color: var(--text);
  background: var(--surface);
}

.btn--outline:hover {
  background: var(--surface-alt);
}

.btn--primary {
  background: var(--primary);
  color: #fff;
}

.btn--primary:hover {
  background: var(--primary-hover);
}

/* ========================================
   FOOTER
   ======================================== */
.footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  margin-top: auto;
}

.footer__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: .8rem;
  color: var(--text-muted);
}

.footer__inner a {
  color: var(--text-secondary);
  transition: color var(--duration) var(--ease);
}

.footer__inner a:hover {
  color: var(--text);
}

.footer__inner span {
  margin: 0 4px;
}

/* ========================================
   CHAT BUBBLE
   ======================================== */
.chat-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 200;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: transform var(--duration) var(--ease), background var(--duration) var(--ease);
}

.chat-bubble:hover {
  transform: scale(1.1);
  background: var(--primary-hover);
}

.chat-bubble svg {
  width: 26px;
  height: 26px;
  fill: #fff;
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeInUp .5s var(--ease) both;
}

.card:nth-child(1) {
  animation-delay: .05s;
}

.card:nth-child(2) {
  animation-delay: .1s;
}

.card:nth-child(3) {
  animation-delay: .15s;
}

.card:nth-child(4) {
  animation-delay: .2s;
}

.card:nth-child(5) {
  animation-delay: .25s;
}

.card:nth-child(6) {
  animation-delay: .3s;
}

.card:nth-child(7) {
  animation-delay: .35s;
}

.card:nth-child(8) {
  animation-delay: .4s;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
  .header__inner {
    gap: var(--gap-sm);
  }

  .search-bar {
    max-width: none;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }

  .popup {
    padding: 20px 22px 20px;
    width: 95%;
  }

  .popup__categories {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ========================================
   PROFILE DROPDOWN MENU
   ======================================== */
.header__actions {
  position: relative;
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  min-width: 240px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--duration) var(--ease);
  z-index: 1000;
  overflow: hidden;
}

.profile-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.profile-dropdown__header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.profile-dropdown__user-name {
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-dropdown__user-email {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.profile-dropdown__menu {
  padding: 8px 0;
}

.profile-dropdown__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 18px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  transition: background var(--duration) var(--ease);
  text-align: left;
}

.profile-dropdown__item:hover {
  background: var(--surface-alt);
}

.profile-dropdown__item svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-secondary);
  fill: none;
  flex-shrink: 0;
}

.profile-dropdown__divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.profile-dropdown__item--logout {
  color: #e74c3c;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 16px;
}

.profile-dropdown__item--logout:hover {
  background: #fff5f5;
}

.profile-dropdown__item--logout svg {
  stroke: #e74c3c;
}

.profile-dropdown__item--artigiano {
  color: #b8860b;
  font-weight: 600;
}

.profile-dropdown__item--artigiano:hover {
  background: #fffbea;
}

.profile-dropdown__item--artigiano svg {
  stroke: #b8860b;
}

@media (max-width: 480px) {
  .grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .header__logo span {
    display: none;
  }

  .category-pill {
    padding: 8px 16px;
    font-size: .82rem;
  }

  .header__artisan-btn {
    padding: 8px 14px;
    font-size: .82rem;
  }

  .profile-dropdown {
    right: -12px;
    min-width: 220px;
  }
}

/* ========================================
   NOTIFICATION BELL WRAPPER
   ======================================== */
.notif-wrapper {
  position: relative;
}

/* ========================================
   NOTIFICATION DROPDOWN PANEL
   ======================================== */
.notif-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 320px;
  max-height: 420px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--duration) var(--ease);
  z-index: 1001;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.notif-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Header */
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  flex-shrink: 0;
}

.notif-header__title {
  font-size: .92rem;
  font-weight: 700;
  color: var(--text);
}

.notif-header__clear {
  font-size: .78rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color var(--duration) var(--ease);
}

.notif-header__clear:hover {
  color: #e74c3c;
}

/* Scrollable list */
.notif-list {
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
}

/* Empty state */
.notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  color: var(--text-muted);
  gap: 10px;
}

.notif-empty p {
  font-size: .88rem;
  margin: 0;
}

/* Single notification item */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  transition: background var(--duration) var(--ease);
  position: relative;
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item:hover {
  background: var(--surface-alt);
}

.notif-item--unread {
  background: #fffdf0;
  border-left: 3px solid var(--primary);
}

.notif-item--unread:hover {
  background: #fffbe0;
}

.notif-item__icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.notif-item__body {
  flex: 1;
  min-width: 0;
}

.notif-item__title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-item__msg {
  font-size: .8rem;
  color: var(--text-secondary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notif-item__time {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Close (×) button */
.notif-item__close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
  margin-top: 2px;
}

.notif-item__close:hover {
  background: #fee2e2;
  color: #e74c3c;
}

/* Badge (red dot with count) */
.notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #e74c3c;
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

@media (max-width: 480px) {
  .notif-dropdown {
    width: 290px;
    right: -16px;
  }
}