/* ===== TOOL PAGES STYLES ===== */

body {
    background: var(--bg-page);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

@media (min-width: 768px) {
    .container {
        padding: 60px 20px;
    }
}

/* Banner pubblicitario superiore — nessun box visibile quando vuoto:
   appare solo lo spazio occupato dall'annuncio reale, se caricato. */
.ad-banner-top {
    margin-bottom: 20px;
    text-align: center;
    overflow: hidden;
}

.ad-banner-top ins {
    max-width: 100%;
}

/* Segnaposto testuale non utilizzato: lo teniamo nascosto */
.ad-placeholder {
    display: none;
}

/* Layout principale — flexbox: il contenuto centrale resta centrato e
   con larghezza corretta anche se le sidebar pubblicitarie vengono
   bloccate/rimosse da un ad blocker. */
.main-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.main-layout > main {
    width: 100%;
    max-width: 800px;
    min-width: 0;
}

@media (min-width: 1024px) {
    .main-layout {
        flex-direction: row;
        justify-content: center;
        align-items: flex-start;
    }

    .main-layout > main {
        flex: 0 1 800px;
    }
}

/* Banner laterali — invisibili quando vuoti */
.ad-sidebar {
    display: none;
    text-align: center;
}

@media (min-width: 1024px) {
    .ad-sidebar {
        flex: 0 0 250px;
        display: flex;
        align-items: center;
        justify-content: center;
        position: sticky;
        top: 20px;
        height: fit-content;
    }
}

/* Card principale */
.tool-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 800px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .tool-card {
        padding: 30px;
    }
}

h1 {
    color: #2d3748;
    margin-bottom: 10px;
    font-size: 1.5rem;
    word-wrap: break-word;
}

@media (min-width: 768px) {
    h1 {
        font-size: 2rem;
    }
}

.subtitle {
    color: #718096;
    margin-bottom: 30px;
}

.upload-area {
    border: 3px dashed #cbd5e0;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 20px;
}

@media (min-width: 768px) {
    .upload-area {
        padding: 40px;
    }
}

.upload-area:hover {
    border-color: var(--brand-primary);
    background: #f7fafc;
}

.upload-area.drag-over {
    border-color: var(--brand-primary);
    background: #eef2ff;
}

.upload-icon {
    font-size: 2rem;
    margin-bottom: 15px;
}

@media (min-width: 768px) {
    .upload-icon {
        font-size: 3rem;
    }
}

input[type="file"] {
    display: none;
}

.settings {
    background: #f7fafc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.setting-group {
    margin-bottom: 15px;
}

.setting-group label {
    display: block;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 8px;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--brand-primary);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--brand-primary);
    cursor: pointer;
    border: none;
}

.quality-value {
    display: inline-block;
    background: var(--brand-primary);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 600;
    margin-left: 10px;
}

.preview-section {
    display: none;
    margin-top: 20px;
}

.preview-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (min-width: 768px) {
    .preview-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.preview-box {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 15px;
}

.preview-box h3 {
    color: #2d3748;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.preview-box img {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 10px;
    object-fit: contain;
}

.file-info {
    background: #edf2f7;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.file-info div {
    margin-bottom: 5px;
}

.file-info div:last-child {
    margin-bottom: 0;
}

.savings,
.info-box {
    background: #48bb78;
    color: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    margin-bottom: 20px;
}

.info-box {
    background: #bee3f8;
    border-left: 4px solid #3182ce;
    text-align: left;
}

.info-box h4 {
    color: #2c5282;
    margin-bottom: 8px;
}

.info-box p {
    color: #2a4365;
    font-size: 0.9rem;
    line-height: 1.5;
}

.btn {
    background: var(--brand-primary);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    width: 100%;
}

.btn:hover {
    background: var(--brand-primary-dark);
}

.btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

/* Banner pubblicitario inferiore — invisibile quando vuoto */
.ad-banner-bottom {
    margin-top: 20px;
    text-align: center;
    overflow: hidden;
}

/* Banner mobile — invisibile quando vuoto */
.ad-mobile {
    display: block;
    margin: 10px 0;
    text-align: center;
    overflow: hidden;
}

@media (min-width: 1024px) {
    .ad-mobile {
        display: none;
    }
}

/* Conversion options */
.conversion-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 30px;
}

@media (min-width: 768px) {
    .conversion-options {
        grid-template-columns: 1fr 1fr;
    }
}

.option-card {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.option-card:hover {
    border-color: var(--brand-primary);
    background: #f7fafc;
}

.option-card.active {
    border-color: var(--brand-primary);
    background: #eef2ff;
}

.option-card .icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.option-card h3 {
    color: #2d3748;
    margin-bottom: 5px;
    font-size: 1.1rem;
}

.option-card p {
    color: #718096;
    font-size: 0.85rem;
}

/* ===== MOBILE RESPONSIVE IMPROVEMENTS ===== */
@media (max-width: 767px) {
    body {
        padding: 0;
    }

    .container {
        padding: 10px;
    }

    .tool-card {
        border-radius: 8px;
        padding: 15px;
    }

    h1 {
        font-size: 1.3rem;
        line-height: 1.3;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .upload-area {
        padding: 20px 10px;
    }

    .upload-area h3 {
        font-size: 1rem;
    }

    .upload-area p {
        font-size: 0.85rem;
    }

    .settings {
        padding: 15px;
    }

    .setting-group label {
        font-size: 0.9rem;
    }

    .quality-value {
        font-size: 0.8rem;
        padding: 3px 10px;
    }

    .preview-box {
        padding: 10px;
    }

    .preview-box h3 {
        font-size: 1rem;
    }

    .file-info {
        font-size: 0.8rem;
        padding: 8px;
    }

    .info-box {
        padding: 12px;
    }

    .info-box h4 {
        font-size: 1rem;
    }

    .info-box p {
        font-size: 0.85rem;
    }

    .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    .conversion-options {
        gap: 10px;
    }

    .option-card {
        padding: 15px;
    }

    .option-card .icon {
        font-size: 2rem;
    }

    .option-card h3 {
        font-size: 1rem;
    }

    .option-card p {
        font-size: 0.8rem;
    }

    /* Hide fixed width ads on mobile, show only responsive ones */
    .ad-banner-top ins[style*="728px"],
    .ad-banner-bottom ins[style*="728px"] {
        display: none !important;
    }
}

/* ===== MOBILE OVERFLOW FIXES (specifici dei layout tool) ===== */
@media (max-width: 767px) {
    .container {
        width: 100% !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
        max-width: 100vw !important;
        overflow-x: hidden;
    }
    
    .main-layout {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    .tool-card {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    
    .ad-banner-top,
    .ad-banner-bottom,
    .ad-mobile {
        max-width: 100% !important;
        overflow: hidden;
    }
    
    .ad-banner-top ins,
    .ad-banner-bottom ins,
    .ad-mobile ins {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* Force hide all large ads */
    ins.adsbygoogle[style*="728px"],
    ins.adsbygoogle[style*="468px"],
    ins.adsbygoogle[style*="300px"] {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }
}
