@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,650;9..144,750&family=Manrope:wght@400;500;600;700;800&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #f7f1e6;
    --bg-soft: #fbf7ef;
    --surface: #ffffff;
    --surface-muted: #f2eadc;
    --text: #203326;
    --text-soft: #617062;
    --muted: #8a927f;
    --border: #ded5c5;
    --border-strong: #c8bca8;
    --primary: #2f6b45;
    --primary-strong: #1f4f32;
    --primary-soft: #e7f1e8;
    --accent: #d8913c;
    --accent-soft: #fff0d8;
    --success: #2f7d4b;
    --success-soft: #e3f4e8;
    --danger: #b5473f;
    --danger-soft: #fde9e6;
    --warning: #a66a21;
    --warning-soft: #fff2d9;
    --info: #315f86;
    --info-soft: #e7f0f6;
    --shadow-sm: 0 8px 22px rgba(48, 61, 41, 0.08);
    --shadow-md: 0 18px 50px rgba(48, 61, 41, 0.12);
    --shadow-lg: 0 28px 70px rgba(48, 61, 41, 0.16);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 34px;
    --container: 1180px;
    --ease: cubic-bezier(.2, .8, .2, 1);
    --transition: 180ms var(--ease);
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    color: var(--text);
    font-family: 'Manrope', 'Trebuchet MS', sans-serif;
    line-height: 1.55;
    background:
        radial-gradient(circle at 8% 12%, rgba(216, 145, 60, 0.18), transparent 26rem),
        radial-gradient(circle at 92% 8%, rgba(47, 107, 69, 0.16), transparent 24rem),
        linear-gradient(145deg, var(--bg) 0%, #efe6d7 54%, #e8ddca 100%);
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(47, 107, 69, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(47, 107, 69, 0.045) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,.8), transparent 70%);
    z-index: -1;
}

body.menu-open {
    overflow: hidden;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    color: inherit;
}

a {
    color: inherit;
}

img,
svg {
    display: block;
    max-width: 100%;
}

main {
    display: block;
}

.page-shell {
    width: min(var(--container), calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 56px;
}

.page-shell.narrow {
    width: min(960px, calc(100% - 32px));
}

.hero {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.7);
    border-radius: var(--radius-xl);
    padding: clamp(28px, 5vw, 58px);
    background:
        linear-gradient(135deg, rgba(255,255,255,.93), rgba(255,255,255,.78)),
        radial-gradient(circle at 88% 12%, rgba(216, 145, 60, .22), transparent 20rem),
        radial-gradient(circle at 12% 88%, rgba(47, 107, 69, .18), transparent 18rem);
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
}

.hero::after {
    content: '';
    position: absolute;
    right: clamp(18px, 5vw, 60px);
    bottom: clamp(18px, 5vw, 52px);
    width: clamp(120px, 24vw, 300px);
    aspect-ratio: 1;
    border-radius: 46% 54% 54% 46%;
    background: linear-gradient(135deg, rgba(47, 107, 69, .12), rgba(216, 145, 60, .14));
    filter: blur(.2px);
    z-index: 0;
}

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

.hero-scroll-link {
    position: absolute;
    right: clamp(18px, 4vw, 42px);
    bottom: clamp(18px, 4vw, 36px);
    z-index: 2;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(222, 213, 197, .92);
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--primary-strong);
    background: rgba(255,255,255,.74);
    box-shadow: var(--shadow-sm);
    opacity: .78;
    text-decoration: none;
    transition: opacity var(--transition), transform var(--transition), background var(--transition), box-shadow var(--transition);
}

.hero-scroll-link::before {
    content: '';
    width: 12px;
    height: 12px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translate(-1px, -2px);
}

.hero-scroll-link:hover,
.hero-scroll-link:focus-visible {
    opacity: 1;
    transform: translateY(2px);
    background: #fff;
    box-shadow: var(--shadow-md);
    outline: none;
}

/* Mobile: centra la freccia in basso */
@media (max-width: 768px) {
    .hero-scroll-link {
        position: absolute;
        right: 50%;
        transform: translateX(-50%);
        bottom: clamp(18px, 4vw, 36px);
    }

    .hero-scroll-link:hover,
    .hero-scroll-link:focus-visible {
        transform: translateX(-50%) translateY(-2px);
        opacity: 1;
    }
}

/* Nasconde la freccia dopo lo scroll */
.hero-scroll-link.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms var(--ease);
}

.hero h1,
.section-title,
.content-card h2,
.login-card h2 {
    font-family: 'Fraunces', Georgia, serif;
    letter-spacing: -0.035em;
}

.hero h1 {
    max-width: 760px;
    font-size: clamp(2.15rem, 5.2vw, 4.8rem);
    line-height: .98;
    color: var(--primary-strong);
    margin-bottom: 18px;
    overflow-wrap: anywhere;
    hyphens: auto;
}

.hero p {
    max-width: 690px;
    color: var(--text-soft);
    font-size: clamp(1rem, 1.8vw, 1.2rem);
}

.hero-actions,
.actions-row,
.navigation {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.hero-actions {
    margin-top: 26px;
}

.section-card,
.content-card,
.progress-container,
.login-card,
.admin-section {
    background: rgba(255,255,255,.9);
    border: 1px solid rgba(222, 213, 197, .86);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(14px);
}

.section-card,
.content-card,
.admin-section {
    padding: clamp(20px, 3vw, 32px);
    margin-bottom: 22px;
}

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.section-title {
    font-size: clamp(1.55rem, 3vw, 2.25rem);
    color: var(--primary-strong);
    line-height: 1.05;
}

.section-subtitle {
    color: var(--text-soft);
    margin-top: 8px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(222, 213, 197, .86);
    border-radius: var(--radius-md);
    padding: 20px;
    background: rgba(255,255,255,.82);
    box-shadow: var(--shadow-sm);
    animation: riseIn 480ms var(--ease) both;
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
}

.stat-number {
    font-size: clamp(1.85rem, 4vw, 2.7rem);
    font-weight: 800;
    letter-spacing: -.04em;
    color: var(--primary-strong);
}

.stat-label {
    color: var(--text-soft);
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.controls-panel {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.search-box {
    position: relative;
}

.search-box input,
.form-control {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255,255,255,.88);
    color: var(--text);
    padding: 14px 18px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition), transform var(--transition);
}

.search-box input {
    padding-right: 48px;
}

.search-box input:focus,
.form-control:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(47, 107, 69, .12);
}

.search-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    color: var(--primary);
    pointer-events: none;
}

.search-icon::before,
.search-icon::after {
    content: '';
    position: absolute;
    display: block;
}

.search-icon::before {
    width: 11px;
    height: 11px;
    border: 2px solid currentColor;
    border-radius: 50%;
    top: 0;
    left: 0;
}

.search-icon::after {
    width: 8px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transform: rotate(45deg);
    right: 1px;
    bottom: 2px;
}

.filter-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.filter-btn,
.btn {
    border: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 11px 18px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
}

.filter-btn {
    background: rgba(255,255,255,.84);
    border: 1px solid var(--border);
    color: var(--text-soft);
}

.filter-btn:hover,
.filter-btn.active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 10px 24px rgba(47,107,69,.2);
}

.btn:hover:not(:disabled),
.filter-btn:hover {
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    box-shadow: 0 14px 28px rgba(47, 107, 69, .24);
}

.btn-secondary {
    color: var(--primary-strong);
    background: rgba(255,255,255,.9);
    border: 1px solid var(--border);
}

.btn-success {
    color: #fff;
    background: linear-gradient(135deg, var(--success), #62a36b);
    box-shadow: 0 14px 28px rgba(47, 125, 75, .25);
}

.btn-danger {
    color: #fff;
    background: linear-gradient(135deg, var(--danger), #8f332f);
}

.btn-warning {
    color: #fff;
    background: linear-gradient(135deg, var(--warning), var(--accent));
}

.btn-sm {
    min-height: 38px;
    padding: 8px 14px;
    font-size: .88rem;
}

.btn-block {
    width: 100%;
}

.actions-compact {
    margin-top: 0;
}

.actions-center {
    justify-content: center;
}

.table-container,
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(255,255,255,.9);
}

.table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 16px 18px;
    vertical-align: middle;
}

.table thead th {
    color: var(--primary-soft);
    background: var(--primary-strong);
    font-size: .76rem;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition), transform var(--transition);
}

.table tbody tr:last-child {
    border-bottom: 0;
}

.table tbody tr:hover {
    background: var(--bg-soft);
}

.table tbody tr.is-clickable {
    cursor: pointer;
}

.table tbody tr.is-clickable:hover {
    background: var(--primary-soft);
}

.table tbody tr.is-available td:first-child {
    box-shadow: inset 4px 0 0 rgba(47, 125, 75, .55);
}

.table tbody tr.is-booked {
    color: var(--text-soft);
    background: rgba(242, 234, 220, .72);
}

.table tbody tr.is-booked:hover {
    background: rgba(232, 221, 202, .9);
}

.table tbody tr.is-booked td:first-child {
    box-shadow: inset 4px 0 0 rgba(166, 106, 33, .52);
}

.table tbody tr.is-booked td:first-child strong {
    color: var(--text-soft);
}

.table tbody tr.is-completed {
    background: rgba(231, 240, 246, .56);
}

.table tbody tr.is-completed td:first-child {
    box-shadow: inset 4px 0 0 rgba(49, 95, 134, .4);
}

.table small,
.cell-muted {
    color: var(--text-soft);
}

.status-badge,
.week-status,
.availability,
.week-duration {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 6px 11px;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.status-libero,
.week-status.available,
.availability {
    color: var(--success);
    background: var(--success-soft);
}

.status-prenotato,
.week-status.booked {
    color: #fff;
    background: linear-gradient(135deg, #8a551d, var(--warning));
}

.status-completato {
    color: var(--info);
    background: var(--info-soft);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    font-size: .82rem;
    font-weight: 800;
}

.loading,
.empty-state {
    text-align: center;
    color: var(--text-soft);
    padding: 42px 18px;
}

.spinner,
.loading::after {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid var(--surface-muted);
    border-top-color: var(--primary);
    animation: spin 900ms linear infinite;
    display: block;
    margin: 0 auto 16px;
    content: '';
}

.loading::after {
    margin: 14px auto 0;
}

.error-message,
.alert {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 14px 16px;
    margin-bottom: 16px;
    animation: slideDown 260ms var(--ease) both;
}

.alert-success {
    color: var(--success);
    background: var(--success-soft);
    border-color: rgba(47,125,75,.25);
}

.alert-error,
.alert-danger,
.error-message {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: rgba(181,71,63,.24);
}

.alert-info {
    color: var(--info);
    background: var(--info-soft);
    border-color: rgba(49,95,134,.2);
}

.progress-container {
    padding: clamp(18px, 3vw, 28px);
    margin-bottom: 22px;
}

.progress-bar {
    position: relative;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: start;
    gap: 12px;
    max-width: 720px;
    margin: 0 auto;
}

.progress-line {
    position: absolute;
    top: 22px;
    left: 12.5%;
    right: 12.5%;
    height: 4px;
    background: var(--surface-muted);
    border-radius: 999px;
    overflow: hidden;
}

.progress-line-active {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: inherit;
    transition: width 420ms var(--ease);
}

.step {
    position: relative;
    z-index: 1;
    display: grid;
    justify-items: center;
    gap: 9px;
    text-align: center;
    color: var(--muted);
    font-weight: 800;
}

.step-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    border: 2px solid var(--border);
    background: #fff;
    transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.step.active .step-circle,
.step.completed .step-circle {
    color: #fff;
    border-color: transparent;
    background: var(--primary);
    box-shadow: 0 12px 28px rgba(47,107,69,.22);
}

.step.active .step-circle {
    transform: scale(1.06);
}

.step.completed .step-circle {
    background: var(--success);
}

.step.active,
.step.completed {
    color: var(--primary-strong);
}

.step-content {
    display: none;
}

.step-content.active {
    display: block;
    animation: riseIn 380ms var(--ease) both;
}

.weeks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.week-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    background: rgba(255,255,255,.86);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition);
    animation: riseIn 420ms var(--ease) both;
}

button.week-card {
    width: 100%;
    padding-right: 58px;
    color: inherit;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    appearance: none;
}

.week-selected-mark {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--primary);
    box-shadow: 0 10px 22px rgba(47,107,69,.24);
    opacity: 0;
    transform: scale(.78);
    transition: opacity var(--transition), transform var(--transition);
}

.week-selected-mark::before {
    content: '';
    width: 11px;
    height: 6px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translate(1px, -1px);
}

.week-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition);
}

.week-card:hover,
.week-card.selected {
    transform: translateY(-4px);
    border-color: rgba(47,107,69,.42);
    box-shadow: var(--shadow-md);
    background: #fff;
}

.week-card:hover::before,
.week-card.selected::before {
    transform: scaleX(1);
}

.week-card.selected {
    outline: 4px solid rgba(47,107,69,.12);
}

.week-card.selected .week-selected-mark {
    opacity: 1;
    transform: scale(1);
}

.week-dates {
    color: var(--primary-strong);
    font-weight: 800;
    font-size: 1.05rem;
    margin-bottom: 12px;
}

.week-duration {
    color: var(--primary);
    background: var(--primary-soft);
    margin-bottom: 12px;
}

.week-description,
.week-booked-by {
    color: var(--text-soft);
}

.form-section {
    margin-bottom: 24px;
}

.form-section h3 {
    margin-bottom: 16px;
    color: var(--primary-strong);
    font-size: 1.25rem;
}

.form-row,
.form-grid,
.add-week-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.add-week-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: end;
}

.form-group {
    display: grid;
    gap: 8px;
}

.form-group label {
    color: var(--primary-strong);
    font-weight: 800;
    font-size: .92rem;
}

.form-control[type='date'],
.form-control[type='password'],
.form-control[type='text'],
.form-control[type='email'] {
    border-radius: var(--radius-md);
}

.selected-week-banner,
.confirmation-summary,
.booking-info {
    border-radius: var(--radius-md);
    border: 1px solid rgba(47,107,69,.18);
    background: linear-gradient(135deg, var(--primary-soft), rgba(255,255,255,.88));
    padding: 18px;
    margin-bottom: 18px;
}

.selected-week-banner h3,
.confirmation-summary h3 {
    color: var(--primary-strong);
    margin-bottom: 8px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 13px 0;
    border-bottom: 1px solid rgba(222,213,197,.82);
}

.summary-item:last-child {
    border-bottom: 0;
}

.summary-label {
    color: var(--text-soft);
    font-weight: 800;
}

.summary-value {
    color: var(--text);
    font-weight: 800;
    text-align: right;
    overflow-wrap: anywhere;
}

.actions-row,
.navigation {
    justify-content: space-between;
    margin-top: 24px;
}

.success-animation {
    position: relative;
    overflow: hidden;
    text-align: center;
    padding: clamp(30px, 6vw, 58px) 18px;
}

.success-animation::before,
.success-animation::after {
    content: '';
    position: absolute;
    inset: 20% 12%;
    pointer-events: none;
    background:
        radial-gradient(circle, rgba(216,145,60,.78) 0 3px, transparent 4px),
        radial-gradient(circle, rgba(47,107,69,.72) 0 3px, transparent 4px),
        radial-gradient(circle, rgba(49,95,134,.54) 0 2px, transparent 3px);
    background-size: 78px 78px, 108px 108px, 62px 62px;
    background-position: 6px 12px, 42px 18px, 18px 44px;
    opacity: 0;
    animation: sparkle 980ms var(--ease) 180ms both;
}

.success-icon {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--success), #77b66d);
    box-shadow: 0 18px 42px rgba(47,125,75,.28);
    animation: successPop 700ms var(--ease) both;
}

.success-icon::before {
    content: '';
    width: 30px;
    height: 16px;
    border-left: 5px solid #fff;
    border-bottom: 5px solid #fff;
    transform: rotate(-45deg) translate(2px, -2px);
    border-radius: 3px;
}

.success-animation h2 {
    color: var(--primary-strong);
    font-family: 'Fraunces', Georgia, serif;
    font-size: clamp(1.7rem, 4vw, 2.8rem);
    letter-spacing: -.035em;
    margin-bottom: 10px;
}

.success-animation p {
    max-width: 620px;
    margin: 0 auto 10px;
    color: var(--text-soft);
}

.login-card {
    width: min(460px, 100%);
    margin: 0 auto;
    padding: clamp(24px, 5vw, 38px);
}

.admin-panel {
    display: none;
}

.admin-section h2 {
    color: var(--primary-strong);
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

@keyframes sparkle {
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

@keyframes successPop {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.08);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

    .controls-panel {
        grid-template-columns: 1fr;
    }

    .filter-group {
        justify-content: center;
        width: 100%;
    }

    .form-row,
    .form-grid {
        grid-template-columns: 1fr;
    }
}
