/* ========================================
   AD CONFIGURATION
   Set to 'block' to show ads, 'none' to hide
   ======================================== */
:root {
    --ads-display: none; /* Change to 'block' to enable ads */
    --ad-placeholder-bg: #ff6b6b;
    --ad-placeholder-border: #ff0000;
}

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

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #0f1115;
    min-height: 100vh;
    padding: 40px 20px;
    color: #d6d6d6;
}

/* Layout */
.page-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
    max-width: 1100px;
    margin: 0 auto;
}

.container {
    background: #16181d;
    border: 2px solid #2a2d36;
    box-shadow: 12px 12px 0 #0a0b0e;
}

/* Header */
header {
    padding: 60px 40px 40px 40px;
    border-bottom: 2px solid #2a2d36;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    color: #ffffff;
}

.highlight {
    position: relative;
    color: #9b5de5;
    display: inline-block;
    text-shadow: 0.2rem 0.2rem 0.5rem #000000;
}

header p {
    margin-top: 12px;
    font-size: 1rem;
    color: #8b90a0;
}

/* Main */
main {
    padding: 50px 40px;
}

section {
    margin-bottom: 50px;
}

section h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 20px;
}

/* Upload Section */
.file-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.file-label {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 26px;
    background: #1d2027;
    border: 2px solid #3a3f4b;
    font-weight: 600;
    cursor: pointer;
    width: auto;
    align-self: flex-start;
    box-shadow: 6px 6px 0 #0a0b0e;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.file-label:hover {
    transform: translate(3px, 3px);
    box-shadow: 3px 3px 0 #0a0b0e;
    background: #242833;
}

#imageInput {
    display: none;
}

.file-count {
    font-size: 0.9rem;
    color: #777d8f;
}

/* Images Grid */
.images-section {
    padding: 30px;
    border: 2px solid #2a2d36;
    background: #14161b;
}

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.image-card {
    border: 2px solid #2a2d36;
    background: #1a1d23;
}

.image-card-header {
    padding: 12px 15px;
    border-bottom: 2px solid #2a2d36;
    background: #14161b;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.image-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #8b90a0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-remove {
    background: #d64545;
    color: white;
    border: none;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}

.image-remove:hover {
    transform: scale(1.1);
}

.image-preview {
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 120px;
}

.image-preview img {
    max-width: 100%;
    max-height: 100px;
    display: block;
}

.image-channels {
    padding: 10px;
    border-top: 2px solid #2a2d36;
    background: #14161b;
}

.channel-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.channel-chip {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #1d2027;
    border: 2px solid #3a3f4b;
    color: #b0b6c6;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
}

.channel-chip:hover {
    background: #242833;
    border-color: #9b5de5;
    transform: translateY(-2px);
}

.channel-chip:active {
    cursor: grabbing;
}

.channel-chip.dragging {
    opacity: 0.5;
}

/* Slots Section */
.slots-section {
    padding: 30px;
    border: 2px solid #2a2d36;
    background: #14161b;
}

.slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.channel-slot {
    border: 2px solid #2a2d36;
    background: #1a1d23;
    transition: transform 0.2s;
}

.channel-slot.drag-over {
    border-color: #9b5de5;
    background: #1d2027;
}

.slot-header {
    padding: 15px 20px;
    border-bottom: 2px solid #2a2d36;
    background: #14161b;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slot-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #b0b6c6;
}

.slot-clear {
    background: #d64545;
    color: white;
    border: 2px solid #2a2d36;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}

.slot-clear:hover {
    transform: scale(1.1);
}

.slot-dropzone {
    position: relative;
    min-height: 180px;
    padding: 20px;
}

.slot-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 140px;
}

.slot-icon {
    width: 50px;
    height: 50px;
    border: 2px solid #3a3f4b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.5rem;
    color: #5c6272;
}

.slot-placeholder p {
    font-size: 0.85rem;
    color: #5c6272;
}

.slot-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.slot-canvas {
    width: 100%;
    max-height: 120px;
    display: block;
    border: 1px solid #2a2d36;
}

.slot-info {
    font-size: 0.75rem;
    color: #8b90a0;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #2a2d36;
}

/* Channel Grid - Legacy (keeping for backward compatibility) */
.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.channel-card {
    border: 2px solid #2a2d36;
    background: #14161b;
    transition: transform 0.2s;
}

.channel-card:hover {
    transform: translateY(-2px);
}

.channel-header {
    padding: 15px 20px;
    border-bottom: 2px solid #2a2d36;
    background: #1a1d23;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.channel-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #b0b6c6;
}

.channel-clear {
    background: #d64545;
    color: white;
    border: 2px solid #2a2d36;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}

.channel-clear:hover {
    transform: scale(1.1);
}

/* Dropzone */
.dropzone {
    position: relative;
    min-height: 180px;
    padding: 30px 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.dropzone:hover {
    background: #1a1d23;
}

.dropzone.dragover {
    background: #1d2027;
    border: 2px dashed #9b5de5;
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
}

.dropzone-content svg {
    color: #5c6272;
}

.dropzone-text {
    font-weight: 600;
    font-size: 0.9rem;
    color: #8b90a0;
}

.dropzone-hint {
    font-size: 0.8rem;
    color: #5c6272;
    font-style: italic;
}

.preview-canvas {
    max-width: 100%;
    max-height: 180px;
    display: block;
    border: 1px solid #2a2d36;
}

.channel-info {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    padding: 6px 10px;
    font-size: 0.75rem;
    color: #8b90a0;
    border: 1px solid #2a2d36;
}

/* Settings Section */
.settings-section {
    padding: 30px;
    border: 2px solid #2a2d36;
    background: #14161b;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.setting-group label {
    font-weight: 600;
    color: #b0b6c6;
    white-space: nowrap;
}

.setting-group select {
    padding: 10px 18px;
    border: 2px solid #3a3f4b;
    background: #1d2027;
    color: #e0e0e0;
    font-size: 1rem;
    outline: none;
}

.setting-group select:focus {
    background: #242833;
}

.quality-slider {
    display: flex;
    align-items: center;
    gap: 12px;
}

.setting-group input[type="range"] {
    width: 150px;
    height: 6px;
    appearance: none;
    -webkit-appearance: none;
    background: #3a3f4b;
    outline: none;
    border: none;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #9b5de5;
    cursor: pointer;
}

.setting-group input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #9b5de5;
    border: none;
    cursor: pointer;
}

.quality-value {
    font-weight: 600;
    color: #ffffff;
    min-width: 40px;
}

/* Buttons */
.action-section {
    display: flex;
    gap: 20px;
}

button {
    padding: 14px 28px;
    font-size: 0.95rem;
    font-weight: 700;
    background: #1d2027;
    color: #ffffff;
    border: 2px solid #3a3f4b;
    cursor: pointer;
    box-shadow: 8px 8px 0 #0a0b0e;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

button:hover:not(:disabled) {
    transform: translate(4px, 4px);
    box-shadow: 4px 4px 0 #0a0b0e;
    background: #242833;
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-download {
    width: 100%;
    margin-top: 30px;
    background: #9b5de5;
    border-color: #9b5de5;
    box-shadow: 8px 8px 0 #0a0b0e;
}

.btn-download:hover {
    transform: translate(4px, 4px);
    box-shadow: 4px 4px 0 #0a0b0e;
}

/* Result Section */
.result-section {
    margin-top: 60px;
    padding: 40px;
    border: 2px solid #2a2d36;
    background: #14161b;
}

.result-section h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: #ffffff;
}

.result-info {
    margin-bottom: 20px;
    font-weight: 600;
    color: #8b90a0;
}

.canvas-wrapper {
    margin-top: 20px;
    padding: 20px;
    border: 2px solid #2a2d36;
    background: #1a1d23;
}

#outputCanvas {
    max-width: 100%;
    display: block;
    border: 2px solid #2a2d36;
}

/* Channel Preview */
.channel-preview-section {
    margin-top: 30px;
    padding: 20px;
    border: 2px solid #2a2d36;
    background: #1a1d23;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.channel-preview-section label {
    font-weight: 600;
    color: #b0b6c6;
}

.channel-toggles {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.channel-toggle {
    padding: 10px 20px;
    font-size: 0.85rem;
    background: #14161b;
    border: 2px solid #3a3f4b;
    box-shadow: 4px 4px 0 #0a0b0e;
}

.channel-toggle.active {
    background: #9b5de5;
    border-color: #9b5de5;
}

.channel-toggle:hover:not(.active) {
    background: #1d2027;
}

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

    main {
        padding: 30px 20px;
    }

    .channels-grid {
        grid-template-columns: 1fr;
    }

    .settings-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .action-section {
        flex-direction: column;
    }

    button {
        width: 100%;
    }
    
    .channel-preview-section {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ========================================
   AD PLACEHOLDERS
   ======================================== */

.ad-placeholder {
    display: var(--ads-display);
    background: var(--ad-placeholder-bg);
    border: 3px dashed var(--ad-placeholder-border);
    padding: 20px;
    text-align: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    position: relative;
    overflow: hidden;
}

.ad-placeholder::before {
    content: '📢 AD SPACE';
    display: block;
    margin-bottom: 8px;
    font-size: 1.2rem;
}

.ad-placeholder::after {
    content: attr(data-size);
    display: block;
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 8px;
}

/* Top Banner Ad - Above header */
.ad-top-banner {
    width: 100%;
    min-height: 90px;
}

/* Sidebar Ads - Fixed on sides of container */
.ad-sidebar {
    position: fixed;
    width: 160px;
    min-height: 600px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
}

.ad-sidebar-left {
    left: 20px;
}

.ad-sidebar-right {
    right: 20px;
}

/* In-content Ad - Between sections */
.ad-in-content {
    width: 100%;
    min-height: 250px;
    margin: 40px 0;
}

/* Bottom Banner Ad - After main content */
.ad-bottom-banner {
    width: 100%;
    min-height: 90px;
    margin-top: 40px;
}

/* Small rectangle ad - in sidebar or corner */
.ad-rectangle {
    width: 300px;
    min-height: 250px;
}

/* Leaderboard ad */
.ad-leaderboard {
    width: 728px;
    max-width: 100%;
    min-height: 90px;
    margin: 0 auto;
}

/* Responsive ad sizing */
@media (max-width: 1400px) {
    .ad-sidebar {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .ad-leaderboard {
        width: 100%;
        min-height: 50px;
    }
    
    .ad-in-content {
        min-height: 100px;
    }
    
    /* Hide sidebar ads on mobile */
    .ad-sidebar {
        display: none !important;
    }
}

/* Pointer-drag ghost chip */
.drag-ghost {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #9b5de5;
    border: 2px solid #c49af5;
    color: #ffffff;
    user-select: none;
    cursor: grabbing;
    box-shadow: 4px 4px 0 #0a0b0e;
}