/**
 * Dal Pastin — Gift Card System
 * Design System: Glassmorphism · Mobile-First · Brand Palette
 * ============================================================
 */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Custom Properties ── */
:root {
  --color-primary:   #6F9463;
  --color-text:      #594F48;
  --color-accent:    #AAD479;
  --color-secondary: #B3A891;
  --color-white:     #FFFFFF;

  --color-primary-rgb:   111, 148, 99;
  --color-text-rgb:      89, 79, 72;
  --color-accent-rgb:    170, 212, 121;
  --color-secondary-rgb: 179, 168, 145;

  --glass-bg:        rgba(255, 255, 255, 0.08);
  --glass-bg-strong: rgba(255, 255, 255, 0.14);
  --glass-border:    rgba(255, 255, 255, 0.18);
  --glass-shadow:    0 8px 32px rgba(0, 0, 0, 0.12);
  --glass-blur:      blur(12px);

  --radius-sm:  8px;
  --radius-md:  16px;
  --radius-lg:  24px;

  --transition: all 0.3s ease;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

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

body {
  font-family: var(--font-family);
  color: var(--color-white);
  line-height: 1.6;
  min-height: 100dvh;
  background-color: #252220; /* Base scura calda, non nera */
  background-image: 
    radial-gradient(ellipse at 0% 0%, rgba(111, 148, 99, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(179, 168, 145, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(170, 212, 121, 0.04) 0%, transparent 70%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ── Layout Containers ── */
.page-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.container--narrow {
  max-width: 480px;
}

.container--medium {
  max-width: 800px;
}

/* Center a card on the page (login, check) */
.page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1rem;
}

/* ── Glass Card ── */
.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  transition: var(--transition);
}

.glass:hover {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.glass--strong {
  background: var(--glass-bg-strong);
}

.glass--card {
  padding: 2rem;
}

@media (min-width: 640px) {
  .glass--card {
    padding: 2.5rem;
  }
}

/* ── Logo ── */
.logo {
  display: block;
  margin: 0 auto 1.5rem;
  max-width: 180px;
  height: auto;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

.logo--small {
  max-width: 120px;
  margin-bottom: 1rem;
}

/* ── Typography ── */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }

@media (min-width: 640px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
}

.text-center { text-align: center; }
.text-muted  { opacity: 0.7; }

.page-title {
  text-align: center;
  margin-bottom: 0.5rem;
}

.page-subtitle {
  text-align: center;
  opacity: 0.7;
  font-weight: 300;
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.8;
}

.form-input {
  width: 100%;
  padding: 0.8rem 1rem;
  font-family: var(--font-family);
  font-size: 1rem;
  color: var(--color-white);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  outline: none;
  transition: var(--transition);
}

.form-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.form-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(var(--color-accent-rgb), 0.25);
  background: rgba(255, 255, 255, 0.1);
}

.form-input--dark {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(var(--color-secondary-rgb), 0.3);
}

.form-input--dark:focus {
  background: rgba(255, 255, 255, 0.8);
}

.form-input--dark::placeholder {
  color: rgba(var(--color-text-rgb), 0.4);
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
}

.btn--primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: var(--color-white);
  box-shadow: 0 4px 16px rgba(var(--color-primary-rgb), 0.35);
}

.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(var(--color-primary-rgb), 0.5);
}

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

.btn--secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-white);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn--secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn--danger {
  background: linear-gradient(135deg, #c0392b, #e74c3c);
  color: var(--color-white);
  box-shadow: 0 4px 16px rgba(192, 57, 43, 0.35);
}

.btn--danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(192, 57, 43, 0.5);
}

.btn--full {
  width: 100%;
}

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

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ── Alerts / Messages ── */
.alert {
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
  animation: fadeSlideIn 0.3s ease;
}

.alert--success {
  background: rgba(var(--color-accent-rgb), 0.15);
  border-color: rgba(var(--color-accent-rgb), 0.3);
  color: var(--color-accent);
}

.alert--error {
  background: rgba(231, 76, 60, 0.15);
  border-color: rgba(231, 76, 60, 0.3);
  color: #e74c3c;
}

.alert--info {
  background: rgba(var(--color-secondary-rgb), 0.15);
  border-color: rgba(var(--color-secondary-rgb), 0.3);
  color: var(--color-secondary);
}

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

/* ── Navbar (Admin) ── */
.navbar {
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  position: relative;
}

.navbar__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--color-white);
  font-weight: 600;
  font-size: 1.1rem;
}

.navbar__brand img {
  height: 36px;
  width: auto;
}

/* Burger Button */
.navbar__burger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 101;
  outline: none;
}

.navbar__burger-line {
  display: block;
  width: 100%;
  height: 2px;
  background-color: var(--color-white);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.navbar__links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.navbar__link {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.navbar__link:hover,
.navbar__link--active {
  color: var(--color-white);
  background: rgba(255, 255, 255, 0.1);
}

.navbar__link--logout {
  color: #e74c3c;
  opacity: 0.8;
}

.navbar__link--logout:hover {
  background: rgba(231, 76, 60, 0.15);
  opacity: 1;
}

/* Responsive Navbar */
@media (max-width: 767px) {
  .navbar__burger {
    display: flex;
  }

  .navbar__links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(37, 34, 32, 0.98);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-direction: column;
    padding: 1rem;
    gap: 0.5rem;
    z-index: 99;
  }

  .navbar__links--open {
    display: flex;
    animation: navbarSlideDown 0.25s ease-out forwards;
  }

  .navbar__link {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }

  /* Burger Open Animation */
  .navbar__burger--open .navbar__burger-line:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }

  .navbar__burger--open .navbar__burger-line:nth-child(2) {
    opacity: 0;
  }

  .navbar__burger--open .navbar__burger-line:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }
}

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

/* ── Sezioni Card Dividite ── */
.cards-section {
  margin-top: 3rem;
  margin-bottom: 3.5rem;
}
.cards-section__title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-white);
}
.cards-section__title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.1em;
  background: var(--color-accent);
  border-radius: 2px;
}
.cards-section__title .count-badge {
  font-size: 0.8rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 50px;
  opacity: 0.85;
}

/* ── Tables ── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.6;
  font-weight: 500;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.data-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge--active {
  background: rgba(var(--color-accent-rgb), 0.2);
  color: var(--color-accent);
}

.badge--empty {
  background: rgba(var(--color-secondary-rgb), 0.2);
  color: var(--color-secondary);
}

.badge--inactive {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
}

.badge--pending {
  background: rgba(241, 196, 15, 0.2);
  color: #f1c40f;
}

/* ── GDPR Checkbox ── */
.gdpr-group {
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
}

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-custom {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
  content: '✓';
  color: #1a1a1a;
  font-size: 0.8rem;
  font-weight: 700;
}

.checkbox-label input[type="checkbox"]:focus-visible + .checkbox-custom {
  box-shadow: 0 0 0 3px rgba(var(--color-accent-rgb), 0.35);
}

.checkbox-text {
  flex: 1;
}

.privacy-link {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: var(--transition);
}

.privacy-link:hover {
  color: var(--color-white);
}

/* ── Gift Card Visual ── */
.gift-card-visual {
  background: linear-gradient(135deg, var(--color-primary), rgba(var(--color-accent-rgb), 0.7));
  border-radius: var(--radius-lg);
  padding: 2rem;
  position: relative;
  overflow: hidden;
  color: var(--color-white);
  box-shadow: 0 12px 40px rgba(var(--color-primary-rgb), 0.4);
  animation: fadeSlideIn 0.5s ease;
}

.gift-card-visual::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 60%;
  height: 200%;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 50%;
  pointer-events: none;
}

.gift-card-visual__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.gift-card-visual__logo {
  height: 40px;
  filter: brightness(10);
}

.gift-card-visual__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.8;
}

.gift-card-visual__serial {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  letter-spacing: 0.15em;
  word-break: break-all;
  margin-bottom: 1.5rem;
  opacity: 0.95;
}

.gift-card-visual__amount {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.gift-card-visual__amount-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
  margin-bottom: 0.25rem;
}

/* ── QR Code Section ── */
.qr-section {
  text-align: center;
  margin-top: 1.5rem;
}

.qr-section img {
  background: var(--color-white);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  max-width: 200px;
  width: 100%;
  height: auto;
}

/* ── Balance Display (check.php) ── */
.balance-display {
  text-align: center;
  padding: 1rem 0;
}

.balance-display__amount {
  font-size: 3rem;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: -0.02em;
  text-shadow: 0 0 30px rgba(var(--color-accent-rgb), 0.3);
}

.balance-display__currency {
  font-size: 1.5rem;
  font-weight: 400;
  opacity: 0.7;
}

.balance-display__label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
  margin-top: 0.25rem;
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (min-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.stat-card {
  padding: 1.25rem;
  text-align: center;
}

.stat-card__value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-accent);
}

.stat-card__label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.6;
  margin-top: 0.25rem;
}

/* ── Section Spacing ── */
.section {
  margin-bottom: 2rem;
}

.section__title {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section__title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 1em;
  background: var(--color-accent);
  border-radius: 2px;
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  padding: 1.5rem 0 3rem;
}

/* ── Grid layouts ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 520px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* Nei container stretti il grid-2 resta 1 colonna fino a più spazio */
.container--narrow .grid-2 {
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .container--narrow .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Transaction History ── */
.tx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.875rem;
}

.tx-item:last-child {
  border-bottom: none;
}

.tx-item__amount {
  font-weight: 600;
  color: #e74c3c;
}

.tx-item__date {
  opacity: 0.5;
  font-size: 0.8rem;
}

.tx-item__note {
  opacity: 0.6;
  font-size: 0.8rem;
  font-style: italic;
}

/* ── Settings Section ── */
.settings-section {
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.settings-section__title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  opacity: 0.5;
}

.empty-state__icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

/* ── Utility ── */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-0 { margin-bottom: 0; }

.mono {
  font-family: 'Courier New', monospace;
  letter-spacing: 0.08em;
}

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

/* ── Responsive Helpers ── */
@media (max-width: 639px) {
  .hide-mobile { display: none !important; }
}
@media (max-width: 375px) {
  .balance-hero__amount {
    font-size: 2.4rem !important;
  }
  .balance-hero__amount .currency {
    font-size: 1.3rem !important;
  }
  .card-visual__balance {
    font-size: 2.1rem !important;
  }
}

/* ── Print Styles ── */
@media print {
  body {
    background: white;
    color: black;
  }
  .navbar, .btn, .form-group {
    display: none;
  }
  .glass {
    background: white;
    backdrop-filter: none;
    border: 1px solid #ccc;
    box-shadow: none;
  }
}
