/* css/builder.css */

body {
    margin: 0;
    padding: 0;
    display: flex;
    height: 100vh;
    width: 100vw;
    background: #0f0f13;
    color: #e0e0e0;
    font-family: 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
}

/* --- Left: Preview --- */
.preview-section {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 0;
}

.preview-container {
    width: 100%;
    max-height: 100%;
    aspect-ratio: 16 / 9;
    position: relative;
    overflow: hidden;
}

#aquarium {
    background: linear-gradient(to bottom, #001f3f, #001220);
    width: 100% !important;
    height: 100% !important;
    position: absolute;
    top: 0;
    left: 0;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.preview-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: #ff0055;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    z-index: 2000;
}

/* --- Right: Dashboard --- */
.designer-section {
    width: 450px;
    background: #18181b;
    border-left: 1px solid #333;
    display: flex;
    flex-direction: column;
    z-index: 10000;
    /* Sidebar stays ON TOP */
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5);
}

.dashboard-header {
    padding: 20px;
    background: #202024;
    border-bottom: 1px solid #333;
}

.dashboard-header h2 {
    margin: 0;
    font-size: 18px;
    color: #00f2ff;
}

.dashboard-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.dash-card {
    background: #27272a;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #333;
}

.dash-card h3 {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: #aaa;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
}

/* Inputs */
input[type="text"],
select,
textarea {
    background: #18181b;
    border: 1px solid #444;
    color: #fff;
    padding: 8px;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 13px;
    margin-bottom: 5px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #00f2ff;
    outline: none;
}

.row-inputs {
    display: flex;
    gap: 10px;
}

/* Position Mini Grid */
.row-flex {
    display: flex;
    gap: 10px;
}

.style-selector {
    flex: 1;
}

.pos-mini-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    width: 60px;
    height: 60px;
}

.pos-mini-cell {
    background: #444;
    cursor: pointer;
    border-radius: 2px;
}

.pos-mini-cell.active {
    background: #00f2ff;
}

/* Active Item Cards */
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.btn-icon-add {
    background: #28a745;
    border: none;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.btn-icon-add:hover {
    background: #34ce57;
}

/* Fixed Items List Container */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 20px;
    width: 100%;
    padding-bottom: 5px;
    /* Prevent cutout */
}

.item-card {
    background: #333;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: 0.2s;
}

.item-card:hover {
    border-color: #666;
    background: #3a3a3a;
}

.item-card.meme-card {
    border-left: 4px solid #ffa500;
}

.item-card.fish-card {
    border-left: 4px solid #00f2ff;
}

.item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.item-title {
    font-weight: bold;
    font-size: 14px;
    color: #eee;
}

.item-meta {
    font-size: 11px;
    color: #aaa;
}

.item-actions {
    display: flex;
    gap: 5px;
}

.btn-mini {
    background: #444;
    border: none;
    color: #ccc;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-mini:hover {
    background: #555;
    color: white;
}

.btn-mini.del:hover {
    background: #ff4444;
}

/* Footer */
.dashboard-footer {
    padding: 20px;
    background: #202024;
    border-top: 1px solid #333;
}

.code-area {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

#final-code {
    height: 40px;
    resize: none;
    color: #00f2ff;
    border-color: #00f2ff;
}

#btn-copy {
    background: #333;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
    padding: 0 10px;
}

.btn-primary {
    width: 100%;
    background: #00f2ff;
    color: #000;
    border: none;
    padding: 12px;
    border-radius: 6px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ================= MODALS ================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    z-index: 20000;
    /* Higher than dashboard */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.2s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-window {
    background: #18181b;
    width: 95vw;
    height: 90vh;
    max-width: 1600px;
    border-radius: 12px;
    border: 1px solid #444;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #202024;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    color: #fff;
    font-size: 24px;
    letter-spacing: 1px;
}

.modal-close {
    background: transparent;
    border: none;
    color: #888;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: #fff;
}

.modal-body-split {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Modal Grid */
.modal-grid-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background: #111;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    grid-auto-rows: 180px;
    gap: 20px;
    align-content: start;
}

.modal-asset {
    width: 100%;
    height: 100%;
    background: #1a1a1a;
    border: 3px solid #333;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    transition: all 0.1s ease-out;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.modal-asset img,
.modal-asset video {
    max-width: 85%;
    max-height: 85%;
    object-fit: contain;
    pointer-events: none;
    z-index: 1;
}

.modal-asset:hover {
    border-color: #666;
    transform: translateY(-3px);
    background: #252525;
}

.modal-asset.selected {
    border-color: #00f2ff;
    background: rgba(0, 242, 255, 0.05);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.3);
}

.modal-asset .id-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    background: rgba(0, 0, 0, 0.8);
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 2;
    border: 1px solid #555;
}

/* Modal Sidebar */
.modal-sidebar {
    width: 420px;
    background: #202024;
    padding: 30px;
    border-left: 1px solid #333;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex-shrink: 0;
    overflow-y: auto;
}

.preview-box {
    width: 100%;
    aspect-ratio: 1;
    background: #050505;
    border: 2px solid #444;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    position: relative;
}

#fish-preview-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#fish-preview-img {
    max-width: 200px;
    filter: drop-shadow(4px 4px 0px rgba(0, 0, 0, 0.5));
}

.preview-name-label {
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 14px;
    white-space: nowrap;
    border: 1px solid #555;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    background: #333;
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 13px;
    color: #ccc;
    font-weight: bold;
    margin-top: -10px;
    border: 1px solid #444;
}

.video-preview-wrapper {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border: 2px solid #444;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

#meme-preview-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-overlay-text {
    position: absolute;
    color: #666;
    pointer-events: none;
    font-size: 16px;
}

/* Form Controls */
.control-group label {
    display: block;
    color: #ccc;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: bold;
}

/* Timing Selector */
.timing-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.timing-option {
    position: relative;
}

.timing-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.timing-card {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: #111;
    border: 2px solid #333;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 14px;
    color: #aaa;
}

.timing-card:hover {
    border-color: #555;
    background: #1a1a1a;
}

/* Checked State */
.timing-option input[type="radio"]:checked+.timing-card {
    border-color: #00f2ff;
    background: rgba(0, 242, 255, 0.1);
    color: #fff;
    font-weight: bold;
}



.btn-confirm {
    margin-top: auto;
    padding: 20px;
    background: linear-gradient(to right, #28a745, #218838);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-confirm:disabled {
    background: #333;
    color: #555;
    cursor: not-allowed;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #00f2ff;
    cursor: pointer;
    margin-top: -8px;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #555;
    border-radius: 2px;
}

/* --- New Footer Buttons --- */
.dashboard-footer {
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.footer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

.footer-actions .btn-copy-code,
.footer-actions .btn-send-donate {
    flex: 1 1 45%;
    min-width: 0;
}

.footer-actions .btn-secondary {
    flex: 1 1 100%;
}

.btn-send-donate {
    background: #555;
    color: #aaa;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-send-donate:hover {
    transform: translateY(-2px);
}

.btn-secondary {
    flex: 1;
    background: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
}

.btn-secondary:hover {
    background: #444;
}

.btn-copy-code {
    background: #555;
    color: #aaa;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-copy-code:hover {
    transform: translateY(-2px);
}

/* --- State Classes for Button Toggling --- */
.active-green {
    background: #00ff88 !important;
    color: #000 !important;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
}

.active-green:hover {
    background: #00e077 !important;
}

.dormant-grey {
    background: #444 !important;
    color: #888 !important;
    box-shadow: none;
}

.modal-text-content {
    padding: 20px;
    font-size: 16px;
    line-height: 1.5;
    color: #ddd;
}

.btn-icon-edit {
    background: #f39c12;
    border: none;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.btn-icon-edit:hover {
    background: #e67e22;
}