/* ============================================================
   COMPAGNI DI VIAGGIO — Old Twitter Style
   Spartan • Minimal • Elegant • Feed-First
   ============================================================ */

/* --- 1. VARIABILI --- */
:root {
    --tw-blue: #1d9bf0;
    --tw-blue-hover: #1a8cd8;
    --tw-blue-light: #e8f5fd;
    --tw-text: #0f1419;
    --tw-text-secondary: #536471;
    --tw-border: #eff3f4;
    --tw-bg: #ffffff;
    --tw-hover: #f7f7f7;
    --tw-red: #f4212e;
    --tw-red-light: #fce8e8;
    --tw-green: #00ba7c;
    --tw-yellow: #ffad1f;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --transition-fast: 0.15s ease;
    --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- 2. RESET & BASE --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    background: var(--tw-bg);
    color: var(--tw-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

a { color: var(--tw-blue); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--tw-blue-hover); }

/* --- 3. HEADER (Fixed, Thin, Twitter-style) --- */
.header-tw {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--tw-border);
    height: 53px;
}

.header-tw-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 16px;
}

.header-tw-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--tw-text);
    letter-spacing: -0.3px;
}

.header-tw-logo a {
    color: var(--tw-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-tw-logo a:hover { color: var(--tw-text); }

.header-tw-logo .logo-emoji { font-size: 1.4rem; }

.header-tw-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-tw .btn-login {
    background: var(--tw-blue);
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    white-space: nowrap;
}

.header-tw .btn-login:hover { background: var(--tw-blue-hover); }

.header-tw .user-greeting {
    font-size: 0.875rem;
    color: var(--tw-text-secondary);
}

.header-tw .btn-dash {
    background: var(--tw-text);
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: opacity var(--transition-fast);
}

.header-tw .btn-dash:hover { opacity: 0.85; color: #fff; }

.header-tw .btn-logout {
    color: var(--tw-text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    transition: color var(--transition-fast);
}

.header-tw .btn-logout:hover { color: var(--tw-red); }

/* --- 4. APP LAYOUT (2 colonne) --- */
.app-layout {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    gap: 30px;
    padding: 12px 16px 40px;
    min-height: calc(100vh - 53px - 60px);
}

/* --- 5. MAIN FEED --- */
.main-feed {
    flex: 1;
    max-width: 720px;
    min-width: 0;
}

/* --- 6. COMPOSE BOX (Stile Twitter) --- */
.compose-card {
    background: linear-gradient(135deg, #f0f7ff 0%, #ffffff 40%);
    border: 1px solid #cce4fc;
    border-left: 4px solid var(--tw-blue);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(29, 155, 240, 0.06);
    transition: border-color var(--transition-fast), box-shadow var(--transition-smooth), background var(--transition-smooth);
}

.compose-card:focus-within {
    border-color: var(--tw-blue);
    border-left-color: var(--tw-blue);
    box-shadow: 0 0 0 3px rgba(29, 155, 240, 0.1), 0 4px 16px rgba(29, 155, 240, 0.08);
    background: #ffffff;
}

.compose-card h3 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--tw-blue);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.2px;
}

.compose-card .compose-body {
    display: flex;
    gap: 12px;
}

.compose-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tw-blue), #0d8bd9);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(29, 155, 240, 0.25);
}

.compose-form { flex: 1; min-width: 0; }

.compose-form input,
.compose-form textarea {
    width: 100%;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 1.1rem;
    color: var(--tw-text);
    background: transparent;
    resize: none;
    padding: 0;
    transition: all var(--transition-fast);
}

.compose-form input::placeholder,
.compose-form textarea::placeholder {
    color: var(--tw-text-secondary);
    opacity: 0.7;
}

.compose-form input {
    font-weight: 600;
    margin-bottom: 6px;
}

.compose-form textarea { font-weight: 400; min-height: 40px; }

.compose-form .compose-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.compose-form .compose-row input {
    flex: 1;
    font-weight: 400;
    font-size: 0.9rem;
    background: var(--tw-hover);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    transition: background var(--transition-fast);
}

.compose-form .compose-row input:focus {
    background: var(--tw-bg);
    box-shadow: 0 0 0 1px var(--tw-blue);
}

.compose-form .compose-row input[type="number"] { max-width: 180px; }

#counter {
    font-size: 0.75rem;
    color: var(--tw-text-secondary);
    text-align: right;
    margin-top: 4px;
    transition: color var(--transition-fast);
}

.compose-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #dae8f5;
}

.compose-notice {
    font-size: 0.75rem;
    color: var(--tw-text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: 55%;
    line-height: 1.4;
}

.btn-tweet {
    background: var(--tw-blue);
    color: #fff;
    border: none;
    padding: 11px 28px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-smooth);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(29, 155, 240, 0.3);
}

.btn-tweet:hover {
    background: var(--tw-blue-hover);
    box-shadow: 0 4px 14px rgba(29, 155, 240, 0.4);
    transform: translateY(-1px);
}

.btn-tweet:active { transform: scale(0.96) translateY(0); }

/* --- 7. FEED HERO (Sottile, elegante) --- */
.feed-hero {
    padding: 12px 0 4px 0;
    text-align: center;
    border-bottom: 1px solid var(--tw-border);
    margin-bottom: 0;
}

.feed-hero h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--tw-text);
    margin: 0;
}

.feed-hero p {
    font-size: 0.85rem;
    color: var(--tw-text-secondary);
    margin: 2px 0 0 0;
}

/* --- 8. FEED HEADER --- */
.feed-header {
    padding: 12px 0 4px 0;
    border-bottom: 1px solid var(--tw-border);
}

.feed-header h2 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--tw-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

/* --- 9. ANNUNCIO CARD (Twitter Tweet Style) --- */
.annuncio {
    background: var(--tw-bg);
    border: 1px solid var(--tw-border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 10px;
    cursor: default;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    position: relative;
}

.annuncio:hover {
    background: var(--tw-hover);
    border-color: #d4d8db;
}

.badge-new {
    background: var(--tw-blue);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    position: absolute;
    top: 12px;
    right: 16px;
    letter-spacing: 0.3px;
    animation: badgePopIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes badgePopIn {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.meta-info {
    font-size: 0.85rem;
    color: var(--tw-text-secondary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.meta-info strong {
    color: var(--tw-text);
    font-weight: 700;
}

.meta-tag {
    background: var(--tw-hover);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    color: var(--tw-text-secondary);
    font-weight: 500;
    transition: background var(--transition-fast);
}

.testo-annuncio {
    font-size: 1rem;
    color: var(--tw-text);
    line-height: 1.5;
    margin: 8px 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.footer-annuncio {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--tw-border);
}

.footer-annuncio .budget {
    font-weight: 700;
    font-size: 0.9rem;
}

.btn-contact {
    background: transparent;
    color: var(--tw-blue);
    border: 1px solid var(--tw-blue);
    padding: 7px 20px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-contact:hover {
    background: var(--tw-blue-light);
    border-color: var(--tw-blue);
    color: var(--tw-blue-hover);
}

.btn-contact:active { transform: scale(0.96); }

/* --- 10. ERROR / EMPTY BANNER --- */
.feed-alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin: 12px 0;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    animation: slideDown 0.25s ease;
}

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

.feed-alert-warning {
    background: #fff5e6;
    color: #a65f00;
    border: 1px solid #ffe0b3;
}

.feed-alert-empty {
    color: var(--tw-text-secondary);
    padding: 32px 16px;
}

/* --- 11. PAGINATION --- */
.pagination-tw {
    text-align: center;
    padding: 16px 0;
}

.btn-load-more {
    display: inline-block;
    background: transparent;
    color: var(--tw-blue);
    border: 1px solid var(--tw-border);
    padding: 10px 28px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.btn-load-more:hover {
    background: var(--tw-blue-light);
    border-color: var(--tw-blue);
}

.btn-load-more:active { transform: scale(0.97); }

.btn-load-more.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* --- 12. SIDE PANEL (Destra) --- */
.side-panel {
    width: 350px;
    flex-shrink: 0;
    position: sticky;
    top: 65px;
    align-self: flex-start;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--tw-border) transparent;
}

.side-card {
    background: var(--tw-hover);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    transition: border-color var(--transition-fast), background var(--transition-smooth);
}

.side-card:hover {
    border-color: var(--tw-border);
    background: var(--tw-bg);
}

.side-card h4 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--tw-text);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* --- 13. SEARCH BOX (Side Panel) --- */
.search-box-tw {
    display: flex;
    align-items: center;
    background: var(--tw-bg);
    border: 1px solid var(--tw-border);
    border-radius: var(--radius-full);
    padding: 0 16px;
    transition: all var(--transition-fast);
}

.search-box-tw:focus-within {
    border-color: var(--tw-blue);
    box-shadow: 0 0 0 1px var(--tw-blue);
    background: var(--tw-bg);
}

.search-box-tw .search-icon {
    color: var(--tw-text-secondary);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.search-box-tw input {
    width: 100%;
    border: none;
    outline: none;
    padding: 12px 8px;
    font-family: inherit;
    font-size: 0.9rem;
    background: transparent;
    color: var(--tw-text);
}

.search-box-tw input::placeholder { color: var(--tw-text-secondary); }

/* --- 14. TAGS (Trends) --- */
.tag {
    display: inline-block;
    background: transparent;
    color: var(--tw-text);
    border: 1px solid var(--tw-border);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    margin: 3px 4px 3px 0;
    transition: all var(--transition-fast);
}

.tag:hover {
    background: var(--tw-blue-light);
    border-color: var(--tw-blue);
    color: var(--tw-blue);
}

.tag-active {
    background: var(--tw-blue);
    border-color: var(--tw-blue);
    color: #fff !important;
}

.tag-active:hover {
    background: var(--tw-blue-hover);
    border-color: var(--tw-blue-hover);
    color: #fff !important;
}

/* --- 15. SEASONAL TAGS --- */
.tag-stagionali .tag {
    background: var(--tw-bg);
}

/* --- 16. ABOUT CARD --- */
.side-card-about { font-size: 0.85rem; color: var(--tw-text-secondary); line-height: 1.6; }
.side-card-about a { font-weight: 600; }

/* --- 17. FOOTER --- */
.footer-tw {
    text-align: center;
    padding: 16px;
    color: var(--tw-text-secondary);
    font-size: 0.8rem;
    border-top: 1px solid var(--tw-border);
}

.footer-tw a { color: var(--tw-text-secondary); }
.footer-tw a:hover { color: var(--tw-blue); }

.footer-links { margin-top: 6px; }
.footer-links a { font-weight: 600; }

/* --- 18. MODALS --- */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal-dialog {
    background: var(--tw-bg);
    max-width: 440px;
    width: 90%;
    padding: 28px;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    position: relative;
    animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
    position: absolute;
    right: 16px;
    top: 12px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--tw-text-secondary);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background var(--transition-fast);
    border: none;
    background: transparent;
}

.modal-close:hover { background: var(--tw-hover); }

.modal-dialog h2 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--tw-text);
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-dialog .modal-subtitle {
    font-size: 0.85rem;
    color: var(--tw-text-secondary);
    margin-bottom: 20px;
}

.modal-dialog input,
.modal-dialog textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--tw-border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--tw-text);
    transition: all var(--transition-fast);
    margin-bottom: 12px;
    background: var(--tw-bg);
}

.modal-dialog input:focus,
.modal-dialog textarea:focus {
    outline: none;
    border-color: var(--tw-blue);
    box-shadow: 0 0 0 2px var(--tw-blue-light);
}

.modal-dialog textarea { resize: vertical; min-height: 100px; }

.modal-dialog .btn-modal {
    width: 100%;
    background: var(--tw-text);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-dialog .btn-modal:hover { opacity: 0.88; }
.modal-dialog .btn-modal:active { transform: scale(0.98); }

.modal-dialog .btn-modal.primary { background: var(--tw-blue); }
.modal-dialog .btn-modal.primary:hover { background: var(--tw-blue-hover); }

.modal-dialog .btn-modal.success { background: var(--tw-green); }

/* Modal Auth Tabs */
.auth-switch {
    text-align: center;
    margin-top: 16px;
    padding: 12px;
    background: var(--tw-hover);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--tw-text-secondary);
    line-height: 1.5;
}

.auth-switch strong { color: var(--tw-text); }

.auth-switch a {
    color: var(--tw-blue);
    font-weight: 700;
    cursor: pointer;
}

.auth-switch a:hover { text-decoration: underline; }

/* --- 19. SUCCESS MODAL --- */
.modal-success {
    background: var(--tw-bg);
    padding: 40px;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    animation: modalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-success .success-icon { font-size: 4rem; margin-bottom: 12px; }

.modal-success h2 {
    margin: 0 0 8px 0;
    color: var(--tw-text);
    font-size: 1.3rem;
}

.modal-success p {
    color: var(--tw-text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal-success button {
    background: var(--tw-blue);
    color: #fff;
    border: none;
    padding: 12px 30px;
    border-radius: var(--radius-full);
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    transition: background var(--transition-fast);
}

.modal-success button:hover { background: var(--tw-blue-hover); }

/* --- 20. FAB MOBILE --- */
.fab-mobile {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: var(--tw-blue);
    color: #fff;
    border-radius: 50%;
    font-size: 1.5rem;
    box-shadow: 0 4px 16px rgba(29, 155, 240, 0.4);
    z-index: 1000;
    text-decoration: none;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-smooth);
}

.fab-mobile:hover {
    background: var(--tw-blue-hover);
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(29, 155, 240, 0.5);
}

/* --- 21. TRANSITIONS & ANIMATIONS --- */
.annuncio {
    animation: feedItemIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Stagger animation for cards */
.annuncio:nth-child(1) { animation-delay: 0s; }
.annuncio:nth-child(2) { animation-delay: 0.05s; }
.annuncio:nth-child(3) { animation-delay: 0.1s; }
.annuncio:nth-child(4) { animation-delay: 0.15s; }
.annuncio:nth-child(5) { animation-delay: 0.2s; }
.annuncio:nth-child(n+6) { animation-delay: 0.25s; }

/* Smooth hover on all interactive elements */
input, textarea, button, a, select {
    transition: all var(--transition-fast);
}

/* --- 22. RESPONSIVE (Mobile) --- */
@media (max-width: 1024px) {
    .app-layout {
        flex-direction: column;
        gap: 0;
        padding: 0;
    }

    .main-feed {
        max-width: 100%;
    }

    .compose-card {
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: 4px solid var(--tw-blue);
        background: #f8fafd;
    }

    .annuncio {
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-bottom: 0;
        border-bottom: 1px solid var(--tw-border);
    }

    .side-panel {
        width: 100%;
        padding: 16px;
        position: static;
        max-height: none;
        overflow-y: visible;
    }

    .side-panel .side-card:first-child {
        border-top: 1px solid var(--tw-border);
        border-radius: 0;
        padding-top: 20px;
    }

    .header-tw-logo .tagline { display: none; }

    .fab-mobile { display: flex; }

    .feed-hero {
        padding: 12px 16px 4px;
    }

    .feed-header {
        padding: 12px 16px 4px;
    }

    .annuncio { padding: 14px 16px; }
}

@media (max-width: 500px) {
    .header-tw-inner { padding: 0 12px; }
    .header-tw-logo { font-size: 1.1rem; }
    .header-tw .btn-login { padding: 6px 16px; font-size: 0.8rem; }
    .header-tw .btn-dash { padding: 6px 16px; font-size: 0.8rem; }

    .compose-card { padding: 12px; }
    .compose-form .compose-row { flex-direction: column; }
    .compose-form .compose-row input[type="number"] { max-width: 100%; }

    .footer-annuncio { flex-direction: column; gap: 10px; align-items: flex-start; }
    .btn-contact { width: 100%; text-align: center; }
}
