﻿/* AdCanva Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --ac-bg: #0f172a;
    --ac-panel-bg: #1e293b;
    --ac-border: #334155;
    --ac-text: #e2e8f0;
    --ac-text-muted: #94a3b8;
    --ac-accent: #6366f1;
    --ac-accent-hover: #4f46e5;
    --ac-danger: #ef4444;
    --ac-radius: 12px;
}

body.adcanva-page {
    background-color: var(--ac-bg);
    color: var(--ac-text);
    font-family: 'Inter', system-ui, sans-serif;
}

/* Hide search bar on AdCanva page only */
body.adcanva-page #desktop-search,
body.adcanva-page #mobile-search {
    display: none !important;
}

.adcanva-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 10px;
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 10px;
}

.panel {
    background: var(--ac-panel-bg);
    border: 1px solid var(--ac-border);
    border-radius: var(--ac-radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid var(--ac-border);
    padding-bottom: 12px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ac-text-muted);
    margin-bottom: 6px;
    display: block;
}

input[type="text"],
input[type="number"],
input[type="url"],
input[type="email"],
input[type="file"],
select,
textarea {
    width: 100%;
    background: #0f172a;
    border: 1px solid var(--ac-border);
    color: var(--ac-text);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--ac-accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--ac-accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--ac-accent-hover);
}

.btn-secondary {
    background: #334155;
    color: #fff;
}

.btn-secondary:hover {
    background: #475569;
}

.btn.active {
    background: var(--ac-accent);
    color: #fff;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--ac-danger);
}

.btn-group {
    display: flex;
    gap: 8px;
}

.btn-group .btn {
    flex: 1;
}

.advanced-box {
    background: #0f172a;
    border: 1px solid var(--ac-border);
    border-radius: 8px;
    padding: 16px;
    margin-top: 8px;
    display: none;
}

.advanced-box.open {
    display: block;
}

.preview-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    background: #0f172a;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--ac-border);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slots-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, #1e293b 0%, #0f172a 100%);
    border-radius: var(--ac-radius);
    border: 1px solid var(--ac-border);
    overflow: hidden;
    padding: 0;
    margin: 0 auto;
}

/* Wrapper to center the inline-flex container */
.panel.full-width {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
}

.slot {
    display: none;
    margin: 0;
    padding: 0;
}

.slot.active {
    display: flex;
}

.frame {
    position: relative;
    transition: transform 0.3s ease;
    transform-origin: center center;
    filter: drop-shadow(0 35px 70px rgba(0, 0, 0, 0.7));
}

.frame.mobile {
    width: 375px;
    height: 812px;
    background: linear-gradient(145deg, #2d2d2d 0%, #1a1a1a 50%, #0f0f0f 100%);
    border-radius: 44px;
    padding: 12px;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.15),
        inset 0 0 0 8px #050505,
        inset 0 0 0 9px #2d2d2d,
        inset 0 0 0 10px rgba(255, 255, 255, 0.05),
        0 0 0 1px rgba(0, 0, 0, 0.9),
        0 8px 20px rgba(0, 0, 0, 0.4),
        0 20px 40px rgba(0, 0, 0, 0.3);
}

/* Dynamic Island (iPhone 14 Pro style) */
.frame.mobile::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 126px;
    height: 37px;
    background: #000;
    border-radius: 20px;
    z-index: 10;
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.8),
        0 1px 2px rgba(255, 255, 255, 0.1);
}

/* Front camera in Dynamic Island */
.frame.mobile::after {
    content: '';
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-20px);
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, #1a1a3a 0%, #000 100%);
    border-radius: 50%;
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.8),
        0 0 0 1px rgba(255, 255, 255, 0.15);
    z-index: 11;
}

/* Power button (right side) */
.frame.mobile .power-btn {
    position: absolute;
    right: -2px;
    top: 180px;
    width: 4px;
    height: 80px;
    background: linear-gradient(90deg, #1a1a1a 0%, #2d2d2d 50%, #1a1a1a 100%);
    border-radius: 2px 0 0 2px;
    box-shadow: inset 1px 0 2px rgba(0, 0, 0, 0.5);
}

/* Volume buttons (left side) */
.frame.mobile .volume-up {
    position: absolute;
    left: -2px;
    top: 140px;
    width: 4px;
    height: 50px;
    background: linear-gradient(90deg, #2d2d2d 0%, #1a1a1a 50%, #2d2d2d 100%);
    border-radius: 0 2px 2px 0;
    box-shadow: inset -1px 0 2px rgba(0, 0, 0, 0.5);
}

.frame.mobile .volume-down {
    position: absolute;
    left: -2px;
    top: 200px;
    width: 4px;
    height: 50px;
    background: linear-gradient(90deg, #2d2d2d 0%, #1a1a1a 50%, #2d2d2d 100%);
    border-radius: 0 2px 2px 0;
    box-shadow: inset -1px 0 2px rgba(0, 0, 0, 0.5);
}

/* Silent switch */
.frame.mobile .silent-switch {
    position: absolute;
    left: -2px;
    top: 100px;
    width: 3px;
    height: 25px;
    background: linear-gradient(90deg, #2d2d2d 0%, #1a1a1a 50%, #2d2d2d 100%);
    border-radius: 0 2px 2px 0;
    box-shadow: inset -1px 0 2px rgba(0, 0, 0, 0.5);
}

/* Bottom speaker grille */
.frame.mobile .speaker-bottom {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 6px;
    background: repeating-linear-gradient(90deg,
            #0a0a0a 0px,
            #0a0a0a 2px,
            transparent 2px,
            transparent 4px);
    border-radius: 3px;
    z-index: 10;
}

.frame.mobile.landscape {
    width: 812px;
    height: 375px;
}

/* Hide notch and buttons in landscape */
.frame.mobile.landscape::before,
.frame.mobile.landscape::after,
.frame.mobile.landscape .power-btn,
.frame.mobile.landscape .volume-up,
.frame.mobile.landscape .volume-down,
.frame.mobile.landscape .silent-switch,
.frame.mobile.landscape .speaker-bottom {
    display: none;
}

.frame.tablet {
    width: 820px;
    height: 1180px;
    background: linear-gradient(145deg, #3d3d3d 0%, #2a2a2a 50%, #1a1a1a 100%);
    border-radius: 34px;
    padding: 8px;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.2),
        inset 0 0 0 14px #0f0f0f,
        inset 0 0 0 15px #3d3d3d,
        inset 0 0 0 16px rgba(255, 255, 255, 0.08),
        0 0 0 1px rgba(0, 0, 0, 0.9),
        0 10px 25px rgba(0, 0, 0, 0.5),
        0 25px 50px rgba(0, 0, 0, 0.4);
}

/* Tablet front camera */
.frame.tablet::before {
    content: '';
    position: absolute;
    top: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    background: radial-gradient(circle, #1a1a3a 0%, #000 100%);
    border-radius: 50%;
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.8),
        0 0 0 1px rgba(255, 255, 255, 0.15),
        0 0 4px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

/* Tablet power button (top) */
.frame.tablet .power-btn {
    position: absolute;
    top: -2px;
    right: 100px;
    width: 60px;
    height: 4px;
    background: linear-gradient(180deg, #2d2d2d 0%, #1a1a1a 50%, #2d2d2d 100%);
    border-radius: 0 0 2px 2px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Tablet volume buttons (right side) */
.frame.tablet .volume-up {
    position: absolute;
    right: -2px;
    top: 200px;
    width: 4px;
    height: 60px;
    background: linear-gradient(90deg, #1a1a1a 0%, #2d2d2d 50%, #1a1a1a 100%);
    border-radius: 2px 0 0 2px;
    box-shadow: inset 1px 0 2px rgba(0, 0, 0, 0.5);
}

.frame.tablet .volume-down {
    position: absolute;
    right: -2px;
    top: 270px;
    width: 4px;
    height: 60px;
    background: linear-gradient(90deg, #1a1a1a 0%, #2d2d2d 50%, #1a1a1a 100%);
    border-radius: 2px 0 0 2px;
    box-shadow: inset 1px 0 2px rgba(0, 0, 0, 0.5);
}

.frame.tablet.landscape {
    width: 1180px;
    height: 820px;
}

/* Tablet landscape camera and button positions */
.frame.tablet.landscape::before {
    top: 50%;
    left: 25px;
    transform: translateY(-50%);
}

.frame.tablet.landscape .power-btn {
    top: 100px;
    right: -2px;
    width: 4px;
    height: 60px;
    border-radius: 2px 0 0 2px;
}

.frame.tablet.landscape .volume-up {
    top: -2px;
    right: 200px;
    width: 60px;
    height: 4px;
    border-radius: 0 0 2px 2px;
}

.frame.tablet.landscape .volume-down {
    top: -2px;
    right: 270px;
    width: 60px;
    height: 4px;
    border-radius: 0 0 2px 2px;
}

.ad-container {
    width: 100%;
    height: 100%;
    background: #fff;
    position: relative;
    overflow: hidden;
}

.rendered-ad {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    cursor: move;
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.5);
}

.rendered-ad img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
    pointer-events: none;
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, transparent 50%, var(--ac-accent) 50%);
    cursor: nwse-resize;
    z-index: 10;
}

.log-box {
    background: #0f172a;
    border: 1px solid var(--ac-border);
    border-radius: 8px;
    padding: 12px;
    height: 300px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.85rem;
}

.log-entry {
    padding: 4px 0;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.log-ts {
    color: var(--ac-text-muted);
    min-width: 70px;
}

.log-type {
    font-weight: 700;
    min-width: 60px;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.log-type.render {
    color: #60a5fa;
}

.log-type.imp {
    color: #34d399;
}

.log-type.click {
    color: #fbbf24;
}

.log-type.error {
    color: #f87171;
}

@media (max-width: 1200px) {
    .adcanva-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .adcanva-container {
        padding: 8px;
        gap: 8px;
    }

    .panel {
        padding: 16px;
    }

    .slots-container {
        padding: 10px;
        min-height: 400px;
    }
}