/* ==========================================================================
   IMAGINAI - DESIGN SYSTEM & STYLESHEET
   ========================================================================== */

/* --- Variáveis Globais de Design --- */
:root {
    --bg-dark: #07090e;
    --bg-surface: #0e121b;
    --bg-card: rgba(18, 24, 38, 0.75);
    --bg-card-hover: rgba(26, 35, 55, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(139, 92, 246, 0.3);

    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-glow: rgba(139, 92, 246, 0.5);
    --accent-cyan: #06b6d4;
    --accent-pink: #ec4899;
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #6b7280;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
    --shadow-neon: 0 0 25px rgba(139, 92, 246, 0.25);

    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset Básico & Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* --- Efeitos de Fundo (Glowing Orbs) --- */
.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
}

.bg-glow-1 {
    top: -100px;
    left: -100px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--primary), transparent 70%);
}

.bg-glow-2 {
    bottom: -150px;
    right: -100px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-cyan), transparent 70%);
}

.bg-glow-3 {
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, var(--accent-pink), transparent 70%);
    opacity: 0.15;
}

/* --- App Layout Layout Container --- */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1380px;
    margin: 0 auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* --- Header Main --- */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

.logo-text h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-text h1 span {
    background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.12);
    border: 1px solid rgba(6, 182, 212, 0.25);
    padding: 2px 8px;
    border-radius: 20px;
}

/* --- AdSense Containers --- */
.ad-section {
    width: 100%;
    display: flex;
    justify-content: center;
}

.ad-container {
    position: relative;
    width: 100%;
    background: rgba(14, 18, 27, 0.6);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    overflow: hidden;
}

.ad-badge {
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dark);
}

.ad-horizontal {
    min-height: 90px;
}

.ad-sidebar {
    min-height: 280px;
    width: 100%;
}

/* Fallback visual quando AdSense não carregar em dev local */
.ad-container:empty::after,
.ad-container ins:empty::after {
    content: "Espaço Reservado para Anúncios (Google AdSense)";
    font-size: 13px;
    color: var(--text-dark);
    font-weight: 500;
    display: block;
    padding: 20px;
    text-align: center;
}

/* --- Main Grid Layout --- */
.main-content {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 28px;
}

.creator-panel {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.sidebar-panel {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* --- Cards Estilo Glassmorphism --- */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.14);
}

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

.card-header h2, .card-header h3 {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
}

.card-header h2 i, .card-header h3 i {
    color: var(--primary);
}

/* --- Inputs e Formulários --- */
.prompt-input-wrapper {
    position: relative;
    margin-bottom: 18px;
}

textarea {
    width: 100%;
    background: rgba(10, 13, 20, 0.8);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 15px;
    resize: vertical;
    outline: none;
    transition: all var(--transition-fast);
}

textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

kbd {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-family: monospace;
}

/* --- Style Tags --- */
.style-tags-container {
    margin-bottom: 22px;
}

.tags-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.tags-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.style-tag {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--text-main);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.style-tag:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--primary);
    color: #fff;
    transform: translateY(-1px);
}

/* --- Seletor de Opções Avançadas --- */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.custom-select, .custom-input {
    width: 100%;
    background: rgba(10, 13, 20, 0.8);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: all var(--transition-fast);
}

.custom-select:focus, .custom-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

/* --- Botões --- */
.btn-primary {
    position: relative;
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    border: none;
    border-radius: var(--radius-md);
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    overflow: hidden;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-neon);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.45);
}

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

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

.btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

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

.btn-text {
    background: none;
    border: none;
    color: var(--accent-cyan);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color var(--transition-fast);
}

.btn-text:hover {
    color: #38bdf8;
    text-decoration: underline;
}

.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--primary);
    color: #fff;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.35);
}

/* --- Área de Resultado da Imagem --- */
.result-card {
    min-height: 420px;
    display: flex;
    flex-direction: column;
}

.image-display-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 8, 14, 0.6);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    max-width: 480px;
    width: 100%;
}

.empty-illustration, .error-illustration {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.error-illustration {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* --- Loading Spinner & Progress --- */
.loader-spinner {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid rgba(139, 92, 246, 0.15);
    border-top: 4px solid var(--primary);
    border-right: 4px solid var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

.spinner-icon {
    font-size: 26px;
    color: var(--primary);
    animation: pulse 1.5s ease-in-out infinite;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

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

.timer-text {
    font-size: 13px;
    font-family: monospace;
    color: var(--accent-cyan);
}

/* --- Imagem Renderizada --- */
.image-wrapper {
    position: relative;
    width: 100%;
    max-height: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.image-wrapper img {
    max-width: 100%;
    max-height: 560px;
    object-fit: contain;
    border-radius: var(--radius-md);
    animation: fadeIn 0.4s ease;
}

.image-overlay {
    position: absolute;
    bottom: 12px;
    left: 12px;
}

.image-tag {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    color: #fff;
}

/* --- Console de Diagnóstico em Tempo Real --- */
.debug-console-wrapper {
    margin-top: 16px;
    background: rgba(5, 7, 12, 0.9);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.debug-console-wrapper details {
    padding: 10px 14px;
}

.debug-console-wrapper summary {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.debug-console-wrapper summary i {
    color: var(--accent-cyan);
    margin-right: 6px;
}

.debug-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

.debug-log-output {
    margin-top: 10px;
    max-height: 180px;
    overflow-y: auto;
    background: #040508;
    border-radius: var(--radius-sm);
    padding: 10px;
    font-family: monospace;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-line {
    word-break: break-all;
    line-height: 1.4;
}

.log-line.info { color: #94a3b8; }
.log-line.success { color: #34d399; }
.log-line.warn { color: #fbbf24; }
.log-line.error { color: #f87171; }

.result-actions {
    display: flex;
    gap: 8px;
}

/* --- Dicas Sidebar --- */
.tips-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tips-list li {
    font-size: 13px;
    color: var(--text-muted);
    position: relative;
    padding-left: 18px;
}

.tips-list li::before {
    content: "•";
    color: var(--primary);
    font-size: 18px;
    position: absolute;
    left: 0;
    top: -2px;
}

.tips-list strong {
    color: var(--text-main);
}

/* --- Galeria do Histórico --- */
.gallery-section {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
}

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

.section-header h2 {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.gallery-count {
    font-size: 13px;
    color: var(--text-muted);
}

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

.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.gallery-item:hover {
    transform: scale(1.03);
    border-color: var(--primary);
}

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

.gallery-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    opacity: 0;
    display: flex;
    align-items: flex-end;
    padding: 10px;
    transition: opacity var(--transition-fast);
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
}

.gallery-item-prompt {
    font-size: 11px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Modais --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    max-width: 520px;
    width: 100%;
    background: #0f1420;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
    margin-bottom: 24px;
    font-size: 14px;
    color: var(--text-muted);
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.btn-icon-inside {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.info-box {
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.2);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: #e0f2fe;
}

.info-box i {
    color: var(--accent-cyan);
    font-size: 18px;
    margin-top: 2px;
}

.info-box ol {
    margin-left: 18px;
    margin-top: 6px;
}

.info-box a {
    color: var(--accent-cyan);
    text-decoration: underline;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Lightbox Modal */
.lightbox-container {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.lightbox-container img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.lightbox-caption {
    margin-top: 16px;
    text-align: center;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.lightbox-close {
    position: absolute;
    top: -48px;
    right: 0;
}

/* --- Toasts de Notificação --- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: rgba(18, 24, 38, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease;
}

.toast.success { border-left: 4px solid #10b981; }
.toast.error { border-left: 4px solid #ef4444; }
.toast.info { border-left: 4px solid var(--accent-cyan); }

/* --- Footer --- */
.main-footer {
    text-align: center;
    padding: 16px;
    color: var(--text-dark);
    font-size: 13px;
}

.main-footer a {
    color: var(--text-muted);
    text-decoration: none;
}

.main-footer a:hover {
    color: var(--primary);
}

/* --- Animações --- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

.hidden {
    display: none !important;
}

/* --- Responsividade --- */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .options-grid {
        grid-template-columns: 1fr;
    }
    .main-header {
        flex-direction: column;
        gap: 14px;
        align-items: flex-start;
    }
    .header-actions {
        width: 100%;
    }
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}
