:root {
    --bg-color: #0b1121;
    --panel-bg: #151e32;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --accent-color: #10b981;
    --accent-hover: #059669;
    --border-color: #27354f;
    --font-family: 'Outfit', sans-serif;
    --transition: all 0.2s ease;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.builder-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: .5rem;
    gap: .5rem;
}

.builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel-bg);
    padding: .5rem .5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.header-brand h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(to right, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.header-brand p { color: var(--text-secondary); font-size: 0.9rem; }

.header-actions { display: flex; gap: 1rem; align-items: center; }

.main-content {
    display: grid;
    grid-template-columns: 6fr 3fr 3fr;
    gap: .5rem;
    flex: 1;
    overflow: hidden;
}

.panel {
    background: var(--panel-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: .5rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.panel h2 {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.row-group { display: flex; gap: 0.5rem; }
.row-group .input-group { 
    flex: 1; 
    flex-direction: row; 
    align-items: center; 
    justify-content: space-between; 
    gap: 0.5rem; 
    margin-bottom: 1rem;
}

.input-group { margin-bottom: 1.2rem; display: flex; flex-direction: column; }
.flex-grow { flex: 1; }
.input-group label {
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.input-group input[type="text"],
.input-group input[type="number"],
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 0.6rem 0.5rem;
    background: rgba(11, 17, 33, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: white;
    font-family: var(--font-family);
    font-size: 0.95rem;
    transition: var(--transition);
}
.input-group textarea { resize: none; flex: 1; }

.row-group .input-group label { margin-bottom: 0; flex: 0 0 140px; font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-group .input-group input[type="number"], 
.row-group .input-group input[type="text"], 
.row-group .input-group select { flex: 1; width: 0; height: 36px; padding: 0 0.5rem; font-size: 0.85rem; box-sizing: border-box; }

.input-group input:focus, .input-group select:focus, .input-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Remove number input up/down arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

.custom-file-btn {
    display: inline-block;
    padding: 0.5rem 0.8rem;
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary-color);
    border: 1px dashed var(--primary-color);
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    font-size: 0.8rem;
    transition: var(--transition);
    margin-bottom: 0.2rem;
}
.custom-file-btn:hover { background: rgba(59, 130, 246, 0.25); }
.file-name-text { font-size: 0.75rem; color: var(--text-secondary); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.file-drop-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    background: rgba(11, 17, 33, 0.4);
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
    min-height: 120px;
}
.file-drop-area:hover { border-color: var(--primary-color); }
.file-input {
    position: absolute; left: 0; top: 0; height: 100%; width: 100%;
    cursor: pointer; opacity: 0; z-index: 10;
}
.file-msg { 
    font-size: 0.85rem; color: var(--text-secondary); z-index: 2; 
    position: relative; background: rgba(11, 17, 33, 0.8); 
    padding: 4px 8px; border-radius: 4px; pointer-events: none;
    max-width: 95%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#image-preview {
    max-width: 100%; height: 120px; object-fit: contain; z-index: 1; border-radius: 4px;
}

.btn {
    margin: 0;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1;
    padding: 0 1.2rem;
    height: 44px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-sizing: border-box;
    vertical-align: middle;
}

.primary-btn { background: var(--primary-color); color: white; }
.primary-btn:hover:not(:disabled) { background: var(--primary-hover); }
.accent-btn { background: var(--accent-color); color: white; }
.accent-btn:hover:not(:disabled) { background: var(--accent-hover); }

.btn-import { background: #8b5cf6; color: white; }
.btn-import:hover:not(:disabled) { background: #7c3aed; }
.btn-settings { background: #0ea5e9; color: white; }
.btn-settings:hover:not(:disabled) { background: #0284c7; }
.btn-import-settings { background: #14b8a6; color: white; }
.btn-import-settings:hover:not(:disabled) { background: #0d9488; }
.btn-export { background: #f59e0b; color: white; }
.btn-export:hover:not(:disabled) { background: #d97706; }

.outline-btn { background: transparent; border-color: var(--border-color); color: var(--text-secondary); }
.outline-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.05); color: white; }

.emoji-icon { font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; font-weight: normal; font-size: 1.1em; }
.submit-btn { background: var(--primary-color); color: white; width: 100%; margin-top: auto; padding: 1rem; }

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

.action-buttons { display: flex; flex-direction: column; gap: 0.8rem; margin-top: 1.5rem; }

/* Slides List */
.list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.list-header h2 { margin: 0; }
.badge { background: var(--primary-color); color: white; padding: 0.2rem 0.6rem; border-radius: 12px; font-size: 0.8rem; font-weight: bold; }

.slides-list { display: flex; flex-direction: column; gap: 0.8rem; }
.empty-state { text-align: center; color: var(--text-secondary); padding: 2rem; font-size: 0.9rem; border: 1px dashed var(--border-color); border-radius: 8px; }

.slide-item {
    display: flex; gap: 0.8rem; background: rgba(11, 17, 33, 0.6); padding: 0.8rem; border-radius: 8px; border: 1px solid var(--border-color);
}
.slide-item img { width: 60px; height: 45px; object-fit: cover; border-radius: 4px; }
.slide-item-content { flex: 1; overflow: hidden; }
.slide-item-content h3 { font-size: 0.95rem; margin-bottom: 0.2rem; word-break: break-word; }
.slide-item-content p { font-size: 0.8rem; color: var(--text-secondary); word-break: break-word; white-space: pre-wrap; }
.slide-actions { display: flex; flex-direction: row; gap: 0.2rem; align-items: center; justify-content: flex-start; margin-top: 0.5rem; }
.action-icon-btn { background: transparent; border: none; cursor: pointer; padding: 0.2rem 0.4rem; border-radius: 4px; color: var(--text-secondary); font-size: 0.9rem; transition: background 0.2s, color 0.2s; }
.action-icon-btn:hover { background: rgba(255,255,255,0.1); color: white; }
.action-icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.edit-btn { color: #3b82f6; }
.edit-btn:hover { background: rgba(59, 130, 246, 0.1); color: #60a5fa; }
.delete-btn { color: #ef4444; }
.delete-btn:hover { background: rgba(239, 68, 68, 0.1); color: #f87171; }

/* Presentation Mode */
.presentation-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: #000; z-index: 1000; opacity: 1; transition: opacity 0.4s ease;
    display: flex; align-items: center; justify-content: center;
}
.presentation-overlay.hidden { opacity: 0; pointer-events: none; }
.close-btn {
    position: absolute; top: 20px; right: 20px; width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,0.1); color: white; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; z-index: 1010; border: none; cursor: pointer;
}
.close-btn:hover { background: rgba(255,255,255,0.2); }

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

.slide-display {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; opacity: 0; visibility: hidden; transition: opacity 0.8s ease, visibility 0.8s ease;
}
.slide-display.active { opacity: 1; visibility: visible; }

/* The layout flex-direction will be set dynamically via JS style.flexDirection */

.slide-image-container { flex: 1; position: relative; overflow: hidden; }
.slide-image-container img {
    width: 100%; height: 100%; object-fit: cover;
}
.slide-display.active .slide-image-container img { transform: scale(1) !important; }
.slide-display.exit .slide-image-container img { transform: scale(1.2); opacity: 0; transition: transform 1s ease, opacity 0.8s ease; }

.slide-content-container {
    background: #1e293b;
    display: flex; flex-direction: column; justify-content: center; padding: 4rem; position: relative;
    /* width/height will be set dynamically */
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slide-content-container h2 {
    font-weight: 800; margin-bottom: 1.5rem; color: #f8fafc;
    opacity: 0; transform: var(--start-transform, translateY(30px)); transition: opacity 0.6s ease 0.4s, transform 0.6s ease 0.4s;
}
.slide-content-container p {
    line-height: 1.6; color: #cbd5e1;
    opacity: 0; transform: var(--start-transform, translateY(30px)); transition: opacity 0.6s ease 0.6s, transform 0.6s ease 0.6s;
}
.slide-display.active .slide-content-container h2, .slide-display.active .slide-content-container p {
    opacity: 1; transform: translate(0, 0);
}

/* Background gradient animation for text panel */
.bg-anim {
    position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, rgba(15, 23, 42, 0) 50%);
    z-index: 0; animation: rotateBg 15s linear infinite; pointer-events: none;
}
@keyframes rotateBg { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.slide-content-container > *:not(.bg-anim) { position: relative; z-index: 1; }

.progress-bar-container { position: absolute; bottom: 0; left: 0; width: 100%; height: 4px; background: rgba(255, 255, 255, 0.1); z-index: 1010; }
.progress-bar { height: 100%; background: var(--primary-color); width: 0%; transition: width linear; }
