/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Fonts */
    --font-primary: 'Inter', sans-serif;

    /* Theme Colors - Premium Glassmorphism */
    --bg-gradient: radial-gradient(circle at top right, #1e1b4b 0%, #020617 100%); /* Deep Indigo to Slate */
    --panel-bg: rgba(30, 41, 59, 0.65); /* Slate 800 with transparency */
    --panel-border: rgba(255, 255, 255, 0.15);
    --panel-shadow: rgba(0, 0, 0, 0.4);
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --accent-primary: #6366f1; /* Indigo */
    --accent-secondary: #a855f7; /* Purple */
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --accent-gradient-hover: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    --accent-success: #10b981; /* Emerald */
    --accent-warning: #f59e0b; /* Amber */
    --accent-danger: #ef4444; /* Rose */
    
    --input-bg: rgba(0, 0, 0, 0.25);
    --input-border: rgba(255, 255, 255, 0.1);
    --input-focus: rgba(99, 102, 241, 0.4);

    --border-radius-sm: 8px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --backdrop-blur: blur(16px);
}

/* Light Theme overrides */
[data-theme="light"] {
    --bg-gradient: radial-gradient(circle at 80% 10%, #f0f4f8 0%, #dbe2ef 80%);
    --panel-bg: rgba(255, 255, 255, 0.45);
    --panel-border: rgba(255, 255, 255, 0.6);
    --panel-shadow: rgba(0, 0, 0, 0.05);
    
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    
    --input-bg: rgba(255, 255, 255, 0.7);
    --input-border: rgba(0, 0, 0, 0.08);
    --input-focus: rgba(99, 102, 241, 0.2);
}

/* Weather-specific variations (dynamic accents based on weather state) */
.weather-sunny {
    --accent-primary: #f59e0b;
    --accent-gradient: linear-gradient(135deg, #f59e0b 0%, #e11d48 100%);
}
.weather-rainy {
    --accent-primary: #3b82f6;
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
}
.weather-snowy {
    --accent-primary: #38bdf8;
    --accent-gradient: linear-gradient(135deg, #e2e8f0 0%, #38bdf8 100%);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background 0.5s ease, color 0.3s ease;
    line-height: 1.6;
    font-size: 16px;
    font-weight: 400;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: var(--transition-smooth);
}
a:hover {
    filter: brightness(1.2);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

header {
    background: var(--panel-bg);
    border-bottom: 1px solid var(--panel-border);
    backdrop-filter: var(--backdrop-blur);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 30px var(--panel-shadow);
}

header .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}
.brand-section:hover h1 {
    filter: brightness(1.15);
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: white;
    font-size: 20px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.brand-title h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-title span {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    margin-top: -2px;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 24px;
}

.header-clock {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.header-time {
    font-size: 18px;
    font-weight: 700;
}

.header-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.quick-weather {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid var(--panel-border);
}

.quick-temp {
    font-weight: 700;
}

/* Theme Toggle Button */
.btn-theme-toggle {
    background: none;
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition-smooth);
    background: rgba(255, 255, 255, 0.03);
}

.btn-theme-toggle:hover {
    background: var(--panel-bg);
    transform: rotate(30deg);
}

/* Main Grid */
main {
    flex: 1;
    padding: 12px 0;
    width: 100%;
    /* No padding here - main-grid handles its own centering */
}

.main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    align-items: start;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    box-sizing: border-box;
}

@media (max-width: 1050px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    .right-sidebar {
        grid-column: 1;
        order: 2; /* Move widgets below tools on mobile */
    }
    .content-area {
        order: 1;
    }
}

@media (max-width: 850px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    .left-sidebar, .right-sidebar, .content-area {
        grid-column: 1;
    }
}

/* ==========================================================================
   GLASS PANELS (CARDS)
   ========================================================================== */
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius-md);
    padding: 32px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px var(--panel-shadow);
    transition: var(--transition-smooth);
}

.glass-panel:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .glass-panel:hover {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

.panel-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.3px;
    position: relative;
    padding-bottom: 8px;
}

.panel-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 3px;
    background: var(--accent-gradient);
    border-radius: 2px;
}

/* ==========================================================================
   WEATHER DASHBOARD
   ========================================================================== */
.widget-column {
    opacity: 0.85;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.widget-column:hover {
    opacity: 1;
}

.left-sidebar, .right-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.weather-widget {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.weather-header {
    text-align: center;
    padding: 10px 0;
}

.weather-temp-main {
    font-size: 48px;
    font-weight: 800;
    line-height: 1;
    margin: 8px 0;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

.weather-condition-text {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.weather-icon-lg {
    font-size: 40px;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

.weather-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.weather-data-card {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: var(--border-radius-sm);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: var(--transition-smooth);
}

[data-theme="light"] .weather-data-card {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.weather-data-card:hover {
    transform: translateY(-2px);
    background: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .weather-data-card:hover {
    background: rgba(255, 255, 255, 0.6);
}

.weather-data-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.weather-data-value {
    font-size: 16px;
    font-weight: 700;
}

.weather-sync-status {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 10px;
    border-top: 1px solid var(--panel-border);
    padding-top: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.weather-offline-badge {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.2);
    display: none;
}

/* ==========================================================================
   UTILITY CONTAINER & TABS
   ========================================================================== */
.utility-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    padding: 10px 16px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: var(--accent-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.utility-content {
    position: relative;
    min-height: 350px;
}

.utility-tab-panel {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.utility-tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-smooth);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--input-focus);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    background: var(--accent-gradient-hover);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Results panel */
.result-box {
    margin-top: 20px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius-sm);
    padding: 16px;
    display: none;
    animation: slideUp 0.3s ease forwards;
}

[data-theme="light"] .result-box {
    background: rgba(255, 255, 255, 0.5);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-box.active {
    display: block;
}

.result-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
}

[data-theme="light"] .result-row {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.result-row:last-child {
    border-bottom: none;
}

.result-label {
    color: var(--text-secondary);
}

.result-val {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Tool specific styles */
/* Codice Fiscale */
.gender-radio-group {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}
.gender-radio-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    cursor: pointer;
}
.cf-final-result {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    text-align: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-sm);
    letter-spacing: 2px;
    margin: 8px 0;
    border: 1px dashed var(--accent-primary);
    cursor: pointer;
    position: relative;
    user-select: all;
}
.cf-final-result::after {
    content: 'Clicca per copiare';
    position: absolute;
    bottom: 2px;
    right: 8px;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--text-muted);
}

/* Password generator slider */
.slider-group {
    margin-bottom: 20px;
}
.slider-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 8px;
}
.slider-val {
    color: var(--accent-primary);
    font-size: 16px;
    font-weight: 700;
}
input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--input-bg);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-gradient);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
    transition: var(--transition-smooth);
}
input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
}
.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
}

.strength-meter {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    margin-bottom: 12px;
    overflow: hidden;
}
.strength-bar {
    height: 100%;
    width: 0;
    transition: var(--transition-smooth);
}
.strength-bar.weak { background: var(--accent-danger); width: 25%; }
.strength-bar.medium { background: var(--accent-warning); width: 60%; }
.strength-bar.strong { background: var(--accent-success); width: 100%; }

/* ==========================================================================
   NEWS AGGREGATOR
   ========================================================================== */
.news-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.news-region-select {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    width: 140px;
}

.news-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 520px;
    overflow-y: auto;
    padding-right: 4px;
}

.news-card {
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.02);
    border-radius: var(--border-radius-sm);
    padding: 12px;
    transition: var(--transition-smooth);
}

[data-theme="light"] .news-card {
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.news-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .news-card:hover {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.05);
}

.news-time {
    font-size: 10px;
    color: var(--accent-primary);
    font-weight: 700;
    margin-bottom: 4px;
}

.news-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 6px;
}

.news-link {
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.news-shimmer {
    height: 80px;
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--border-radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================================================
   ADVERTISEMENT BOXES (MONETIZATION)
   ========================================================================== */
.ad-container {
    background: rgba(0, 0, 0, 0.15);
    border: 1px dashed var(--panel-border);
    border-radius: var(--border-radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    max-width: 1400px;
    margin: 0 auto 24px auto;
    padding-left: 24px;
    padding-right: 24px;
    box-sizing: border-box;
    text-align: center;
    min-height: 120px;
    margin: 16px 0;
    position: relative;
    overflow: hidden;
}

[data-theme="light"] .ad-container {
    background: rgba(255, 255, 255, 0.3);
}

.ad-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    font-weight: 600;
}

.ad-placeholder {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.ad-top-leaderboard {
    max-width: 728px;
    margin: 0 auto 12px auto;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
footer {
    background: var(--panel-bg);
    border-top: 1px solid var(--panel-border);
    padding: 24px 0;
    margin-top: auto;
    font-size: 13px;
    color: var(--text-secondary);
    backdrop-filter: var(--backdrop-blur);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-links {
    display: flex;
    gap: 16px;
}

.footer-links a {
    color: var(--text-secondary);
}

.footer-links a:hover {
    color: var(--accent-primary);
}

.copy-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--accent-success);
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}
.copy-toast.active {
    transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   PULSATING DOT FOR LIVE METEO SYNC
   ========================================================================== */
.sync-dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent-success);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px var(--accent-success);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* ==========================================================================
   MOBILE RESPONSIVENESS ENHANCEMENTS
   ========================================================================== */
@media (max-width: 600px) {
    .container {
        padding: 0 16px;
    }
    main {
        padding: 16px 0;
    }
    header .header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
    }
    .brand-section {
        flex-direction: row;
        gap: 8px;
    }
    .brand-logo {
        width: 32px;
        height: 32px;
        font-size: 15px;
        border-radius: 8px;
    }
    .brand-title h1 {
        font-size: 16px;
    }
    .brand-title span {
        display: none;
    }
    .header-clock {
        display: none;
    }
    .header-meta {
        gap: 8px;
    }
    .btn-theme-toggle {
        width: 32px;
        height: 32px;
        font-size: 14px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .quick-weather[href], 
    .quick-weather[onclick], 
    button.quick-weather {
        width: 32px;
        height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        padding: 0;
        font-size: 0 !important;
        gap: 0;
        overflow: hidden;
        flex-shrink: 0;
    }
    .quick-weather[href] i, 
    .quick-weather[onclick] i, 
    button.quick-weather i {
        font-size: 14px !important;
        margin: 0;
    }
    #quickWeatherWidget {
        padding: 4px 8px;
        font-size: 11px;
        border-radius: 12px;
    }
    #quickWeatherWidget i {
        font-size: 11px;
    }
    .glass-panel {
        padding: 16px;
    }
    .panel-title {
        font-size: 16px;
        margin-bottom: 16px;
    }
    .weather-temp-main {
        font-size: 38px;
    }
    /* Prevent mobile input zooming on iOS */
    input, select, textarea {
        font-size: 16px !important;
    }
    /* Adjust grids for tighter spaces */
    .checkbox-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .gender-radio-group {
        flex-direction: column;
        gap: 8px;
    }
    .result-row {
        font-size: 12px;
    }
    .cf-final-result {
        font-size: 18px;
        letter-spacing: 1px;
    }
}

@media (max-width: 400px) {
    /* Rimosse sovrascritture di incolonnamento per mantenere l'header compatto in riga */
}

/* ==========================================================================
   MONETIZATION AD SLOTS
   ========================================================================== */
.ad-slot-placeholder {
    width: 100%;
    min-height: 250px;
    background-color: var(--panel-bg);
    border: 1px dashed var(--panel-border);
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
    margin: 20px 0;
    position: relative;
    overflow: hidden;
}
.ad-slot-placeholder::before {
    content: 'Spazio Pubblicitario (AdSense)';
    opacity: 0.5;
}
.ad-slot-placeholder.ad-slot-sidebar {
    min-height: 600px;
}

/* ==========================================================================
   STRUMENTI PDF (CLIENT-SIDE)
   ========================================================================== */
.pdf-file-item {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius-sm);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    transition: var(--transition-smooth);
}
[data-theme="light"] .pdf-file-item {
    background: rgba(255, 255, 255, 0.4);
}
.pdf-file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pdf-file-info i {
    color: var(--accent-danger);
    font-size: 16px;
}
.pdf-file-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pdf-file-size {
    font-size: 11px;
    color: var(--text-muted);
}
.btn-remove-file {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    transition: var(--transition-smooth);
}
.btn-remove-file:hover {
    color: var(--accent-danger);
    transform: scale(1.1);
}
.pdf-dropzone-drag {
    border-color: var(--accent-primary) !important;
    background: rgba(99, 102, 241, 0.08) !important;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

/* ==========================================================================
   HUB STRUMENTI & UTILITY
   ========================================================================== */
.hub-category-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.tool-card {
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
}
[data-theme="light"] .tool-card {
    background: rgba(255, 255, 255, 0.55);
}
.tool-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
    box-shadow: 0 4px 16px var(--panel-shadow);
}
.tool-card-icon {
    width: 36px;
    height: 36px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.tool-card-info {
    flex: 1;
}
.tool-card-info h4 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 2px;
    color: var(--text-primary);
}
.tool-card-info p {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* Barra di ritorno all'hub negli strumenti */
.tool-back-bar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 16px;
}
.btn-back-hub {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--border-radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-smooth);
}
.btn-back-hub:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* ==========================================================================
   EDITOR PDF & TIMBRO
   ========================================================================== */
.pdf-editor-workspace {
    position: relative;
    height: 75vh;
    min-height: 600px;
    background: #525659;
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius-sm);
    overflow: auto;
    padding: 20px;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
}

.pdf-editor-workspace canvas {
    background: white;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    margin: 0 auto;
    display: block;
}

.draggable-stamp {
    position: absolute;
    cursor: grab;
    z-index: 10;
    border: 2px dashed rgba(99, 102, 241, 0.8);
    background: rgba(99, 102, 241, 0.1);
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: none; /* Previene scroll su mobile durante il drag */
}

.draggable-stamp:active {
    cursor: grabbing;
    border: 2px dashed rgba(16, 185, 129, 1);
    background: rgba(16, 185, 129, 0.2);
}

/* ==========================================================================
   ACTION BAR & WORKFLOW
   ========================================================================== */
.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--panel-border);
}

.btn-action {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.btn-action-primary {
    background: var(--accent-gradient);
    color: white;
    border: none;
}
.btn-action-primary:hover {
    background: var(--accent-gradient-hover);
}

/* ==========================================================================
   STILI PERSONALIZZATI PER QUILL EDITOR (DARK MODE PREMIUM)
   ========================================================================== */
.ql-toolbar.ql-snow {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid var(--panel-border) !important;
    border-top-left-radius: var(--border-radius-sm) !important;
    border-top-right-radius: var(--border-radius-sm) !important;
}
[data-theme="light"] .ql-toolbar.ql-snow {
    background: rgba(0, 0, 0, 0.02) !important;
}
.ql-container.ql-snow {
    background: rgba(0, 0, 0, 0.15) !important;
    border: 1px solid var(--panel-border) !important;
    border-top: none !important;
    border-bottom-left-radius: var(--border-radius-sm) !important;
    border-bottom-right-radius: var(--border-radius-sm) !important;
    color: var(--text-primary) !important;
    font-family: var(--font-primary) !important;
}
[data-theme="light"] .ql-container.ql-snow {
    background: rgba(255, 255, 255, 0.6) !important;
}
.ql-editor {
    min-height: 250px;
    font-size: 14px !important;
    line-height: 1.6 !important;
}
/* Colori delle icone e dei picker della toolbar di Quill */
.ql-snow .ql-stroke {
    stroke: var(--text-secondary) !important;
}
.ql-snow .ql-fill {
    fill: var(--text-secondary) !important;
}
.ql-snow .ql-picker {
    color: var(--text-secondary) !important;
}
.ql-snow .ql-picker-options {
    background-color: var(--panel-bg) !important;
    border: 1px solid var(--panel-border) !important;
    border-radius: var(--border-radius-sm) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3) !important;
}
[data-theme="light"] .ql-snow .ql-picker-options {
    background-color: white !important;
    color: #333 !important;
}
.ql-snow .ql-picker-item {
    color: var(--text-secondary) !important;
}
.ql-snow .ql-picker-item:hover, 
.ql-snow .ql-picker-label:hover {
    color: var(--accent-primary) !important;
}
.ql-snow .ql-picker-item.ql-selected {
    color: var(--accent-primary) !important;
}
.ql-snow.ql-toolbar button:hover .ql-stroke, 
.ql-snow.ql-toolbar button.ql-active .ql-stroke {
    stroke: var(--accent-primary) !important;
}
.ql-snow.ql-toolbar button:hover .ql-fill, 
.ql-snow.ql-toolbar button.ql-active .ql-fill {
    fill: var(--accent-primary) !important;
}

/* ==========================================================================
   STILI PER L'EDITOR PDF PROFESSIONALE
   ========================================================================== */
.draggable-text-box {
    position: absolute;
    z-index: 10;
    border: 1px dashed var(--accent-primary);
    background: rgba(99, 102, 241, 0.08);
    color: #ef4444;
    padding: 6px 10px;
    font-family: Helvetica, Arial, sans-serif;
    font-size: 14px;
    font-weight: bold;
    min-width: 60px;
    min-height: 20px;
    outline: none;
    cursor: move;
    border-radius: 4px;
}
.draggable-text-box:focus {
    border: 1.5px solid var(--accent-success) !important;
    background: rgba(16, 185, 129, 0.1) !important;
}
.btn-delete-textbox {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 15;
}
.btn-delete-textbox:hover {
    background: #dc2626;
    transform: scale(1.1);
}
/* Stile card in evidenza */
.featured-tool-card:hover {
    border-color: var(--accent-primary) !important;
    box-shadow: 0 12px 32px rgba(99, 102, 241, 0.25) !important;
    transform: translateY(-4px) !important;
}

/* Rettangolo di copertura (Sbianchetta) */
.draggable-rect-box {
    position: absolute;
    z-index: 9;
    border: 1px dashed var(--accent-success);
    background: #ffffff;
    cursor: move;
    box-sizing: border-box;
    resize: both; /* Consente il ridimensionamento nativo da browser */
    overflow: hidden;
    min-width: 30px;
    min-height: 15px;
    border-radius: 2px;
}
.btn-delete-rect {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    font-size: 8px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    z-index: 12;
}
.btn-delete-rect:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Pulsante toggle sfondo per textbox */
.btn-toggle-bg {
    position: absolute;
    top: -10px;
    right: 12px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 15;
    transition: all 0.2s;
}
.btn-toggle-bg:hover {
    background: var(--accent-success);
    transform: scale(1.1);
}

/* Stili Scanner Documenti */
.ds-corner-handle {
    transition: transform 0.1s ease, border-color 0.2s ease;
    touch-action: none; /* Impedisce lo scroll di pagina durante il drag su mobile */
}
.ds-corner-handle:hover {
    transform: translate(-12px, -12px) scale(1.2) !important;
    border-color: var(--accent-success) !important;
}
.ds-filter-btn {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--panel-border);
    color: var(--text-muted);
}
.ds-filter-btn.active {
    background: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
    color: #fff !important;
}

/* ==========================================================================
   APP PROMO SECTION & CARDS
   ========================================================================== */
.app-promo-section {
    margin-top: 32px;
    margin-bottom: 32px;
}
.app-promo-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius-md);
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    backdrop-filter: var(--backdrop-blur);
    box-shadow: 0 8px 32px var(--panel-shadow);
}
.app-promo-info {
    display: flex;
    align-items: center;
    gap: 20px;
}
.app-promo-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    flex-shrink: 0;
}
.app-promo-text h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.app-promo-text p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}
.app-promo-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.btn-promo-download {
    background: var(--accent-gradient);
    color: #ffffff !important;
    border: none;
    padding: 12px 20px;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}
.btn-promo-download:hover {
    background: var(--accent-gradient-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}
.btn-promo-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary) !important;
    border: 1px solid var(--panel-border);
    padding: 12px 20px;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
    cursor: pointer;
}
.btn-promo-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--text-secondary);
}
.app-promo-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
}
.app-promo-qr img {
    border-radius: 6px;
    display: block;
    width: 80px;
    height: 80px;
}
.app-promo-qr span {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
}


/* ==========================================================================
   ENHANCED TOOL SEARCH & CATEGORY FILTERS
   ========================================================================== */
.tools-search-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 16px;
}

.search-shortcut-badge {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--panel-border);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    pointer-events: none;
}

[data-theme="light"] .search-shortcut-badge {
    background: rgba(0, 0, 0, 0.06);
}

.tool-category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.category-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

[data-theme="light"] .category-pill {
    background: rgba(0, 0, 0, 0.03);
}

.category-pill:hover,
.category-pill.active {
    background: var(--accent-gradient);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.hub-category-block.hidden-category {
    display: none !important;
}



