:root {
    --bg-dark: #121212;
    --bg-panel: #1e1e1e;
    --primary: #bb86fc;
    --primary-hover: #9965f4;
    --text-main: #e0e0e0;
    --text-muted: #a0a0a0;
    --border: #333;
    --success: #03dac6;
    --error: #cf6679;
    --overlay-bg: rgba(30, 30, 30, 0.95);
    --selected-border: #03dac6;
}

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

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden; 
}

/* --- LAYOUT PRINCIPAL --- */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* --- SIDEBAR (Controles) --- */
.sidebar {
    width: 350px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto; 
    z-index: 20;
    flex-shrink: 0;
}

/* Header & Status */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.5rem;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--error);
    transition: all 0.3s ease;
    border: 2px solid rgba(0,0,0,0.2);
}

.status-indicator.online {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s;
}

.icon-btn:hover {
    color: var(--text-main);
    background-color: rgba(255,255,255,0.1);
}

/* Form Controls */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 5px;
    width: 100%;
}

.control-group.row {
    flex-direction: row;
    gap: 15px;
}

/* Slider Controls */
.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.value-display {
    color: var(--primary);
    font-weight: bold;
    font-size: 0.9rem;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Estilo do Input Range */
input[type=range].slider {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    margin: 10px 0;
    cursor: pointer;
}

input[type=range].slider:focus {
    outline: none;
}

/* Track (o trilho) */
input[type=range].slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: #333;
    border-radius: 3px;
    border: 1px solid var(--border);
}

input[type=range].slider::-moz-range-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: #333;
    border-radius: 3px;
    border: 1px solid var(--border);
}

/* Thumb (o botãozinho) */
input[type=range].slider::-webkit-slider-thumb {
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -7px; /* Centralizar verticalmente no track */
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    transition: background 0.2s, transform 0.2s;
}

input[type=range].slider::-moz-range-thumb {
    height: 18px;
    width: 18px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    transition: background 0.2s, transform 0.2s;
}

input[type=range].slider::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

input[type=range].slider::-moz-range-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

/* Seed Control Layout */
.seed-control {
    display: flex;
    gap: 10px;
    align-items: center;
}

.seed-control input[type="number"] {
    flex: 1;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-main);
    user-select: none;
}

.input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

textarea, input[type="text"], input[type="number"] {
    background-color: #2c2c2c;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 12px;
    border-radius: 6px;
    font-family: inherit;
    resize: vertical;
    font-size: 0.95rem;
    transition: border-color 0.2s, background-color 0.2s;
    width: 100%; 
    display: block;
}

textarea:focus, input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #333;
}

input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #202020;
}

/* Buttons */
.primary-btn {
    background-color: var(--primary);
    color: #000;
    border: none;
    padding: 14px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s, transform 0.1s;
    font-size: 1rem;
    width: 100%; 
}

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

.primary-btn:active {
    transform: scale(0.98);
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.secondary-btn {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 14px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 1rem;
}

.secondary-btn:hover {
    background-color: rgba(255,255,255,0.05);
}

.text-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 5px 10px;
    border-radius: 4px;
    transition: color 0.2s, background-color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.text-btn:hover {
    color: var(--text-main);
    background-color: rgba(255,255,255,0.05);
}

.text-btn.delete-batch {
    color: var(--error);
}
.text-btn.delete-batch:hover {
    background-color: rgba(207, 102, 121, 0.1);
}

.footer-note {
    margin-top: auto;
    display: flex;
    justify-content: center;
    padding-top: 10px;
    word-break: break-all;
    text-align: center;
}

/* --- MAIN CONTENT --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background-color: #0a0a0a;
}

/* Live View (Área da Imagem) */
.live-view {
    flex: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    padding: 20px;
    background-image: radial-gradient(#1a1a1a 1px, transparent 1px);
    background-size: 20px 20px;
}

.live-view img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transition: opacity 0.3s;
}

.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    opacity: 0.5;
    text-align: center;
}

.placeholder .material-icons {
    font-size: 4rem;
    margin-bottom: 10px;
}

.hidden {
    display: none !important;
}

/* Image Actions */
.image-actions {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 50;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.1);
}

.action-btn {
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: bold;
    transition: background 0.2s;
    font-size: 0.9rem;
    background: transparent;
}

.action-btn:hover {
    background-color: rgba(255,255,255,0.2);
}

.action-btn.delete {
    color: #cf6679;
}
.action-btn.delete:hover {
    background-color: #cf6679;
    color: white;
}

.action-btn.info {
    color: #03dac6;
}
.action-btn.info:hover {
    background-color: #03dac6;
    color: black;
}

/* Progress Overlay */
.progress-overlay {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--overlay-bg);
    padding: 15px 25px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    width: auto;
    min-width: 300px;
    max-width: 90%;
    z-index: 100;
    border: 1px solid rgba(255,255,255,0.05);
}

.progress-bar-container {
    flex: 1;
    height: 6px;
    background: #444;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    width: 0%;
    transition: width 0.3s ease;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- GALLERY --- */
.gallery-section {
    flex: 1;
    background-color: var(--bg-panel);
    border-top: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    min-height: 200px;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.gallery-header h2 {
    font-size: 1rem;
    color: var(--text-muted);
}

.gallery-tools {
    display: flex;
    gap: 10px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.gallery-item {
    aspect-ratio: 1;
    background-color: #000;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
    border: 2px solid transparent;
}

.gallery-item:hover {
    transform: scale(1.05);
    border-color: var(--primary);
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.gallery-item.selected {
    border-color: var(--selected-border);
    transform: scale(0.95);
    opacity: 0.8;
}

.gallery-item.selected::after {
    content: 'check_circle';
    font-family: 'Material Icons';
    position: absolute;
    top: 5px;
    right: 5px;
    color: var(--selected-border);
    font-size: 1.5rem;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
}

/* --- FILA --- */
.queue-container {
    margin-top: 20px;
    border-top: 1px solid var(--border);
    padding-top: 15px;
    flex: 1; 
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.queue-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-right: 5px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.queue-item {
    background-color: #252525;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    font-size: 0.85rem;
    position: relative;
    overflow: hidden;
    transition: all 0.2s;
}

.queue-item.active {
    border-color: var(--primary);
    background-color: #2a2a2a;
}

.queue-item.completed {
    border-color: var(--success);
    opacity: 0.7;
}

.queue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.queue-id {
    font-weight: bold;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.queue-status {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: #333;
    color: #aaa;
    text-transform: uppercase;
}

.queue-item.active .queue-status {
    background: rgba(187, 134, 252, 0.2);
    color: var(--primary);
}

.queue-mini-bar-bg {
    width: 100%;
    height: 4px;
    background: #444;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 5px;
}

.queue-mini-bar-fill {
    height: 100%;
    background: var(--success);
    width: 0%;
    transition: width 0.3s ease;
}

/* --- MODAL --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
    transition: opacity 0.3s;
}

.modal.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 25px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    color: var(--primary);
    font-size: 1.2rem;
}

.icon-btn-plain {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.icon-btn-plain:hover {
    color: #fff;
}

.modal-body {
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-actions button {
    width: auto;
    padding: 10px 20px;
}


/* ========================================= */
/* RESPONSIVIDADE MOBILE         */
/* ========================================= */
@media (max-width: 768px) {
    body { height: auto; overflow-y: auto; overflow-x: hidden; }
    .app-container { flex-direction: column; height: auto; overflow: visible; }
    .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); position: relative; padding-bottom: 25px; }
    textarea, input[type="text"], input[type="number"] { font-size: 16px; padding: 14px; }
    .main-content { flex: none; width: 100%; height: auto; display: flex; flex-direction: column; }
    .live-view { min-height: 50vh; padding: 10px; background-color: #050505; }
    .live-view img { max-height: 60vh; width: auto; max-width: 100%; }
    .image-actions { top: 10px; right: 10px; padding: 5px; }
    .action-btn { padding: 10px; }
    .progress-overlay { position: fixed; bottom: 20px; width: 90%; z-index: 1000; box-shadow: 0 -4px 20px rgba(0,0,0,0.7); }
    .gallery-section { min-height: auto; padding-bottom: 40px; }
    .gallery-grid { grid-template-columns: repeat(3, 1fr); }
    .queue-container { max-height: 200px; }
}