/* Reset e configurações globais */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a1a;
    color: #ffffff;
    overflow: hidden;
    user-select: none;
}

/* Container principal */
#app-container {
    width: 100%;
    /* height: 100vh; Removed to allow flex layout to control height */
    position: relative;
    display: flex;
}

/* Área de apresentação */
#presentation-area {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
}

#background-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000000;
    /* preto por padrão */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
}

#slide-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    /* Deixa cliques passarem */
}

#current-slide {
    /* Dimensions handled by JS fitSlideToScreen */
    aspect-ratio: 16 / 9;
    /* Mantém como hint/fallback */

    /* Box pontilhado guia */
    outline: 2px dashed rgba(255, 255, 255, 0.3);

    position: relative;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Ensure content is clipped to slide boundaries */
}

/* Removed media queries for Aspect Ratio as JS handles it now */

#current-slide img,
#current-slide video {
    pointer-events: auto;
    position: relative;
    z-index: 1;
    /* Content at 1 */
    pointer-events: auto;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#slide-media-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Fullscreen: Remove dashed border */
.is-fullscreen #current-slide {
    outline: none !important;
}

/* Camada de overlay para imagens PNG */
#overlay-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    /* Ensure it is above the image (z-1) */
    pointer-events: none;
}

.overlay-image {
    position: absolute;
    cursor: move;
    pointer-events: all;
    border: 2px dashed transparent;
    transition: border-color 0.3s ease;
    z-index: 101;
    /* Elements inside overlay layer */
}

.overlay-image:hover {
    border-color: #00ff88;
}

.overlay-image.selected {
    border-color: #ff6b6b;
}

/* Overlay Layer */
/* This rule is now redundant as #overlay-layer is defined above with z-index 100 */
/* #overlay-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none;
    /* Deixa cliques passarem para o slide se não atingirem um objeto */
/* } */

/* Os objetos dentro da layer devem capturar eventos */
.overlay-image,
.overlay-text {
    pointer-events: auto;
}

.overlay-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Resize handles para imagens overlay */
.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ff6b6b;
    border: 1px solid #fff;
    border-radius: 50%;
    display: none;
    /* ocultas por padrão */
}

/* Mostra alças apenas quando a imagem está selecionada */
.overlay-image.selected .resize-handle {
    display: block;
}

.resize-handle.nw {
    top: -5px;
    left: -5px;
    cursor: nw-resize;
}

.resize-handle.ne {
    top: -5px;
    right: -5px;
    cursor: ne-resize;
}

.resize-handle.sw {
    bottom: -5px;
    left: -5px;
    cursor: sw-resize;
}

.resize-handle.se {
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

/* Menu lateral */
.side-menu {
    width: 300px;
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(10px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    right: 0;
    top: 0;
    height: auto;
    max-height: 100%;
    overflow-y: auto;
    transition: right 0.3s ease;
    z-index: 900;
    padding: 20px;
    flex-shrink: 0;
}

.side-menu:hover {
    right: 0;
}

.side-menu.show {
    right: 0;
}

.menu-header {
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.menu-header h3 {
    color: #00ff88;
    font-size: 1.2em;
}

.menu-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.menu-section h4 {
    color: #ffffff;
    margin-bottom: 15px;
    font-size: 1em;
}

.menu-section h5 {
    color: #cccccc;
    margin-bottom: 10px;
    font-size: 0.9em;
}

/* Botões */
.btn-primary,
.btn-secondary,
.btn-success,
.btn-warning,
.btn-danger,
.btn-info {
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    margin: 5px 5px 5px 0;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #1e7e34;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

/* Controles de mídia */
.media-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.media-controls button {
    width: 100%;
    justify-content: center;
}

/* Playlist */
.playlist-container {
    margin-top: 20px;
}

.playlist {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    padding: 10px;
}

.playlist-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.playlist-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

.playlist-item.active {
    background: rgba(0, 255, 136, 0.3);
    border: 1px solid #00ff88;
}

.playlist-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.playlist-item-name {
    font-size: 0.9em;
    color: #ffffff;
    margin-bottom: 2px;
}

.playlist-item-duration {
    font-size: 0.8em;
    color: #cccccc;
}

.playlist-item-actions {
    display: flex;
    gap: 5px;
}

.playlist-item-actions button {
    padding: 4px 8px;
    font-size: 0.8em;
    margin: 0;
}

/* Controles de tempo */
.time-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.time-controls label {
    color: #cccccc;
    font-size: 0.9em;
}

.time-controls input {
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 0.9em;
}

.time-controls input:focus {
    outline: none;
    border-color: #00ff88;
}

/* Controles de transição */
.transition-controls select {
    width: 100%;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    background: #ffffff;
    color: #333333;
    /* cinza escuro para melhor legibilidade */
    font-size: 0.9em;
}

.transition-controls select:focus {
    outline: none;
    border-color: #00ff88;
}

/* Controles de background */
.background-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.background-controls button {
    width: auto;
    justify-content: center;
}

/* Controles de reprodução */
.playback-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.playback-controls button {
    justify-content: center;
}

/* Controles de navegação */
.navigation-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.navigation-controls button {
    flex: 1;
    justify-content: center;
}

.slide-counter {
    text-align: center;
    color: #cccccc;
    font-size: 0.9em;
    padding: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Controles de tela cheia */
.fullscreen-controls {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 25px;
    border-radius: 25px;
    display: flex;
    gap: 15px;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.fullscreen-controls.show {
    opacity: 1;
    visibility: visible;
}

.fullscreen-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 50px;
    justify-content: center;
}

.fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

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

.fullscreen-btn i {
    font-size: 16px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-content {
    background-color: #2a2a2a;
    margin: 15% auto;
    padding: 20px;
    border-radius: 10px;
    width: 400px;
    max-width: 90%;
    position: relative;
}

.modal-content h3 {
    color: #00ff88;
    margin-bottom: 20px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 15px;
    top: 10px;
    cursor: pointer;
}

.close:hover {
    color: #fff;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-body label {
    color: #cccccc;
}

.modal-body input {
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

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

/* Efeitos de transição */
.transition-fade {
    transition: opacity var(--transition-duration, 1000ms) ease-in-out;
}

.transition-slide-left {
    transition: transform var(--transition-duration, 1000ms) ease-in-out;
}

.transition-slide-right {
    transition: transform var(--transition-duration, 1000ms) ease-in-out;
}

.transition-slide-up {
    transition: transform var(--transition-duration, 1000ms) ease-in-out;
}

.transition-slide-down {
    transition: transform var(--transition-duration, 1000ms) ease-in-out;
}

.transition-zoom {
    transition: transform var(--transition-duration, 1000ms) ease-in-out;
}

/* Estados de transição */
.fade-out {
    opacity: 0;
}

.slide-left-out {
    transform: translateX(-100%);
}

.slide-right-out {
    transform: translateX(100%);
}

.slide-up-out {
    transform: translateY(-100%);
}

.slide-down-out {
    transform: translateY(100%);
}

.zoom-in-out {
    transform: scale(0);
}

.zoom-out-out {
    transform: scale(2);
}

/* Responsividade */
@media (max-width: 768px) {
    .side-menu {
        width: 300px;
        right: -250px;
    }

    .playback-controls {
        grid-template-columns: 1fr;
    }

    .navigation-controls {
        flex-direction: column;
    }
}

/* Scrollbar personalizada */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Animações */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(100%);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* Indicador de carregamento */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #00ff88;
    animation: spin 1s ease-in-out infinite;
}

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

/* Color picker estilo botão */
.color-picker {
    width: 40px;
    height: 34px;
    padding: 0;
    border: none;
    cursor: pointer;
    margin-right: 8px;
}

/* Lista de PNG inseridos */
.overlay-list {
    margin-top: 10px;
    max-height: 150px;
    overflow-y: auto;
}

.overlay-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 5px 8px;
    margin-bottom: 5px;
    border-radius: 4px;
    font-size: 0.85em;
    cursor: pointer;
}

.overlay-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.overlay-item button {
    background: transparent;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
}

/* Fullscreen object-fit override */
#presentation-area.is-fullscreen #current-slide img,
#presentation-area.is-fullscreen #current-slide video {
    object-fit: cover !important;
}

/* Text Controls */
.collapsible-header {
    cursor: pointer;
    user-select: none;
}

.collapsible-header:hover h4 {
    color: #00ff88;
}

.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    color: #cccccc;
    font-size: 0.85em;
    margin-bottom: 4px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    font-size: 0.9em;
}

.form-group select option {
    background-color: #333333;
    color: white;
}

.form-group-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.form-group.half {
    flex: 1;
}

.color-picker-wrapper input[type="color"] {
    width: 100%;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.float-right {
    float: right;
}

.w-full {
    width: 100%;
}

/* Overlay Text */
.overlay-text {
    position: absolute;
    cursor: move;
    user-select: none;
    white-space: nowrap;
    z-index: 20;
    padding: 5px;
    border: 1px dashed transparent;
}

.overlay-text.selected {
    border-color: #00ff88;
    background: rgba(0, 255, 136, 0.1);
}

.overlay-text:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

/* Ensure font awesome icons work inside buttons */
.btn-primary i {
    margin-right: 5px;
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: #00ff88;
    border: 2px solid #ffffff;
    border-radius: 50%;
    z-index: 1500;
    /* Ensure it's above everything */
    display: none;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.overlay-image.selected .resize-handle,
.overlay-text.selected .resize-handle {
    display: block;
}

.resize-handle.nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.resize-handle.ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.resize-handle.sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.resize-handle.se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

.btn-icon-small {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon-small:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-icon-small.active {
    background: #00ff88;
    color: #1a1a1a;
    border-color: #00ff88;
}

textarea {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    font-family: inherit;
    padding: 8px;
}

/* Drop Zone Overlay */
.drop-zone-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    pointer-events: none;
    text-align: center;
    border-radius: inherit;
    overflow: hidden;
}

.drop-zone-overlay img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.4;
    z-index: 0;
    margin: 0;
}

.drop-zone-overlay .drop-text {
    position: relative;
    z-index: 1;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.95);
    background: rgba(0, 0, 0, 0.6);
    padding: 15px 30px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}