/* ===================================
   BASE CSS - Stili condivisi tra tutti i temi
   =================================== */

/* Reset minimo */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Messaggi di errore */
.error-message {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    font-weight: 600;
    background: var(--error-bg, rgba(255, 107, 107, 0.15));
    color: var(--error-text, #ff6b6b);
    border: 1px solid var(--error-border, rgba(255, 107, 107, 0.3));
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px var(--error-shadow, rgba(255, 107, 107, 0.2));
}

/* Messaggi di successo */
.success-message {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    font-weight: 600;
    background: rgba(81, 207, 102, 0.15);
    color: #51cf66;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(81, 207, 102, 0.2);
}

/* Errori di validazione form */
.validation-error {
    color: #ff6b6b;
    font-size: 0.875rem;
    display: block;
    margin-top: 0.25rem;
}

/* Link per tornare indietro */
.back-link {
    display: inline-block;
    margin-top: 1rem;
    text-decoration: underline;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.back-link:hover {
    opacity: 1;
}

/* Footer base */
footer {
    padding: 2rem;
    text-align: center;
}

.footer-links a {
    opacity: 0.7;
    font-size: 0.875rem;
}

.motto {
    font-style: italic;
    opacity: 0.8;
    transition: opacity 0.5s;
}

/* ===================================
   PRIVACY PAGE OVERRIDES
   =================================== */
.privacy-page .hero,
.privacy-page .theme-selector,
.privacy-page footer {
    display: none;
}

.privacy-page .container {
    max-width: 800px;
    padding: 2rem;
}

.privacy-page .privacy-content {
    text-align: left;
    padding: 2rem;
    line-height: 1.6;
}

.privacy-page .privacy-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.privacy-page .privacy-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

/* ===================================
   SUCCESS PAGE ANIMATIONS
   =================================== */
.success-celebration {
    position: relative;
    padding: 2rem;
    border-radius: 20px;
    margin: 2rem 0;
    text-align: center;
}

.celebration-text {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.celebration-subtext {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Sparkle animations */
@keyframes sparkle {
    0%, 100% { opacity: 0; transform: scale(0.5); }
    50% { opacity: 1; transform: scale(1); }
}

.sparkle {
    position: absolute;
    font-size: 1.5rem;
    animation: sparkle 2s ease-in-out infinite;
}

.sparkle:nth-child(1) { top: 10%; left: 15%; animation-delay: 0s; }
.sparkle:nth-child(2) { top: 20%; right: 20%; animation-delay: 0.5s; }
.sparkle:nth-child(3) { bottom: 30%; left: 10%; animation-delay: 1s; }
.sparkle:nth-child(4) { bottom: 20%; right: 15%; animation-delay: 1.5s; }

/* ===================================
   DASHBOARD - Empty states
   =================================== */
.empty-state {
    text-align: center;
    padding: 2rem;
    opacity: 0.7;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state-text {
    font-size: 1rem;
}

/* ===================================
   FLOATING TOOLBAR - Privacy + Theme
   =================================== */
.floating-toolbar {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.theme-toggle-wrapper {
    position: relative;
}

.floating-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--toolbar-border, rgba(255, 255, 255, 0.1));
    background: var(--toolbar-bg, rgba(0, 0, 0, 0.6));
    backdrop-filter: blur(10px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px var(--toolbar-shadow, rgba(0, 0, 0, 0.3));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

.floating-button:hover {
    transform: scale(1.1);
    background: var(--toolbar-hover-bg, rgba(0, 0, 0, 0.75));
    border-color: var(--toolbar-hover-border, rgba(255, 255, 255, 0.2));
}

.floating-button-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.theme-popup {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    min-width: 180px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 0.5rem;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-popup.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.theme-popup button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
}

.theme-popup button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.theme-popup button.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.theme-popup button.active::after {
    content: '✓';
    margin-left: auto;
    font-size: 0.8rem;
    opacity: 0.8;
}

.theme-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.theme-name {
    font-weight: 500;
}

/* Selettore lingua (gemello del selettore tema) */
.language-toggle-wrapper {
    position: relative;
}

.language-popup {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    min-width: 180px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 0.5rem;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.language-popup.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.language-popup a {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
    text-decoration: none;
}

.language-popup a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.language-popup a.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.language-popup a.active::after {
    content: '✓';
    margin-left: auto;
    font-size: 0.8rem;
    opacity: 0.8;
}

.language-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.language-name {
    font-weight: 500;
}

/* ===================================
   MOTTO STYLES (legacy, kept for compatibility)
   =================================== */
.motto {
    font-style: italic;
    opacity: 0.9;
    transition: opacity 0.5s;
    font-size: 1.05rem;
    line-height: 1.7;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 1rem;
    font-weight: 500;
}

/* Motto inline - dentro il form della home */
.motto-inline {
    font-style: italic;
    opacity: 0.65;
    transition: opacity 0.5s;
    font-size: 0.9rem;
    line-height: 1.6;
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(128, 128, 128, 0.2);
}

/* ===================================
   BACK LINK STYLES
   =================================== */
.back-link {
    display: inline-block;
    margin-top: 1.5rem;
    padding: 0.75rem 1.25rem;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    background: var(--back-link-bg, rgba(255, 255, 255, 0.15));
    color: var(--back-link-text, inherit);
    border: 1px solid var(--back-link-border, transparent);
    transition: all 0.3s;
}

.back-link:hover {
    background: var(--back-link-hover-bg, rgba(255, 255, 255, 0.25));
    border-color: var(--back-link-hover-border, transparent);
    transform: translateX(-4px);
}

/* ===================================
   BUTTON LOADING STATE
   =================================== */
.primary-button.loading,
.card-action.loading,
.action-button.loading,
button.loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}

.primary-button.loading::after,
.card-action.loading::after,
.action-button.loading::after,
button.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: button-spin 0.8s linear infinite;
}

/* Nascondi il testo durante il loading */
.primary-button.loading,
.card-action.loading {
    color: transparent;
}

.action-button.loading .action-text,
.action-button.loading .action-icon {
    visibility: hidden;
}

@keyframes button-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===================================
   FORM FIELDS - Message and Name inputs
   =================================== */
.extra-fields {
    margin-top: 1rem;
    animation: fadeIn 0.3s ease-out;
}

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

.message-input,
.name-input {
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    border: 2px solid rgba(128, 128, 128, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: inherit;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s;
    margin-bottom: 0.5rem;
}

.message-input:focus,
.name-input:focus {
    outline: none;
    border-color: var(--primary, #FFAE42);
    background: rgba(255, 255, 255, 0.15);
}

.message-input {
    resize: vertical;
    min-height: 80px;
    max-height: 200px;
    line-height: 1.5;
}

.message-input::placeholder,
.name-input::placeholder {
    opacity: 0.6;
}

.char-counter {
    display: block;
    text-align: right;
    font-size: 0.85rem;
    opacity: 0.6;
    margin-bottom: 1rem;
}

.form-hint {
    display: block;
    font-size: 0.85rem;
    opacity: 0.6;
    margin-bottom: 1rem;
    font-style: italic;
}

/* Dashboard user email under displayName */
.user-email {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-top: 0.25rem;
}

/* ===================================
   CREDIT LANDING PAGE
   =================================== */

/* === Expired State === */
.link-expired-container {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 500px;
    margin: 0 auto;
}

.expired-visual {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 2rem;
}

.clock-icon {
    font-size: 4rem;
    position: relative;
    z-index: 2;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

.expired-rings {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ring {
    position: absolute;
    border: 2px solid currentColor;
    border-radius: 50%;
    opacity: 0;
    animation: ring-expand 2s ease-out infinite;
}

.ring-1 { width: 60px; height: 60px; margin: -30px 0 0 -30px; }
.ring-2 { width: 90px; height: 90px; margin: -45px 0 0 -45px; animation-delay: 0.5s; }
.ring-3 { width: 120px; height: 120px; margin: -60px 0 0 -60px; animation-delay: 1s; }

@keyframes ring-expand {
    0% { transform: scale(0.5); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}

.expired-title {
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.expired-description {
    font-size: 1.1rem;
    opacity: 0.8;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.expired-recovery {
    padding-top: 2rem;
    border-top: 1px solid rgba(128, 128, 128, 0.2);
}

.recovery-text {
    font-size: 1rem;
    opacity: 0.7;
    margin-bottom: 1.5rem;
}

.recovery-button {
    display: inline-block;
    text-decoration: none;
}

/* === Credit Celebration === */
.credit-landing {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
}

.credit-celebration {
    position: relative;
    text-align: center;
    padding: 2rem 1rem 3rem;
    margin-bottom: 2rem;
}

.confetti {
    position: absolute;
    font-size: 1.5rem;
    animation: confetti-fall 3s ease-in-out infinite;
    opacity: 0.8;
}

.confetti-1 { top: 0; left: 10%; animation-delay: 0s; }
.confetti-2 { top: 10%; right: 15%; animation-delay: 0.3s; }
.confetti-3 { top: 5%; left: 30%; animation-delay: 0.6s; }
.confetti-4 { top: 15%; right: 25%; animation-delay: 0.9s; }
.confetti-5 { top: 0; right: 10%; animation-delay: 1.2s; }

@keyframes confetti-fall {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.8; }
    50% { transform: translateY(20px) rotate(180deg); opacity: 1; }
}

.cheers-animation {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.beer-left {
    animation: cheers-left 1.5s ease-in-out infinite;
    display: inline-block;
}

.beer-right {
    animation: cheers-right 1.5s ease-in-out infinite;
    display: inline-block;
}

@keyframes cheers-left {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-20deg) translateX(-5px); }
}

@keyframes cheers-right {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(20deg) translateX(5px); }
}

.credit-headline {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.credit-subheadline {
    font-size: 1.2rem;
    opacity: 0.8;
}

/* === DisplayName Banner === */
.displayname-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
    border-radius: 16px;
    background: rgba(255, 174, 66, 0.12);
    border: 2px solid rgba(255, 174, 66, 0.3);
    animation: fadeIn 0.5s ease-out;
}

.banner-icon-wrapper {
    flex-shrink: 0;
}

.banner-wave {
    font-size: 1.8rem;
    display: block;
    animation: wave 1.5s ease-in-out infinite;
    transform-origin: 70% 70%;
}

@keyframes wave {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(20deg); }
    75% { transform: rotate(-10deg); }
}

.banner-content {
    flex: 1;
    min-width: 150px;
}

.banner-title {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.banner-subtitle {
    display: block;
    font-size: 0.85rem;
    opacity: 0.7;
}

.banner-form {
    flex: 1;
    min-width: 200px;
}

.banner-input-group {
    display: flex;
    gap: 0.5rem;
}

.banner-input {
    flex: 1;
    margin-bottom: 0;
}

.banner-save-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: none;
    background: rgba(255, 174, 66, 0.8);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.banner-save-btn:hover {
    background: rgba(255, 174, 66, 1);
    transform: scale(1.05);
}

/* === Credit Showcase Card === */
.credit-showcase {
    position: relative;
    border-radius: 24px;
    padding: 2rem;
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid currentColor;
    overflow: hidden;
}

.showcase-badge {
    position: absolute;
    top: -1px;
    right: 2rem;
    padding: 0.75rem 1.25rem;
    border-radius: 0 0 16px 16px;
    background: currentColor;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge-icon {
    font-size: 1.2rem;
}

.badge-text {
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.showcase-content {
    padding-top: 1rem;
}

.debtor-section {
    margin-bottom: 1.5rem;
}

.debtor-label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.debtor-name {
    font-size: clamp(1.5rem, 4vw, 2rem);
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.debtor-email {
    font-size: 0.9rem;
    opacity: 0.6;
}

.credit-message {
    position: relative;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.1);
    font-style: italic;
    font-size: 1.1rem;
    line-height: 1.6;
}

.quote-mark {
    font-size: 1.5rem;
    opacity: 0.4;
    font-style: normal;
}

.credit-meta {
    display: flex;
    justify-content: flex-end;
}

.credit-date {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    opacity: 0.7;
}

.date-icon {
    font-size: 1rem;
}

/* === Actions === */
.credit-actions {
    text-align: center;
}

.dashboard-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    text-decoration: none;
    min-width: 280px;
}

.cta-icon {
    font-size: 1.3rem;
}

.cta-text {
    font-size: 1.1rem;
}

/* === Responsive === */
@media (max-width: 600px) {
    .displayname-banner {
        flex-direction: column;
        text-align: center;
    }

    .banner-content {
        text-align: center;
    }

    .banner-form {
        width: 100%;
    }

    .showcase-badge {
        position: static;
        display: inline-flex;
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    .credit-showcase {
        padding-top: 1.5rem;
    }
}

/* ===================================
   UTILITIES
   =================================== */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
