/*
 * ===========================================
 * GALERIA DE GEOMETRIAS SAGRADAS - LumiNah
 * ===========================================
 * Estilos modulares para a galeria/Grimório
 * Extraído de hipotrocoides_sagrados.css
 * v1.0 - Modularização completa
 */

/* ===== VARIÁVEIS (herda do tema pai se disponível) ===== */
:root {
    --gallery-bg-primary: var(--bg-primary, #0a0a1a);
    --gallery-bg-secondary: var(--bg-secondary, #12122a);
    --gallery-bg-tertiary: var(--bg-tertiary, #1a1a3a);
    --gallery-border-color: var(--border-color, rgba(0, 255, 255, 0.2));
    --gallery-accent-neon: var(--accent-neon, #00ffff);
    --gallery-accent-blue: var(--accent-blue, #0080ff);
    --gallery-accent-green: var(--accent-green, #00ff88);
    --gallery-text-primary: var(--text-primary, #ffffff);
    --gallery-text-secondary: var(--text-secondary, #a0a0a0);
}

/* ===== GALERIA SIDEBAR ===== */
.gallery-sidebar {
    position: fixed;
    top: 0;
    right: -350px;
    width: 350px;
    height: 100vh;
    background: var(--gallery-bg-tertiary);
    border-left: 1px solid var(--gallery-border-color);
    box-shadow: -10px 0 20px rgba(0, 0, 0, 0.3);
    transition: right 0.3s ease;
    z-index: 10000;
    overflow-y: auto;
    padding: 20px;
}

.gallery-sidebar.open {
    right: 0;
}

/* ===== BOTÃO TOGGLE ===== */
.gallery-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    background: var(--gallery-bg-tertiary);
    border: 2px solid var(--gallery-border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--gallery-accent-neon);
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.gallery-toggle:hover {
    border-color: var(--gallery-accent-neon);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    transform: translateY(-50%) scale(1.1);
}

/* ===== HEADER DA GALERIA ===== */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--gallery-border-color);
}

.gallery-title {
    color: var(--gallery-accent-neon);
    font-size: 1.2em;
    font-weight: bold;
}

.gallery-close {
    background: none;
    border: none;
    color: var(--gallery-text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.gallery-close:hover {
    color: var(--gallery-accent-neon);
    background: rgba(0, 255, 255, 0.1);
}

/* ===== SEÇÃO DE SALVAMENTO ===== */
.save-section {
    margin-bottom: 30px;
    padding: 15px;
    background: var(--gallery-bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--gallery-border-color);
}

.save-section h3 {
    color: var(--gallery-accent-neon);
    margin-bottom: 15px;
    font-size: 1em;
}

.save-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--gallery-bg-primary);
    border: 1px solid var(--gallery-border-color);
    border-radius: 6px;
    color: var(--gallery-text-primary);
    font-size: 0.9em;
    margin-bottom: 10px;
    outline: none;
    box-sizing: border-box;
}

.save-input:focus {
    border-color: var(--gallery-accent-neon);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.save-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(45deg, var(--gallery-accent-neon), var(--gallery-accent-blue));
    border: none;
    border-radius: 8px;
    color: var(--gallery-bg-primary);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.save-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}

/* ===== LISTA DE ITENS ===== */
.gallery-list {
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.gallery-item {
    background: var(--gallery-bg-secondary);
    border: 1px solid var(--gallery-border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.gallery-item:hover {
    border-color: var(--gallery-accent-neon);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.gallery-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.gallery-item-header h4 {
    margin: 0;
    color: var(--gallery-accent-neon);
    font-size: 0.95em;
}

.gallery-item-actions {
    display: flex;
    gap: 4px;
}

.gallery-item-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: #d4d4d4;
    transition: background 0.2s, color 0.2s;
}

.gallery-item-actions button:hover {
    background: rgba(167, 139, 250, 0.15);
    color: #c4b5fd;
}

.gallery-item-preview {
    background: var(--gallery-bg-primary);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 8px;
    min-height: 60px;
    max-height: 180px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-item-preview img {
    max-width: 100%;
    max-height: 160px;
    object-fit: contain;
    border-radius: 4px;
}

.gallery-item-preview svg {
    width: 160px;
    height: 160px;
    max-width: 100%;
    display: block;
    overflow: visible;
}

.gallery-item-info {
    text-align: right;
}

.gallery-item-info small {
    color: var(--gallery-text-secondary);
    font-size: 0.75em;
    opacity: 0.7;
}

.gallery-item-name {
    color: var(--gallery-accent-neon);
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.gallery-item-curves {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 6px;
    margin-bottom: 2px;
    min-height: 0;
}

.curve-tag {
    font-size: 0.62em;
    padding: 2px 7px;
    border-radius: 10px;
    background: rgba(167, 139, 250, 0.12);
    color: #c4b5fd;
    border: 1px solid rgba(167, 139, 250, 0.28);
    white-space: nowrap;
}

.gallery-item-params {
    color: var(--gallery-text-secondary);
    font-size: 0.8em;
    font-family: 'Courier New', monospace;
    margin-bottom: 3px;
}

.gallery-item-date {
    color: var(--gallery-text-secondary);
    font-size: 0.7em;
    opacity: 0.7;
}

.gallery-item-color {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--gallery-border-color);
    margin-left: 10px;
}

.delete-btn {
    float: right;
    background: none;
    border: none;
    color: #ff4444;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.delete-btn:hover {
    background: rgba(255, 68, 68, 0.2);
    color: #ff6666;
}

.empty-gallery {
    color: var(--gallery-text-secondary);
    text-align: center;
    padding: 30px;
    font-style: italic;
    opacity: 0.8;
}

/* ===== ANIMAÇÕES ===== */
.pulsing {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ===== MODAL DE SALVAMENTO ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 11000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--gallery-bg-tertiary);
    border-radius: 15px;
    border: 2px solid var(--gallery-border-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--gallery-border-color);
    background: linear-gradient(45deg, var(--gallery-bg-secondary), var(--gallery-bg-tertiary));
}

.modal-header h2 {
    color: var(--gallery-accent-neon);
    margin: 0;
    font-size: 1.4em;
}

.modal-close {
    background: none;
    border: none;
    color: var(--gallery-text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    color: var(--gallery-accent-neon);
    background: rgba(0, 255, 255, 0.1);
}

.modal-body {
    padding: 25px;
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
}

/* ===== SEÇÃO DE THUMBNAIL ===== */
.thumbnail-section {
    flex: 0 0 250px;
}

.thumbnail-section h3 {
    color: var(--gallery-accent-neon);
    margin-bottom: 15px;
    font-size: 1.1em;
}

.thumbnail-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.thumbnail-container canvas {
    border: 2px solid var(--gallery-border-color);
    border-radius: 8px;
    background: var(--gallery-bg-primary);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.capture-status {
    color: var(--gallery-accent-green);
    font-weight: bold;
    font-size: 0.9em;
    text-align: center;
    padding: 8px 12px;
    background: rgba(0, 255, 0, 0.1);
    border-radius: 6px;
    border: 1px solid var(--gallery-accent-green);
}

.capture-btn {
    padding: 10px 20px;
    background: linear-gradient(45deg, var(--gallery-accent-blue), var(--gallery-accent-neon));
    border: none;
    border-radius: 8px;
    color: var(--gallery-bg-primary);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 128, 255, 0.3);
}

.capture-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 128, 255, 0.4);
}

/* ===== FORMULÁRIO ===== */
.form-section {
    flex: 1;
    min-width: 300px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: var(--gallery-accent-neon);
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    background: var(--gallery-bg-secondary);
    border: 2px solid var(--gallery-border-color);
    border-radius: 8px;
    color: var(--gallery-text-primary);
    font-family: inherit;
    font-size: 0.9em;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--gallery-accent-neon);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.parameters-display {
    background: var(--gallery-bg-primary);
    border: 1px solid var(--gallery-border-color);
    border-radius: 6px;
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.8em;
    color: var(--gallery-accent-neon);
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
}
.parameters-display code {
    max-height: none;
    overflow: visible;
}

/* ===== FOOTER DO MODAL ===== */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    padding: 20px 25px;
    border-top: 1px solid var(--gallery-border-color);
    background: var(--gallery-bg-secondary);
}

.cancel-btn,
.save-final-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95em;
}

.cancel-btn {
    background: var(--gallery-bg-primary);
    border: 2px solid var(--gallery-border-color);
    color: var(--gallery-text-secondary);
}

.cancel-btn:hover {
    background: var(--gallery-bg-secondary);
    border-color: var(--gallery-accent-neon);
    color: var(--gallery-accent-neon);
}

.save-final-btn {
    background: linear-gradient(45deg, var(--gallery-accent-neon), var(--gallery-accent-blue));
    color: var(--gallery-bg-primary);
    box-shadow: 0 4px 15px rgba(0, 255, 255, 0.3);
}

.save-final-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 255, 255, 0.4);
}

.save-final-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 900px) {
    .modal-body {
        flex-direction: column;
    }

    .thumbnail-section {
        flex: none;
        align-self: center;
    }

    .form-section {
        min-width: auto;
    }
}

@media (max-width: 500px) {
    .gallery-sidebar {
        width: 100%;
        right: -100%;
    }

    .gallery-sidebar.open {
        right: 0;
    }
}

/* ===== GALERIAS EXTRAS (Objetos 3D, Cenas, Silhuetas) ===== */
.gallery-extra-sidebar {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.gallery-extra-sidebar .gallery-header {
    flex-shrink: 0;
}

.gallery-extra-sidebar .save-section {
    flex-shrink: 0;
}

.gallery-extra-sidebar .gallery-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.gallery-extra-sidebar .gallery-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--gallery-border-color, rgba(0,255,255,0.2));
}

.gallery-extra-sidebar .save-btn {
    background: linear-gradient(135deg, rgba(107,255,184,0.15), rgba(0,128,255,0.15));
    border: 1px solid rgba(107,255,184,0.3);
    color: #6BFFB8;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.gallery-extra-sidebar .save-btn:hover {
    background: linear-gradient(135deg, rgba(107,255,184,0.25), rgba(0,128,255,0.25));
    border-color: rgba(107,255,184,0.5);
}
