/* ===== CSS Variables & Reset ===== */
:root {
    --primary-color: #f38020;
    --primary-hover: #e06d0f;
    --secondary-color: #6366f1;
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252541;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b8;
    --border-color: #2d2d44;
    --success-color: #10b981;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(243, 128, 32, 0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow: hidden; /* Prevent body scroll for full app feel */
}

/* ===== Container ===== */
.container {
    max-width: 100%;
    margin: 0;
    padding: 0;
    height: calc(100vh - 70px);
}

/* ===== Header ===== */
/* ===== Navbar ===== */
.navbar {
    width: 100%;
    height: 70px;
    background: rgba(15, 15, 35, 0.85); /* Dark semi-transparent */
    backdrop-filter: blur(12px);
    border-bottom: 1px solid #2d2d44;
    position: sticky; /* Sticky top */
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-logo {
    width: 36px;
    height: 36px;
    color: var(--primary-color);
}

.brand-text {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    line-height: 1.2;
}

.brand-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    background: none;
    -webkit-text-fill-color: initial;
}

.beta-tag {
    background: rgba(243, 128, 32, 0.15);
    color: var(--primary-color);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
    border: 1px solid rgba(243, 128, 32, 0.3);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.5rem;
    transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
}

.btn-github {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #252541;
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid #2d2d44;
    transition: var(--transition);
}

.btn-github:hover {
    background: #2d2d44;
    border-color: #3e3e5e;
}

/* Adjust Main Content to not overlap/hide under sticky nav if needed (sticky works fine) */
/* Adjust Main Content to not overlap/hide under sticky nav if needed (sticky works fine) */
.main-content {
    padding-top: 0;
}

/* ===== Main Content ===== */
/* ===== Main Content ===== */
.main-content {
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 0; /* Remove gap for full panel look */
    height: 100%;
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

/* ===== Panel Styles ===== */
.editor-panel,
.preview-panel {
    background: var(--bg-secondary);
    border-radius: 0; /* Remove radius for full fit */
    border: none;
    overflow: hidden;
    /* box-shadow: var(--shadow-lg); */ /* Remove shadow for flat look */
    transition: var(--transition);
}

.editor-panel:hover,
.preview-panel:hover {
    border-color: rgba(243, 128, 32, 0.3);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.panel-header {
    padding: 1rem;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.preview-controls {
    display: flex;
    gap: 0.5rem;
}

/* ===== Editor Panel ===== */
.editor-panel {
    height: 100%;
    max-height: none; /* Allow full height */
    overflow-y: auto;
    overflow-x: hidden;
    background: #1e1e2d; 
    border-right: 1px solid var(--border-color);
}

.panel-header {
    padding: 1rem 1.25rem;
    background: #151521;
    border-bottom: 1px solid #2a2a35;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
}

/* ===== Section Titles ===== */
.section-title {
    color: #ffd700; /* Gold/Yellow for contrast or keep basic */
    color: var(--primary-color);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    margin: 1.5rem 1.25rem 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    opacity: 0.9;
}

/* ===== Form Groups ===== */
.form-group {
    padding: 0.75rem 1.25rem;
    border-bottom: none; /* Removed heavy lines */
    transition: var(--transition);
}

.form-group:hover {
    background: rgba(255, 255, 255, 0.02);
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: var(--text-secondary); /* Lighter label */
    font-size: 0.8rem;
    letter-spacing: 0.02em;
}

/* ===== Input Fields ===== */
.input-field {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: #14141f; /* Darker input bg */
    border: 1px solid #2d2d3a;
    border-radius: 6px;
    color: #ececf1;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    outline: none;
}

.input-field:focus {
    border-color: var(--primary-color);
    background: #0f0f19;
    box-shadow: 0 0 0 2px rgba(243, 128, 32, 0.2);
}

.input-field::placeholder {
    color: rgba(160, 160, 184, 0.4);
}

.textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
    line-height: 1.5;
}

select.input-field {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23a0a0b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    appearance: none;
}

/* ===== Color Picker ===== */
.color-picker-group {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 0.75rem;
    align-items: center;
}

.color-input {
    width: 48px;
    height: 38px;
    border: 1px solid #2d2d3a;
    padding: 2px;
    border-radius: 6px;
    cursor: pointer;
    background: #14141f;
    transition: var(--transition);
}

.color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

.color-input:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.color-text {
    text-transform: uppercase;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

/* ===== Checkbox ===== */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
    margin-bottom: 0;
    color: var(--text-primary) !important; /* Override label color for checkbox text */
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: #14141f;
    position: relative;
    transition: var(--transition);
}

.checkbox-label:hover .checkbox-custom {
    border-color: var(--primary-color);
}

.checkbox-label input[type="checkbox"]:checked ~ .checkbox-custom {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-label input[type="checkbox"]:checked ~ .checkbox-custom::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ===== Buttons ===== */
.btn-primary,
.btn-secondary,
.btn-icon {
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    outline: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: calc(100% - 2.5rem); /* Adjust for new padding */
    margin: 1.25rem;
    padding: 0.8rem 1.25rem;
    box-shadow: 0 4px 6px -1px rgba(243, 128, 32, 0.2);
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 10px -1px rgba(243, 128, 32, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid #2d2d3a;
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(243, 128, 32, 0.05);
}

.btn-icon {
    padding: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: 4px;
}

.btn-icon:hover {
    color: var(--primary-color);
    background: rgba(243, 128, 32, 0.1);
}

/* ===== Preview Panel ===== */
.preview-panel {
    display: flex;
    flex-direction: column;
}

.preview-container {
    flex: 1;
    background: #f5f5f5;
    position: relative;
    height: 100%;
    min-height: 0;
}

#previewFrame,
#fullscreenFrame {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

/* ===== Toast Notification ===== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--success-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-lg);
    transform: translateY(150%);
    opacity: 0;
    transition: var(--transition);
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast svg {
    flex-shrink: 0;
}

/* ===== Fullscreen Modal ===== */
.fullscreen-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 999;
    display: none;
    flex-direction: column;
}

.fullscreen-modal.active {
    display: flex;
}

.fullscreen-header {
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.fullscreen-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: var(--transition);
}

.btn-close:hover {
    color: var(--primary-color);
    background: rgba(243, 128, 32, 0.1);
}

#fullscreenFrame {
    flex: 1;
}

/* ===== Animations ===== */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* ===== Responsive Design ===== */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 400px 1fr;
    }
}

@media (max-width: 968px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .editor-panel {
        max-height: none;
    }
    
    .preview-container {
        min-height: 600px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }
    
    .header h1 {
        font-size: 1.75rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .form-group {
        padding: 1rem;
    }
    
    .btn-primary {
        width: calc(100% - 2rem);
        margin: 1rem;
    }
}
