/* Core Variables */
.aiwt-app {
    --ilove-red: #e5322d;
    --ilove-red-hover: #cc2a26;
    --ilove-dark: #333333;
    --ilove-gray: #f2f2f2;
    --ilove-border: #e0e0e0;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: var(--ilove-dark);
    box-sizing: border-box;
}

.aiwt-app * { box-sizing: border-box; }

/* STATE CONTROLS */
.aiwt-state-hidden { display: none !important; }
.aiwt-state-active { display: block; }

/* --- STATE 1: GIANT UPLOAD SCREEN --- */
#aiwt-upload-state {
    text-align: center;
    padding: 80px 20px;
    background: #fafafa;
    border: 2px dashed #dcdcdc;
    border-radius: 12px;
    margin: 20px 0;
    transition: 0.3s;
}
#aiwt-upload-state:hover { background: #fdfdfd; border-color: #bbbbbb; }

.aiwt-hero-title { font-size: 2.5rem; font-weight: 700; margin: 20px 0 10px; color: #111; }
.aiwt-hero-subtitle { font-size: 1.2rem; color: #666; margin-bottom: 40px; }

.aiwt-giant-btn {
    background: var(--ilove-red);
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    padding: 24px 48px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(229, 50, 45, 0.3);
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
}
.aiwt-giant-btn:hover { background: var(--ilove-red-hover); transform: translateY(-2px); }
.aiwt-drag-text { margin-top: 15px; color: #888; font-size: 0.95rem; }

/* --- STATE 2: WORKSPACE --- */
.aiwt-workspace-layout {
    display: flex;
    height: 75vh;
    min-height: 600px;
    border: 1px solid var(--ilove-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--ilove-gray);
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}

/* Left Canvas Area */
.aiwt-canvas-zone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
    /* Photoshop Checkerboard */
    background-image: linear-gradient(45deg, #e5e5e5 25%, transparent 25%), linear-gradient(-45deg, #e5e5e5 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e5e5e5 75%), linear-gradient(-45deg, transparent 75%, #e5e5e5 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}
#aiwt-canvas {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    cursor: grab;
    background-color: transparent;
}
#aiwt-canvas:active { cursor: grabbing; }

/* Right Sidebar Background & Container */
.aiwt-sidebar {
    width: 360px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--ilove-border);
    z-index: 10;
}

.aiwt-sidebar-header {
    background: #ffffff;
    padding: 24px 20px;
    border-bottom: 1px solid var(--ilove-border);
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    z-index: 2;
}
.aiwt-sidebar-header h3 { 
    margin: 0; 
    font-size: 1.25rem; 
    font-weight: 800; 
    color: #0f172a;
    display: flex;
    align-items: center;
}

.aiwt-sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Premium Setting Cards */
.aiwt-setting-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.aiwt-setting-card:hover {
    box-shadow: 0 6px 12px rgba(0,0,0,0.04);
    border-color: #cbd5e1;
}

/* The New Premium Headings */
.aiwt-premium-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.aiwt-premium-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: #fef2f2;
    color: var(--ilove-red);
    border-radius: 8px;
}

/* Inputs */
.aiwt-text-input, .aiwt-select-input, .aiwt-file-input, .aimp-input-small input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
    background: #f8fafc;
    transition: 0.2s;
}
.aiwt-text-input:focus, .aiwt-select-input:focus, .aimp-input-small input:focus { 
    outline: none; 
    border-color: var(--ilove-red); 
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(229, 50, 45, 0.1);
}

textarea.aiwt-text-input { font-family: inherit; }

.aiwt-grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.aiwt-color-input { width: 100%; height: 42px; border: 1px solid #cbd5e1; border-radius: 6px; padding: 2px; cursor: pointer; }

/* 4-Column Grid for Margins */
.aiwt-grid-4-margin { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.aimp-input-small label { display: block; font-size: 0.75rem; font-weight: bold; color: #555; text-align: center; margin-bottom: 6px;}
.aimp-input-small input { text-align: center; padding: 8px; font-size: 0.9rem; }

/* Text Formatting Bar */
.aiwt-format-bar {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.aiwt-format-btn {
    flex: 1;
    text-align: center;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    background: #f8fafc;
    transition: 0.2s;
}
.aiwt-format-btn input:checked + b, 
.aiwt-format-btn input:checked + i,
.aiwt-format-btn input:checked + u { color: var(--ilove-red); }
.aiwt-format-btn:has(input:checked) { border-color: var(--ilove-red); background: #fdf5f5; }

/* Premium Sliders */
.aiwt-label {
    display: block;
    font-size: 0.85rem;
    font-weight: bold;
    color: #555;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.aiwt-slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
    margin-top: 16px;
}
.aiwt-slider-label:first-of-type { margin-top: 0; }
.aiwt-slider {
    width: 100%;
    accent-color: var(--ilove-red);
}

/* Mosaic Pattern Toggle Card */
.aiwt-pattern-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.aiwt-pattern-card:hover {
    border-color: var(--ilove-red);
    background: #fdfafb;
    box-shadow: 0 6px 12px rgba(0,0,0,0.04);
}
.aiwt-pattern-text {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.95rem;
    display: block;
    margin-bottom: 2px;
}
.aiwt-pattern-sub {
    font-size: 0.75rem;
    color: #64748b;
    display: block;
}
.aiwt-checkbox { 
    width: 22px; 
    height: 22px; 
    accent-color: var(--ilove-red); 
    cursor: pointer;
}

/* Footer Action Button */
.aiwt-sidebar-footer {
    padding: 20px;
    background: #ffffff;
    border-top: 1px solid var(--ilove-border);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.02);
}
.aiwt-action-btn {
    width: 100%;
    background: var(--ilove-red);
    color: white;
    font-size: 1.15rem;
    font-weight: 800;
    padding: 18px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.2s;
    box-shadow: 0 4px 12px rgba(229, 50, 45, 0.2);
}
.aiwt-action-btn:hover { 
    background: var(--ilove-red-hover); 
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(229, 50, 45, 0.3);
}

/* Mobile */
@media (max-width: 800px) {
    .aiwt-workspace-layout { flex-direction: column; height: auto; }
    .aiwt-canvas-zone { height: 400px; padding: 20px; }
    .aiwt-sidebar { width: 100%; border-left: none; border-top: 1px solid var(--ilove-border); }
}