/* Global Styles - Girly Pink Theme ✨💖 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #fff5f9 0%, #ffe6f0 50%, #ffd6e8 100%);
    min-height: 100vh;
    padding: 20px;
}

/* Navigation Bar */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    margin: 0;
}

.nav-container {
    max-width: 1400px !important;  /* Wider to fit all 9 links */
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h2 {
    color: #ff6b9d;
    /* Solid pink */
    margin: 0;
    font-size: 1.5em;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 20px;
    margin: 0;
    padding: 0;
}

.nav-links a {
    color: #333;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s;
    padding: 8px 16px;
    border-radius: 8px;
}

.nav-links a:hover,
.nav-links a.active {
    color: #ff6b9d;
    background: rgba(255, 107, 157, 0.1);
}

/* Add top padding to body when navbar is present */
body:has(.navbar) {
    padding-top: 80px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

/* Wider container for comparison section */
.container-wide {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #ff6b9d 0%, #c86dd7 50%, #a855f7 100%);
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: 0 8px 30px rgba(192, 132, 252, 0.25);
    border: 3px solid rgba(255, 255, 255, 0.6);
}

header h1 {
    font-size: 3em;
    margin-bottom: 15px;
    color: white;
    font-weight: 800;
    text-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

header p {
    font-size: 1.4em;
    color: white;
    font-weight: 600;
    opacity: 1;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: 0 5px 25px rgba(255, 107, 157, 0.12);
    border: 2px solid #ffe6f0;
}

.card h2 {
    color: #ff6b9d !important;
    /* Solid pink - no gradient! */
    background: none !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: #ff6b9d !important;
    background-clip: initial !important;
    margin-bottom: 20px;
    font-size: 1.6em;
}

/* Upload Area - Pink theme */
.upload-area {
    border: 3px dashed #ffc9e0;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 20px;
    background: rgba(255, 107, 157, 0.05);
}

.upload-area:hover {
    border-color: #ff6b9d;
    background: rgba(255, 107, 157, 0.1);
}

.upload-area.drag-over,
.upload-area.dragover {
    border-color: #c86dd7;
    background: rgba(200, 109, 215, 0.1);
}

.upload-icon {
    font-size: 4em;
    display: block;
    margin-bottom: 15px;
}

.upload-prompt p {
    color: #ff6b9d;
    font-weight: 600;
    font-size: 1.2em;
    margin: 5px 0;
}

.upload-hint {
    font-size: 0.9em;
    color: #666;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: #5b21b6;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.form-group select,
.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ffc9e0;
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.3s;
    background: white;
    color: #2d3748;
}

.form-group select:focus,
.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #ff6b9d;
    background: #fff5f9;
    box-shadow: 0 0 0 4px rgba(255, 107, 157, 0.1);
}

.form-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #ffa3c1;
    margin-right: 8px;
}

/* Range Slider - Pink theme */
input[type="range"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 200px;
    height: 8px;
    background: transparent;
    outline: none;
    margin: 0 10px;
    cursor: pointer;
    border-radius: 5px;
}

/* Slider Track - WebKit */
input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #ffe6f0 0%, #ffc9e0 50%, #ff6b9d 100%);
    border: none;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Slider Track - Firefox */
input[type="range"]::-moz-range-track {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #ffe6f0 0%, #ffc9e0 50%, #ff6b9d 100%);
    border: none;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Slider Thumb - WebKit */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 3px solid #ff6b9d;
    box-shadow: 0 3px 10px rgba(255, 107, 157, 0.3);
    margin-top: -7px;
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.4);
}

input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.0);
    box-shadow: 0 2px 8px rgba(255, 107, 157, 0.3);
}

/* Slider Thumb - Firefox */
input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 3px solid #ff6b9d;
    box-shadow: 0 3px 10px rgba(255, 107, 157, 0.3);
    transition: all 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.4);
}

input[type="range"]::-moz-range-thumb:active {
    transform: scale(1.0);
    box-shadow: 0 2px 8px rgba(255, 107, 157, 0.3);
}

/* Buttons - Pink gradients matching trial page */
.btn {
    padding: 14px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 10px;
    box-shadow: 0 5px 15px rgba(255, 107, 157, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #ff6b9d 0%, #c86dd7 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 157, 0.35);
}

.btn-success {
    background: linear-gradient(135deg, #ff6b9d 0%, #c86dd7 100%);
    /* Same as primary! */
    color: white;
}

.btn-success:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 157, 0.35);
}

.btn-secondary {
    background: linear-gradient(135deg, #ff6b9d 0%, #c86dd7 100%);
    /* Same as primary! */
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 157, 0.35);
}

.btn:disabled {
    background: #e0e0e0;
    color: #999;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Status Messages with more spacing */
#upload-status,
#process-status {
    margin-top: 15px;
    padding: 15px;
    border-radius: 10px;
    display: none;
    font-weight: 600;
}

#upload-status.success,
#process-status.success {
    background: linear-gradient(135deg, #c3f0c8 0%, #b5f0c0 100%);
    color: #2d7a3e;
    display: block;
    border: 2px solid #4ade80;
    margin-bottom: 25px;
    /* More space before buttons! */
}

#upload-status.error,
#process-status.error {
    background: linear-gradient(135deg, #ffc9e0 0%, #ffb8d1 100%);
    color: #d63384;
    display: block;
    border: 2px solid #ff6b9d;
}

#download-info {
    font-size: 1.1em;
    color: #2d3748;
    margin: 15px 0 25px 0;
    /* More space before buttons! */
    font-weight: 600;
}

/* Fix yellow line - override with pink */
hr {
    border: none;
    border-top: 2px solid #ffc9e0 !important;
    /* Pink not yellow! */
    margin: 25px 0 !important;
    /* More spacing! */
}

/* Section spacing improvements */
h3 {
    margin-top: 30px !important;
    /* More space above headings */
    margin-bottom: 15px !important;
}

/* Loading Indicator */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 182, 193, 0.95);
    /* Pink overlay */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    border: 4px solid #ffe6f0;
    border-top: 4px solid #ff6b9d;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

#loading p {
    color: #5b21b6;
    font-size: 1.2em;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }

    .card {
        padding: 20px;
    }

    .btn {
        width: 100%;
        margin-bottom: 10px;
    }

    .nav-links {
        gap: 15px;
        font-size: 0.9em;
    }
}

/* Emoji Preview Tooltip */
.emoji-preview-tooltip {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    background: white;
    border: 4px solid #ff6b9d;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 15px 40px rgba(255, 107, 157, 0.3);
    display: none;
}

.emoji-preview-tooltip img {
    width: 250px;
    height: 250px;
    object-fit: contain;
    display: block;
    border-radius: 10px;
}

.emoji-preview-tooltip p {
    margin: 10px 0 0 0;
    text-align: center;
    font-weight: 600;
    color: #ff6b9d;
    font-size: 14px;
}

.emoji-preview-tooltip.show {
    display: block !important;
    animation: emojiPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes emojiPop {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ===========================================
   TEMPLATE CONTROLS
   =========================================== */
.template-controls {
    margin-bottom: 20px;
    padding: 20px;
    padding-top: 20px !important;
    /* No extra space at top! */
    background: linear-gradient(135deg, #fff0f5 0%, #ffe6f0 100%);
    border: 2px solid #ffc9e0;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.1);
}

.template-controls h3 {
    color: #ff6b9d;
    margin-bottom: 15px;
    margin-top: 0 !important;
    /* No space above heading! */
    font-size: 1.2em;
}

/* Text Styling Section - Override inline styles */
#text-template-controls,
[id*="text-template"],
[id*="text-styling"] {
    background: linear-gradient(135deg, #fff0f5 0%, #ffe6f0 100%) !important;
    border: 2px solid #ffc9e0 !important;
    border-radius: 12px !important;
    padding: 20px !important;
    padding-top: 20px !important;
    /* No extra space at top! */
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.1);
}

#text-template-controls h3,
[id*="text-template"] h3,
[id*="text-styling"] h3 {
    color: #ff6b9d !important;
    background: none !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: #ff6b9d !important;
    background-clip: initial !important;
    margin-bottom: 15px !important;
    margin-top: 0 !important;
    /* No space above heading! */
    font-size: 1.2em;
}

/* Frame/Border Controls - Override inline styles */
#border-controls,
[id*="border-controls"],
[id*="frame"] {
    background: linear-gradient(135deg, #fff0f5 0%, #ffe6f0 100%) !important;
    border: 2px solid #ffc9e0 !important;
    border-radius: 12px !important;
    padding: 20px !important;
    padding-top: 20px !important;
    /* No extra space at top! */
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.1);
}

#border-controls h3,
[id*="border-controls"] h3,
[id*="frame"] h3 {
    color: #ff6b9d !important;
    background: none !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: #ff6b9d !important;
    background-clip: initial !important;
    margin-bottom: 15px !important;
    margin-top: 0 !important;
    /* No space above heading! */
    font-size: 1.2em;
}

/* Processing Complete heading - solid pink */
#results-section h2,
.card h2:contains("Processing Complete") {
    color: #ff6b9d !important;
    background: none !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: #ff6b9d !important;
    background-clip: initial !important;
}

/* Before/After heading - solid pink */
.comparison-container h3,
#comparison-section h2,
h2:contains("Before"),
h3:contains("Before") {
    color: #ff6b9d !important;
    background: none !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: #ff6b9d !important;
    background-clip: initial !important;
}

.template-list {
    margin-top: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.template-item {
    background: white;
    padding: 12px 15px;
    margin-bottom: 10px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px solid #ffc9e0;
    transition: all 0.3s;
}

.template-item:hover {
    border-color: #ff6b9d;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(255, 107, 157, 0.2);
}

.template-info {
    flex: 1;
}

.template-info strong {
    display: block;
    color: #5b21b6;
    margin-bottom: 4px;
    font-weight: 600;
}

.template-info small {
    color: #666;
    font-size: 0.85em;
}

.template-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    padding: 6px 14px;
    font-size: 0.9em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-small.btn-primary {
    background: linear-gradient(135deg, #ff6b9d 0%, #c86dd7 100%);
    color: white;
}

.btn-small.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 157, 0.3);
}

.btn-small.btn-danger {
    background: linear-gradient(135deg, #ff6b9d 0%, #ff4081 100%);
    color: white;
}

.btn-small.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 64, 129, 0.3);
}

.empty-message {
    text-align: center;
    color: #999;
    padding: 20px;
}

/* ===========================================
   PREVIEW BOX
   =========================================== */
.preview-box {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #fff9f5 0%, #ffe6d9 100%);
    border-radius: 12px;
    border: 2px solid #ffd4b8;
    box-shadow: 0 4px 15px rgba(255, 180, 120, 0.1);
}

.preview-box h4 {
    color: #ff9966;
    margin-bottom: 10px;
}

.preview-loading,
.preview-error {
    text-align: center;
    padding: 40px;
    color: #666;
}

.preview-info p {
    margin: 8px 0;
    color: #555;
}

.preview-info small {
    display: block;
    margin-top: 15px;
    color: #999;
}

/* ===========================================
   BEFORE/AFTER COMPARISON - SIDE BY SIDE
   =========================================== */
#comparison-section {
    max-width: 1400px !important;
}

.comparison-container {
    margin: 20px 0;
}

.comparison-images {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 20px;
    width: 100%;
    align-items: flex-start;
}

.comparison-image-wrapper {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(255, 107, 157, 0.2);
    flex: 1 1 50%;
    max-width: 50%;
    border: 3px solid #ffc9e0;
}

.comparison-image-wrapper img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.comparison-label {
    position: absolute;
    top: 10px;
    left: 10px;
    background: linear-gradient(135deg, #ff6b9d 0%, #c86dd7 100%);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9em;
    backdrop-filter: blur(5px);
    z-index: 10;
    box-shadow: 0 3px 10px rgba(255, 107, 157, 0.3);
}

.comparison-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
}

#comparison-counter {
    font-weight: 600;
    color: #5b21b6;
    font-size: 1.1em;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .comparison-images {
        flex-direction: column !important;
    }

    .comparison-image-wrapper {
        max-width: 100%;
    }
}

/* ===========================================
   RESPONSIVE ADJUSTMENTS
   =========================================== */
@media (max-width: 768px) {
    .template-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .template-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .comparison-slider-container {
        max-width: 100%;
    }

    .comparison-controls {
        flex-direction: column;
    }
}
/* ===================================================================
   ADVANCED DRAGGABLE & RESIZABLE PREVIEW PANEL - CSS
   =================================================================== */

/* Preview Toggle Button */
.preview-toggle-section {
    padding: 15px;
    background: linear-gradient(135deg, #f8f9ff 0%, #fff0f8 100%);
    border-radius: 8px;
    border: 2px dashed #d4a5ff;
    margin-top: 15px;
}

#toggle-preview-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #764ba2;
}

/* Advanced Preview Panel - Draggable & Resizable */
.advanced-preview-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 420px;
    min-width: 300px;
    max-width: 90vw;
    height: 600px;
    min-height: 400px;
    max-height: 90vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.4);
    border: 2px solid #e0d4ff;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow: hidden;
}

.advanced-preview-panel.minimized {
    height: auto !important;
}

.advanced-preview-panel.minimized .preview-panel-body,
.advanced-preview-panel.minimized .preview-panel-footer {
    display: none !important;
}

@keyframes slideInRight {
    from {
        transform: translateX(450px) scale(0.8);
        opacity: 0;
    }
    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

/* Draggable Header */
.preview-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px 10px 0 0;
    cursor: move;
    user-select: none;
}

.preview-panel-header.dragging {
    cursor: grabbing;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.drag-icon {
    font-size: 16px;
    opacity: 0.7;
}

.preview-panel-header h3 {
    margin: 0;
    font-size: 1.05em;
    font-weight: 600;
}

.header-right {
    display: flex;
    gap: 6px;
}

.header-btn,
.preview-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.header-btn:hover,
.preview-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.preview-close-btn:hover {
    background: rgba(255, 82, 82, 0.8);
}

/* Preview Mode Tabs */
.preview-mode-tabs {
    display: flex;
    background: #f8f9ff;
    border-bottom: 2px solid #e0d4ff;
}

.mode-tab {
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #666;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-tab:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.mode-tab.active {
    background: white;
    color: #764ba2;
    border-bottom-color: #764ba2;
}

/* Panel Body */
.preview-panel-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fafbff;
}

/* Preview Image Wrapper */
.preview-image-wrapper {
    position: relative;
    width: 100%;
    min-height: 200px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-image-wrapper img {
    max-width: 100%;
    max-height: 500px;
    height: auto;
    display: block;
    border-radius: 0;
}

/* Image Navigation Overlay */
.image-navigation-overlay {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
}

.nav-btn {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.nav-btn:hover {
    background: rgba(102, 126, 234, 0.9);
    border-color: white;
    transform: scale(1.15);
}

.nav-btn:active {
    transform: scale(0.95);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Loading State */
.preview-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.preview-loading .spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #764ba2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.preview-loading p {
    margin-top: 20px;
    color: #666;
    font-size: 0.95em;
}

/* Error State */
.preview-error {
    text-align: center;
    padding: 60px 20px;
    color: #d32f2f;
}

.preview-error p {
    margin: 0 0 8px 0;
    font-weight: bold;
    font-size: 1.05em;
}

.preview-error small {
    color: #666;
    font-size: 0.9em;
}

/* Image Info Bar */
.image-info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 15px;
    background: white;
    border-top: 1px solid #e0d4ff;
    border-bottom: 1px solid #e0d4ff;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85em;
}

.info-label {
    color: #888;
    font-weight: 600;
}

.info-value {
    color: #333;
    font-weight: 500;
}

/* Settings Display */
.preview-settings-display {
    padding: 15px;
}

.settings-section h4,
.recommendations-section h4 {
    margin: 0 0 10px 0;
    font-size: 0.95em;
    color: #667eea;
    font-weight: 700;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.setting-item {
    display: flex;
    gap: 6px;
    font-size: 0.85em;
}

.setting-label {
    color: #888;
    font-weight: 600;
}

.setting-value {
    color: #333;
    font-weight: 500;
}

/* Recommendations */
.recommendations-section {
    margin-top: 15px;
    padding: 12px;
    background: linear-gradient(135deg, #fff0f8 0%, #f8f9ff 100%);
    border-radius: 8px;
    border: 1px solid #d4a5ff;
}

.recommendation-text {
    margin: 5px 0;
    font-size: 0.9em;
    line-height: 1.6;
}

.recommendation-note {
    color: #666;
    font-size: 0.8em;
    display: block;
    margin-top: 8px;
}

/* Panel Footer */
.preview-panel-footer {
    padding: 12px 15px;
    border-top: 2px solid #e0d4ff;
    background: #f8f9ff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-left,
.footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    color: #666;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.footer-btn {
    padding: 6px 12px;
    font-size: 0.85em;
    border-radius: 6px;
    border: 1px solid #d4a5ff;
    background: white;
    color: #764ba2;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.footer-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #764ba2;
    transform: translateY(-2px);
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    background: transparent;
    z-index: 10;
}

.resize-n, .resize-s {
    width: 100%;
    height: 8px;
    cursor: ns-resize;
}

.resize-e, .resize-w {
    width: 8px;
    height: 100%;
    cursor: ew-resize;
}

.resize-n { top: 0; left: 0; }
.resize-s { bottom: 0; left: 0; }
.resize-e { top: 0; right: 0; }
.resize-w { top: 0; left: 0; }

.resize-ne, .resize-nw, .resize-se, .resize-sw {
    width: 15px;
    height: 15px;
}

.resize-ne {
    top: 0;
    right: 0;
    cursor: nesw-resize;
}

.resize-nw {
    top: 0;
    left: 0;
    cursor: nwse-resize;
}

.resize-se {
    bottom: 0;
    right: 0;
    cursor: nwse-resize;
}

.resize-sw {
    bottom: 0;
    left: 0;
    cursor: nesw-resize;
}

/* ==========================================
   📱 MOBILE RESPONSIVE STYLES
   ========================================== */

/* Tablet and below (768px) */
@media (max-width: 768px) {
    /* Container */
    .container {
        padding: 10px;
        max-width: 100%;
    }
    
    /* Header */
    header h1 {
        font-size: 2em;
    }
    
    header p {
        font-size: 1.1em;
    }
    
    /* Cards */
    .card {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .card h2 {
        font-size: 1.3em;
    }
    
    /* Upload area - Touch-friendly */
    .upload-area {
        min-height: 180px;
        padding: 30px 20px;
    }
    
    .upload-icon {
        font-size: 3em;
    }
    
    .upload-area p {
        font-size: 1em;
    }
    
    /* Options grid - Stack vertically */
    .options-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .option-group {
        margin-bottom: 15px;
    }
    
    .option-group label {
        font-size: 0.95em;
    }
    
    .option-group select,
    .option-group input {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 12px;
        width: 100%;
    }
    
    /* Buttons - Touch-friendly (44px minimum) */
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-success {
        min-height: 44px;
        padding: 14px 24px;
        font-size: 1em;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .btn-small {
        min-height: 38px;
        padding: 10px 16px;
    }
    
    /* Progress bar */
    .progress-container {
        margin: 20px 0;
    }
    
    /* Results grid - Stack vertically */
    .results-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .result-item {
        padding: 12px;
    }
    
    .result-item img {
        max-height: 300px;
    }
    
    /* Settings grid */
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Range sliders - Full width */
    input[type="range"] {
        width: 100%;
    }
    
    /* Color boxes */
    .color-box {
        width: 35px;
        height: 35px;
        min-width: 35px;
        min-height: 35px;
    }
    
    /* Emoji selector */
    .emoji-selector {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    
    .emoji-option {
        width: 50px;
        height: 50px;
    }
    
    .emoji-option img {
        width: 35px;
        height: 35px;
    }
    
    /* Advanced preview - Full screen on mobile */
    .advanced-preview-panel {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        transform: none !important;
        padding: 15px;
    }
    
    @keyframes slideInRight {
        from {
            transform: translateX(100%);
            opacity: 0;
        }
        to {
            transform: translateX(0);
            opacity: 1;
        }
    }
    
    .preview-image-container {
        height: calc(100vh - 180px);
    }
    
    .preview-header {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .preview-header h3 {
        font-size: 1.1em;
    }
    
    /* Template controls */
    .template-controls {
        padding: 15px;
    }
    
    .template-list {
        gap: 8px;
    }
    
    .template-item {
        padding: 10px 12px;
        flex-direction: column;
        gap: 8px;
    }
    
    .template-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    /* Status messages */
    .status-message {
        font-size: 0.95em;
        padding: 12px 15px;
    }
    
    /* Loading overlay */
    .loading-overlay {
        padding: 20px;
    }
    
    .loading-spinner {
        width: 50px;
        height: 50px;
    }
}

/* Small mobile (480px) */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.6em;
    }
    
    header p {
        font-size: 1em;
    }
    
    .card {
        padding: 15px;
    }
    
    .card h2 {
        font-size: 1.2em;
    }
    
    .upload-area {
        min-height: 150px;
        padding: 20px 15px;
    }
    
    .upload-icon {
        font-size: 2.5em;
    }
    
    .btn,
    .btn-primary,
    .btn-secondary {
        padding: 12px 20px;
        font-size: 0.95em;
    }
    
    .emoji-selector {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .result-item img {
        max-height: 250px;
    }
}

/* Landscape mobile */
@media (max-width: 896px) and (orientation: landscape) {
    header {
        padding: 20px;
    }
    
    header h1 {
        font-size: 1.5em;
    }
    
    .upload-area {
        min-height: 120px;
    }
    
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Touch-specific improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .upload-area {
        cursor: pointer;
        min-height: 200px;
    }
    
    .color-box,
    .emoji-option {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Prevent text selection during interaction */
    .emoji-selector,
    .color-boxes,
    .results-grid {
        -webkit-user-select: none;
        -moz-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
    
    /* Better spacing */
    .options-grid,
    .settings-grid {
        gap: 20px;
    }
}

/* Prevent zoom on input focus (iOS) */
@supports (-webkit-touch-callout: none) {
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
}


/* MOBILE BUTTON ALIGNMENT FIXES */
/* Add this to the END of existing CSS files - won't affect desktop! */

/* ========================================
   MOBILE-ONLY FIXES (max-width: 768px)
   Desktop is completely unaffected
   ======================================== */

@media (max-width: 768px) {
    
    /* FIX 1: Center all buttons on mobile */
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-large,
    button[type="submit"] {
        display: block !important;
        margin-left: auto !important;
        margin-right: auto !important;
        text-align: center !important;
    }
    
    /* FIX 2: Hero/CTA buttons container - center alignment */
    .hero-buttons,
    .cta-buttons,
    .demo-actions {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px !important;
    }
    
    /* FIX 3: Individual CTA buttons */
    .hero-buttons .btn,
    .cta-buttons .btn,
    .demo-actions .btn {
        width: 90% !important;
        max-width: 400px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    
    /* FIX 4: Form buttons - center text */
    .form-actions,
    .button-group,
    .action-buttons {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 10px !important;
    }
    
    .form-actions .btn,
    .button-group .btn,
    .action-buttons .btn {
        width: 90% !important;
        max-width: 400px !important;
    }
    
    /* FIX 5: Trial page - Apply & Preview buttons */
    #apply-btn,
    #preview-btn,
    button[onclick*="apply"],
    button[onclick*="preview"] {
        display: block !important;
        margin-left: auto !important;
        margin-right: auto !important;
        width: 90% !important;
        max-width: 400px !important;
    }
    
    /* FIX 6: Section containers - center content */
    section,
    .section,
    .card {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }
    
    /* FIX 7: Purple CTA sections */
    .cta-section,
    section[style*="background"],
    .hero-section {
        text-align: center !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    .cta-section .btn,
    section[style*="background"] .btn {
        display: block !important;
        margin: 10px auto !important;
        width: 90% !important;
        max-width: 400px !important;
    }
    
    /* FIX 8: Ask Questions page - form buttons */
    .question-form .btn,
    #questionForm .btn,
    form .btn-primary {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* ========================================
   END MOBILE-ONLY FIXES
   Desktop unaffected ✅
   ======================================== */
