/* Image Mode Button */
#img-mode-btn.img-mode-active {
    background: #1a6b1a !important;
    border-color: #4caf50 !important;
    color: #4caf50 !important;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
}

/* General Styles */
body {
    background-color: black;
    color: white;
    font-family: 'Helvetica', sans-serif;
    padding-bottom: 120px; /* Space for fixed button bar + render gallery clearance */
}

.container {
    overflow: visible; /* Allow content to scroll past fixed bar */
}

/* Background and foreground styles moved to portraitDefaults.css */

/* Import portrait defaults */
@import url('./portraitDefaults.css');

/* Preview Styles */
.preview-container {
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    align-items: flex-end;
}

.preview {
    display: inline-flex;
    gap: 20px;
    align-items: flex-end;
}

.kilo-flyers-template-preview {
    overflow: hidden;
    position: relative;
    display: block; /* CHANGED: block instead of flex - prevents text expansion from moving layers */
    border-radius: 10px;
    background: black;
}

/* Removed outline styling for previews */

/* Preview sizes moved to previewSizes.css */

/* Portrait styles moved to portraitDefaults.css */

/* Updates Section */
.updates-section {
    margin: 5px 0;
    width: 100%;
    text-align: left;
    font-size: 16px;
    padding: 10px;
    box-sizing: border-box;
}

/* Main content row layout */
.main-content-row {
    display: flex;
    gap: 20px;
    width: 100%;
    align-items: flex-start;
    margin-bottom: 5px;
}

.grid-section {
    width: 450px;
    flex-shrink: 0; /* Prevent shrinking */
    padding-top: 0;
}

.preview-section {
    flex: 1;
    min-width: 0;
}

/* ── Loading overlay ── */
#loading {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99998;
    justify-content: center;
    align-items: center;
}

#loading.active {
    display: flex;
}

#loading .spinner {
    width: 48px;
    height: 48px;
    border: 5px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: kf-spin 0.8s linear infinite;
}

@keyframes kf-spin {
    to { transform: rotate(360deg); }
}

/* ── Mobile: grid + previews on same row, scrolls horizontally as one unit ── */
@media (max-width: 768px) {
    /* Wrap the row in a horizontally-scrolling viewport */
    .main-content-row {
        display: flex;
        flex-wrap: nowrap;
        align-items: flex-end;   /* bottom-align previews to grid */
        gap: 12px;
        width: 100%;
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        /* Don't let flex shrink children — let them keep natural widths */
        min-width: 0;
    }

    /* Grid fixed width — doesn't shrink */
    .grid-section {
        width: 280px;
        min-width: 280px;
        flex-shrink: 0;
    }

    /* Grid unrestricted height, full section width */
    .grid {
        max-height: none;
        overflow-y: visible;
        max-width: 280px;
        width: 280px;
    }

    /* Preview section: shrink to fit its content, don't flex-grow */
    .preview-section {
        flex: 0 0 auto;
        width: auto;
        min-width: 0;
    }

    /* Preview container: don't constrain to parent width */
    .preview-section .preview-container {
        width: auto;
        min-width: 0;
    }

    /* Hide back, voice and portrait buttons on mobile */
    #undo-btn,
    #voice-control-btn,
    #portrait-menu-btn,
    .portrait-menu-container {
        display: none !important;
    }

    /* Un-fix the bottom button bar so it scrolls with the page */
    .all-buttons-row {
        position: static;
        bottom: auto;
    }

    body {
        padding-bottom: 0;
    }
}

/* All buttons row */
.all-buttons-row {
    display: flex;
    gap: 20px;
    width: 100%;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background-color: #000;
    padding: 8px 10px;
    box-sizing: border-box;
    border-top: 1px solid #222;
}

/* Button Styles */
.button-section {
    display: flex;
    margin: 0px auto;
    padding: 10px;
    width: 100%;
    align-items: center;
    box-sizing: border-box;
    min-height: 60px;
    gap: 10px;
}

.button-section-center {
    margin: 0 auto;
    display: flex;
    justify-content: center;
    gap: 20px;
    align-items: center;
}

.button-section-page1 {
    flex: 1;
}

.button-section-page2 {
    position: relative;
    display: flex;
    flex: 1;
    align-items: center;
}

/* Form Styles */
.form {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
}

.form-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    margin: 0 10px;
}

#textInput {
    flex-grow: 1;
    padding: 0 10px;
    background-color: black;
    border: 1px solid white;
    color: white;
    font-size: 16px;
    border-radius: 50px;
    max-height: 40px !important;
}

#attachmentButton {
    cursor: pointer;
}


/* Shared button style */
.shared-button-style {
    background-color: black;
    border: 2px solid white;
    color: white;
    cursor: pointer;
    border-radius: 50px;
    transition: all 0.3s ease;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.shared-button-style:hover {
    background-color: #333;
    transform: scale(1.05);
}

.shared-button-style:active {
    background-color: white;
    color: black;
}

/* PSD Grid Button Specific Styles */
.psd-grid-button {
    font-family: 'Helvetica', sans-serif;
    font-weight: bold;
    font-size: 14px;
}

.psd-grid-button .icon {
    color: #007bff;
    font-weight: bold;
}

.psd-grid-button:hover .icon {
    color: #0056b3;
}

.text-button-style {
    background-color: transparent;
    border: 1px solid white;
    color: white;
    cursor: pointer;
    border-radius: 50px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding-left: 20px;
    padding-right: 20px;
}

/* Preview styles moved to previewSizes.css */

/* Common section styling */
.move-buttons-section, .resize-rotate-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 8px;
    border-radius: 5px;
    width: 100%;
    margin-bottom: 5px;
}

.section-label {
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.move-buttons, .control-buttons {
    display: flex;
    gap: 10px;
}

/* Move button styling */
.move-button {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border: 1px solid white;
    border-radius: 50%;
    background: transparent;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.move-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Control buttons styling - now using the same style as move buttons */
.control-buttons {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

.control-button {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border: 1px solid white;
    border-radius: 50%;
    background: transparent;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.control-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.size-down, .size-up {
    font-weight: bold;
}

.rotate-left, .rotate-right {
    font-size: 14px;
}

/* Slider and text container */
.slider-text-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 5px;
    width: 100%;
}

/* Slider controls */
.slider-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Temperature and contrast controls */
.temperature-controls, .contrast-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.temperature-controls label, .contrast-controls label {
    color: white;
    font-size: 12px;
    min-width: 40px;
}

/* Slider styling */
.temperature-slider, .contrast-slider {
    flex: 1;
    height: 2px;
    -webkit-appearance: none;
    appearance: none;
    appearance: none;
    background: white;
    outline: none;
    opacity: 0.7;
    border-radius: 1px;
}

.temperature-slider::-webkit-slider-thumb,
.contrast-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: white;
    cursor: pointer;
    border-radius: 50%;
}

.temperature-slider::-moz-range-thumb,
.contrast-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: white;
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

/* Banner preview styles moved to previewSizes.css */

/* Update the preview buttons container to maintain proper spacing */
.preview-buttons {
    margin-top: 0px;
}

/* Search Styles */
.search-form {
    display: flex;
    gap: 10px;
    margin: 20px auto;
    width: 100%;
    max-width: 800px;
    box-sizing: border-box;
    padding: 20px;
}

#textInput {
    flex: 1;
    padding: 10px 20px;
    background-color: black;
    border: 1px solid white;
    color: white;
    font-size: 16px;
    border-radius: 50px;
    max-height: 40px;
}

#textInput::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-form button {
    background-color: transparent;
    border: 1px solid white;
    color: white;
    cursor: pointer;
    border-radius: 50px;
    padding: 0 30px;
    font-size: 16px;
    min-height: 40px;
    transition: all 0.3s ease;
}

.search-form button:hover {
    background-color: white;
    color: black;
}

.search-input {
    flex: 1;
    padding: 0 15px;
    background-color: black;
    border: 1px solid white;
    color: white;
    font-size: 16px;
    border-radius: 50px;
    height: 40px !important;
    line-height: 40px;
    box-sizing: border-box;
}

.search-button {
    background-color: transparent;
    border: 1px solid white;
    color: white;
    cursor: pointer;
    border-radius: 50px;
    padding: 0 10px;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

.search-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}