/* Main container */
.tool-container {
    max-width: 1100%;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Headings */
h1 {
    font-size: 2rem;
    margin-bottom: 5px;
}

.subtitle {
    color: #666;
    margin-bottom: 20px;
}

/* Gradient tool layout */
.gradient-tool {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

/* Controls panel */
.controls {
    flex: 1;
    min-width: 368px;
    background: #fff;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 6px 15px rgba(0,0,0,0.08);
    text-align: left;
}

.control-group {
    margin-bottom: 20px;
}

.control-group label {
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
}

select, input[type="color"], input[type="range"], input[type="number"] {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #ddd;
    font-size: 14px;
    box-sizing: border-box;
}

/* Color stop inputs */
.color-stops {
    margin-bottom: 20px;
}

.color-input {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.color-input input[type="color"] {
    width: 45px;
    height: 45px;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.color-input input[type="range"] {
    flex: 1;
}

.color-input .pos-value {
    font-size: 12px;
    color: #555;
    width: 35px;
    text-align: right;
}

/* Opacity slider */
.alpha-slider {
    width: 80px;
}

/* Buttons */
.btn {
    padding: 14px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: #007bff;
    transition: 0.2s;
    font-size: 14px;
    color: #fff;
}

.btn:hover {
    background: #005fcc;
}

.btn.primary {
    background: #007bff;
    color: #fff;
}

.btn.primary:hover {
    background: #005fcc;
}

.btn.small {
    font-size: 13px;
    padding: 6px 10px;
}

/* Preview panel */
.preview {
    flex: 2;
    min-width: 300px;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 6px 15px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

#gradientPreview {
    border-radius: 10px;
    width: 100%;
    height: auto;
    margin-bottom: 15px;
    box-sizing: border-box;
    box-shadow: inset 0 0 8px rgba(0,0,0,0.05);
    transition: background 0.3s;
}

/* Download button below preview */
#downloadGradient {
    width: 140px;
    margin-bottom: 10px;
}

/* CSS output textarea */
#cssOutput {
    width: 100%;
    padding: 10px;
    font-size: 13px;
    border-radius: 8px;
    border: 1px solid #ddd;
    font-family: monospace;
    resize: none;
    height: 80px;
}

/* Examples */
.examples-title {
    margin-top: 40px;
    font-size: 1.5rem;
}

.examples {
    display: grid;
    grid-template-columns: repeat(auto-fill,minmax(140px,1fr));
    gap: 15px;
    margin-top: 15px;
}

.example-box {
    border-radius: 12px;
    height: 80px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.example-box:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Custom size inputs layout */
#customSizeInputs input[type="number"] {
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #ddd;
}


/* --- FIXES FOR MOBILE RESPONSIVENESS --- */
html, body {
    width: 100%;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

.tool-container {
    max-width: 100%; /* Allow full width on mobile */
    
    box-sizing: border-box;
}

.gradient-tool {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .gradient-tool {
        flex-direction: column;
        align-items: stretch;
    }

    .controls, .preview {
        flex: 1 1 100%;
        width: 100%;
        min-width: unset;
        max-width: 100%; /* Fix cutoff */
    }

    h1 {
        font-size: 1.6rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .tool-container {
        padding: 15px;
    }
    @media (max-width: 480px) {
    #gradientPreview {
        min-height: 180px; /* smaller default height */
    }
}

    h1 {
        font-size: 1.4rem;
    }

    .controls, .preview {
        padding: 15px;
    }

    .btn {
        font-size: 13px;
        padding: 8px 12px;
    }

    #cssOutput {
        font-size: 12px;
        height: 70px;
    }

    .example-box {
        height: 70px;
    }

    /* Examples grid adjusts to small screens */
    .examples {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}
