/*
    WhatsApp Link Generator – Utility Page
    ══════════════════════════════════════════════════
    Parte della sezione "Lab & Utility" di AttilioViscido.it

    DESIGN SYSTEM:
    Stesso design token block delle altre utility.
*/

:root {
    --primary: #076FB7;
    --primary-light: #2A8CD4;
    --accent: #D3B574;
    --accent-hover: #b89a57;
    --dark-bg: #0D1117;
    --card-bg: #161B22;
    --card-border: rgba(211, 181, 116, 0.15);
    --text-main: #c9d1d9;
    --text-white: #ffffff;
    --text-muted: #8b949e;
    --error: #f85149;
    --success: #3fb950;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--dark-bg);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* ── Animated background ────────────────────────── */
.bg-grid {
    position: fixed;
    inset: 0; z-index: 0;
    background-image:
        linear-gradient(rgba(7, 111, 183, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(7, 111, 183, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.18;
    pointer-events: none;
    z-index: 0;
    animation: driftGlow 18s ease-in-out infinite alternate;
}

.glow-1 {
    width: 500px; height: 500px;
    background: var(--primary);
    top: -100px; right: -100px;
    animation-delay: 0s;
}

.glow-2 {
    width: 400px; height: 400px;
    background: var(--accent);
    bottom: -80px; left: -80px;
    animation-delay: -9s;
    opacity: 0.1;
}

@keyframes driftGlow {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-40px, 40px) scale(1.1); }
    100% { transform: translate(40px, -20px) scale(0.95); }
}

/* ── Compact Site Header ────────────────────────── */
.site-header {
    position: fixed; top: 0; left: 0; width: 100%; z-index: 100;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.site-header-inner {
    max-width: 900px; margin: 0 auto; padding: 0 24px;
    height: 60px; display: flex; align-items: center; justify-content: space-between;
}
.back-link {
    display: flex; align-items: center; gap: 12px;
    text-decoration: none; color: var(--text-main); font-weight: 600;
    transition: var(--transition);
}
.back-link:hover { color: var(--accent); }
.back-link i { font-size: 0.9rem; opacity: 0.7; transition: var(--transition); }
.back-link:hover i { transform: translateX(-3px); opacity: 1; }
.logo-text { font-size: 1.1rem; font-weight: 800; color: var(--text-white); }
.logo-dot { color: var(--accent); }
.breadcrumb {
    display: flex; align-items: center; gap: 8px; font-size: 0.82rem;
    color: var(--text-muted); background: rgba(255, 255, 255, 0.05);
    padding: 5px 14px; border-radius: 20px; border: 1px solid rgba(255, 255, 255, 0.07);
}
.breadcrumb i { color: var(--accent); font-size: 0.8rem; }

/* ── Main Wrapper ───────────────────────────────── */
.app-wrapper {
    position: relative; z-index: 1; width: 100%; max-width: 600px;
    padding: 90px 20px 40px; display: flex; flex-direction: column;
    align-items: center; gap: 16px;
}

/* ── App Card ───────────────────────────────────── */
.app-card {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 24px; padding: 36px; width: 100%; display: flex;
    flex-direction: column; gap: 28px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    animation: slideUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── App Header ─────────────────────────────────── */
.app-header { display: flex; align-items: center; gap: 16px; position: relative; }
.app-icon-wrap {
    width: 52px; height: 52px;
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: #fff; font-size: 1.8rem; border-radius: 14px; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
    box-shadow: 0 8px 20px rgba(37, 211, 102, 0.3);
}
.app-header h1 { font-size: 1.6rem; font-weight: 800; color: var(--text-white); line-height: 1.2; }
.app-subtitle { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.reset-btn {
    margin-left: auto; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted); cursor: pointer; padding: 9px; border-radius: 10px;
    display: flex; justify-content: center; align-items: center; transition: var(--transition); flex-shrink: 0;
}
.reset-btn:hover {
    color: var(--accent); background: rgba(211, 181, 116, 0.1); border-color: var(--accent);
}

/* ── Form Inputs ────────────────────────────────── */
.controls-section { display: flex; flex-direction: column; gap: 20px; }
.input-group { display: flex; flex-direction: column; gap: 8px; }
.input-label {
    font-size: 0.85rem; font-weight: 600; color: var(--text-muted);
    letter-spacing: 0.03em; text-transform: uppercase;
    display: flex; align-items: center; gap: 8px;
}
.input-label i { color: var(--primary-light); }

.phone-input-wrap {
    display: flex; gap: 10px; width: 100%; position: relative;
}

/* Custom dropdown prefisso */
.custom-select-wrap {
    position: relative; width: 125px; flex-shrink: 0;
}
.custom-select-trigger {
    width: 100%; height: 50px; background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px;
    padding: 0 14px; display: flex; align-items: center; justify-content: space-between;
    cursor: pointer; color: var(--text-white); font-family: 'Outfit', sans-serif;
    font-size: 0.95rem; font-weight: 600; transition: var(--transition);
}
.custom-select-trigger:hover, .custom-select-trigger:focus {
    border-color: var(--primary); background: rgba(0, 0, 0, 0.4);
    outline: none; box-shadow: 0 0 0 3px rgba(7, 111, 183, 0.15);
}
.flag-icon {
    width: 20px; height: 15px; object-fit: cover; border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.select-arrow {
    font-size: 0.75rem; color: var(--text-muted); transition: transform 0.3s ease;
}
.custom-select-wrap.open .select-arrow {
    transform: rotate(180deg);
}

.custom-select-options-wrap {
    position: absolute; top: calc(100% + 8px); left: 0; width: 260px;
    background: #161B22; border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px; box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
    z-index: 100; display: none; flex-direction: column; overflow: hidden;
    animation: dropdownFade 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.custom-select-wrap.open .custom-select-options-wrap {
    display: flex;
}
@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.custom-select-search-wrap {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.2);
}
.search-icon { font-size: 0.8rem; color: var(--text-muted); }
.custom-select-search-wrap input {
    flex: 1; background: transparent; border: none; outline: none;
    color: var(--text-white); font-family: 'Outfit', sans-serif;
    font-size: 0.85rem; padding: 2px 0;
}

.custom-select-options {
    max-height: 220px; overflow-y: auto; list-style: none;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.custom-select-options::-webkit-scrollbar {
    width: 6px;
}
.custom-select-options::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1); border-radius: 3px;
}
.custom-select-option {
    padding: 10px 14px; display: flex; align-items: center; gap: 10px;
    cursor: pointer; transition: var(--transition); color: var(--text-main);
    font-size: 0.88rem;
}
.custom-select-option:hover {
    background: rgba(7, 111, 183, 0.15); color: var(--text-white);
}
.custom-select-option.selected {
    background: rgba(7, 111, 183, 0.3); color: var(--text-white); font-weight: 600;
}
.custom-select-option.hidden {
    display: none !important;
}
.country-prefix {
    margin-left: auto; color: var(--text-muted); font-size: 0.8rem; font-weight: 600;
}

/* Input numero */
.phone-input {
    flex: 1; height: 50px; background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px;
    padding: 0 16px; color: var(--text-white); font-family: monospace;
    font-size: 1.15rem; font-weight: 600; letter-spacing: 0.05em;
    transition: var(--transition);
}
.phone-input:hover, .phone-input:focus {
    border-color: var(--primary); background: rgba(0, 0, 0, 0.4);
    outline: none; box-shadow: 0 0 0 3px rgba(7, 111, 183, 0.15);
}
.phone-input::placeholder {
    color: var(--text-muted); font-family: 'Outfit', sans-serif;
    font-size: 1rem; font-weight: 400; letter-spacing: normal;
}
.error-message {
    color: var(--error); font-size: 0.82rem; font-weight: 600;
    margin-top: 4px; display: flex; align-items: center; gap: 6px;
}
.error-message[hidden] {
    display: none;
}
.error-message::before {
    content: "\f071"; font-family: "Font Awesome 6 Free"; font-weight: 900;
}

/* Messaggio precompilato */
.label-header { display: flex; justify-content: space-between; align-items: center; }
.char-counter { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }
.message-input {
    background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px; padding: 12px 16px; color: var(--text-white);
    font-family: 'Outfit', sans-serif; font-size: 0.95rem; line-height: 1.5;
    resize: none; transition: var(--transition); width: 100%;
}
.message-input:hover, .message-input:focus {
    border-color: var(--primary); background: rgba(0, 0, 0, 0.4);
    outline: none; box-shadow: 0 0 0 3px rgba(7, 111, 183, 0.15);
}

/* Bottoni */
.action-row { display: flex; }
.generate-btn {
    width: 100%; background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white; border: none; border-radius: 12px; padding: 15px;
    font-family: 'Outfit', sans-serif; font-size: 1rem; font-weight: 700; cursor: pointer;
    display: flex; justify-content: center; align-items: center; gap: 10px;
    transition: var(--transition); box-shadow: 0 6px 20px rgba(7, 111, 183, 0.35);
}
.generate-btn:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    transform: translateY(-2px); box-shadow: 0 10px 30px rgba(7, 111, 183, 0.5);
}
.generate-btn:active {
    transform: translateY(1px); box-shadow: 0 4px 12px rgba(7, 111, 183, 0.3);
}

/* ── Result Section ─────────────────────────────── */
.result-section {
    border-top: 1px solid rgba(255, 255, 255, 0.06); padding-top: 25px;
    display: flex; flex-direction: column; gap: 16px;
    animation: fadeIn 0.4s ease both;
}
.result-section.hidden { display: none; }

.format-label {
    font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
    letter-spacing: 0.03em; text-transform: uppercase;
    display: flex; align-items: center; gap: 8px;
}
.format-label i { color: var(--accent); }

.link-display-wrap {
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px; padding: 14px 16px; gap: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2) inset;
}
.link-display {
    flex: 1; font-family: monospace; font-size: 0.92rem;
    color: var(--accent); word-break: break-all;
    user-select: all; overflow-x: auto; white-space: nowrap;
    scrollbar-width: none;
}
.link-display::-webkit-scrollbar { display: none; }

.copy-btn {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-muted); font-size: 1rem; cursor: pointer;
    transition: var(--transition); border-radius: 8px; width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.copy-btn:hover {
    color: var(--text-white); background: rgba(7, 111, 183, 0.4); border-color: var(--primary);
    transform: translateY(-2px); box-shadow: 0 4px 12px rgba(7, 111, 183, 0.3);
}

.result-actions-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.action-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 13px 20px; border: none; border-radius: 12px; font-family: 'Outfit', sans-serif;
    font-size: 0.95rem; font-weight: 700; cursor: pointer; text-decoration: none;
    transition: var(--transition); letter-spacing: 0.02em;
}
.action-btn--primary {
    background: linear-gradient(135deg, #25D366, #128C7E); color: #ffffff;
    box-shadow: 0 6px 18px rgba(37, 211, 102, 0.25);
}
.action-btn--primary:hover {
    background: linear-gradient(135deg, #2ae771, #159f90);
    transform: translateY(-2px); box-shadow: 0 10px 24px rgba(37, 211, 102, 0.4);
}
.action-btn--accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: #0D1117;
    box-shadow: 0 6px 18px rgba(211, 181, 116, 0.25);
}
.action-btn--accent:hover {
    transform: translateY(-2px); box-shadow: 0 10px 24px rgba(211, 181, 116, 0.4);
}

/* ── Success Toast ──────────────────────────────── */
.success-toast {
    display: flex; align-items: center; gap: 12px;
    background: rgba(63, 185, 80, 0.12); border: 1px solid rgba(63, 185, 80, 0.3);
    border-radius: 10px; padding: 12px 16px; font-size: 0.9rem; font-weight: 600;
    color: var(--success); animation: fadeIn 0.4s ease;
}
.success-toast.hidden { display: none !important; }
.success-toast i { font-size: 1.1rem; }

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

/* ── Modale (QR Code) ────────────────────────────── */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.75);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 1000;
    display: flex; justify-content: center; align-items: center;
    opacity: 1; transition: var(--transition);
}
.modal-overlay.hidden { opacity: 0; pointer-events: none; }

.modal-content {
    background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 20px;
    padding: 32px; width: 90%; max-width: 440px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    display: flex; flex-direction: column; gap: 16px; transform: translateY(0) scale(1);
    transition: var(--transition);
}
.modal-overlay.hidden .modal-content { transform: translateY(24px) scale(0.95); }

.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.3rem; color: var(--text-white); display: flex; align-items: center; gap: 10px; }
.modal-header h3 i { color: var(--accent); }
.modal-close {
    background: transparent; border: none; color: var(--text-muted); font-size: 1.6rem;
    cursor: pointer; line-height: 1; transition: var(--transition);
}
.modal-close:hover { color: var(--text-white); }

.modal-intro { font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; }

.qr-container-wrap {
    display: flex; justify-content: center; align-items: center;
    background: #ffffff; padding: 24px; border-radius: 16px;
    width: 200px; height: 200px; margin: 10px auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
#qrcode img {
    display: block; width: 152px !important; height: 152px !important;
}

.modal-actions { display: flex; justify-content: center; margin-top: 8px; }
.confirm-btn {
    width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 13px 20px; border-radius: 12px; font-family: 'Outfit', sans-serif;
    font-weight: 700; font-size: 0.95rem; cursor: pointer; transition: var(--transition);
    background: var(--primary); border: 1px solid var(--primary); color: var(--text-white);
    box-shadow: 0 4px 15px rgba(7, 111, 183, 0.3);
}
.confirm-btn:hover {
    background: var(--primary-light); border-color: var(--primary-light);
    transform: translateY(-1px); box-shadow: 0 6px 20px rgba(7, 111, 183, 0.4);
}

/* Privacy Note */
.privacy-note {
    font-size: 0.78rem; color: var(--text-muted); opacity: 0.6;
    display: flex; align-items: center; gap: 6px; text-align: center;
    line-height: 1.4; padding: 0 10px;
}
.privacy-note i { color: var(--accent); opacity: 0.8; }

/* ── Responsive adjustments ─────────────────────── */
@media (max-width: 520px) {
    .app-card { padding: 28px 20px; border-radius: 20px; gap: 22px; }
    .app-header h1 { font-size: 1.35rem; }
    .site-header-inner { padding: 0 16px; }
    .breadcrumb { display: none; }
    .result-actions-grid { grid-template-columns: 1fr; }
    .phone-input { font-size: 1.05rem; }
    .custom-select-wrap { width: 110px; }
    .custom-select-trigger { padding: 0 10px; font-size: 0.9rem; }
    .custom-select-options-wrap { width: 220px; }
}
