/* =====================================================
   CONVERSOR DE IMAGENS - Estilos
   Design moderno com tema escuro e acentos vibrantes
   ===================================================== */

/* Variáveis CSS */
:root {
    --primary-color: #00ff88;
    --primary-dark: #00cc6a;
    --secondary-color: #007bff;
    --danger-color: #dc3545;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --bg-dark: #1a1a2e;
    --bg-panel: rgba(30, 30, 50, 0.95);
    --bg-input: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: rgba(255, 255, 255, 0.15);
    --shadow-glow: 0 0 20px rgba(0, 255, 136, 0.2);
}

/* Container principal da aplicação */
#app-container {
    display: flex;
    flex-direction: row;
    gap: 16px;
    padding: 16px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 12px;
    min-height: calc(100vh - 200px);
}

/* Wrapper do Canvas */
#canvas-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Changed from space-between since slider is now absolute */
    /* Push carousel to bottom */
    min-width: 0;
    height: 100%;
    /* Ensure full height */
    position: relative;
    /* Needed for absolute positioning of slider */
    padding-bottom: 150px;
    /* Space for the slider */
}

/* Container do Canvas */
#canvas-container {
    position: relative;
    background: #0a0a14;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-glow), 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    /* Flex properties to fill space */
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    /* Space between canvas and dimension indicator/slider */
}

#canvas-container:hover {
    border-color: var(--primary-color);
}

#main-canvas {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 350px);
}

/* Indicador de dimensões */
#dimension-indicator {
    margin-top: 12px;
    padding: 8px 16px;
    background: var(--bg-panel);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 600;
    border: 1px solid var(--border-color);
}

/* Overlay de marca d'água */
#watermark-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Removed empty #watermark-overlay.active */

.watermark-element {
    position: absolute;
    cursor: move;
    border: 2px dashed transparent;
    transition: border-color 0.3s ease;
    pointer-events: auto;
    /* Enable interaction for the element itself */
}

.watermark-element:hover,
.watermark-element.selected {
    border-color: var(--primary-color);
}

.watermark-element img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* Handles de redimensionamento */
#image-handles .handle,
.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border: 2px solid #fff;
    border-radius: 50%;
    z-index: 100;
}

#image-handles .handle.nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

#image-handles .handle.ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

#image-handles .handle.sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

#image-handles .handle.se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

/* =====================================================
   SLIDER DE IMAGENS
   ===================================================== */

#image-slider-container {
    width: 100%;
    margin-top: 0;
    padding: 12px;
    background: var(--bg-panel);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 10;
}

#image-slider {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 8px 4px;
    scroll-behavior: smooth;
}

#image-slider::-webkit-scrollbar {
    height: 8px;
}

#image-slider::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

#image-slider::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.slider-thumbnail {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    background: #000;
}

.slider-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.slider-thumbnail:hover {
    transform: scale(1.05);
    border-color: var(--primary-color);
}

.slider-thumbnail.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.slider-thumbnail .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: var(--danger-color);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 10px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slider-thumbnail:hover .remove-btn {
    opacity: 1;
}

.slider-thumbnail .index-badge {
    position: absolute;
    bottom: 2px;
    left: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
}

#slider-info {
    text-align: center;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#slider-info #image-count {
    color: var(--primary-color);
    font-weight: bold;
}

/* =====================================================
   PAINEL DE CONTROLES
   ===================================================== */

.side-menu {
    width: 320px;
    min-width: 320px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.menu-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.menu-header h3 {
    color: var(--primary-color);
    font-size: 1.2em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.menu-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.menu-section h4 {
    color: var(--text-primary);
    font-size: 0.95em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-section h4 i {
    color: var(--primary-color);
    width: 20px;
    text-align: center;
}

/* Seções colapsáveis */
.collapsible-header {
    cursor: pointer;
    transition: color 0.3s ease;
}

.collapsible-header:hover h4 {
    color: var(--primary-color);
}

.collapsible-header .fa-chevron-down {
    transition: transform 0.3s ease;
    font-size: 0.8em;
    margin-left: auto;
}

.collapsible-content {
    padding-top: 10px;
}

/* Grupos de controles */
.controls-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.controls-group label {
    color: var(--text-secondary);
    font-size: 0.85em;
    margin-bottom: 2px;
}

/* =====================================================
   BOTÕES
   ===================================================== */

.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-warning,
.btn-info {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--secondary-color), #0056b3);
    color: #fff;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0056b3, var(--secondary-color));
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--primary-color);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #1e7e34);
    color: #fff;
}

.btn-success:hover {
    background: linear-gradient(135deg, #1e7e34, var(--success-color));
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #a71d2a);
    color: #fff;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #a71d2a, var(--danger-color));
    transform: translateY(-2px);
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.btn-icon:hover {
    background: var(--primary-color);
    color: #000;
    border-color: var(--primary-color);
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

/* =====================================================
   INPUTS
   ===================================================== */

select,
input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9em;
    transition: all 0.3s ease;
}

select:focus,
input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 255, 136, 0.1);
}

select option {
    background: #1a1a2e;
    color: #fff;
}

select optgroup {
    background: #0a0a14;
    color: var(--primary-color);
    font-weight: bold;
}

.dimension-inputs .flex {
    display: flex;
}

.dimension-inputs .flex-1 {
    flex: 1;
}

.dimension-inputs .gap-2 {
    gap: 8px;
}

/* =====================================================
   SLIDERS (RANGE INPUTS)
   ===================================================== */

.slider-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.slider-control label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    color: var(--text-secondary);
}

.slider-control label i {
    color: var(--primary-color);
    width: 16px;
    text-align: center;
    font-size: 0.9em;
}

.slider-control input[type="range"] {
    flex: 2;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}

.slider-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.slider-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-control .value-display {
    min-width: 45px;
    text-align: right;
    font-size: 0.8em;
    color: var(--primary-color);
    font-weight: 600;
}

/* Checkbox */
.checkbox-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-control input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.checkbox-control label {
    color: var(--text-secondary);
    font-size: 0.9em;
    cursor: pointer;
}

/* =====================================================
   FILTROS PREDEFINIDOS
   ===================================================== */

.filters-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.filter-btn {
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--primary-color);
}

.filter-btn.active {
    background: var(--primary-color);
    color: #000;
    border-color: var(--primary-color);
    font-weight: 600;
}

/* =====================================================
   UTILITÁRIOS
   ===================================================== */

.w-full {
    width: 100%;
}

.mt-2 {
    margin-top: 8px;
}

.mt-3 {
    margin-top: 12px;
}

.mt-4 {
    margin-top: 16px;
}

.flex {
    display: flex;
}

.flex-1 {
    flex: 1;
}

.gap-2 {
    gap: 8px;
}

.hidden {
    display: none !important;
}

/* Crop specific cursors */
.cursor-crosshair {
    cursor: crosshair;
}

.cursor-move {
    cursor: move;
}

.cursor-nw-resize {
    cursor: nw-resize;
}

.cursor-ne-resize {
    cursor: ne-resize;
}

.cursor-sw-resize {
    cursor: sw-resize;
}

.cursor-se-resize {
    cursor: se-resize;
}

.float-right {
    float: right;
}

/* =====================================================
   SCROLLBAR PERSONALIZADA
   ===================================================== */

.side-menu::-webkit-scrollbar {
    width: 6px;
}

.side-menu::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.side-menu::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

/* =====================================================
   RESPONSIVIDADE
   ===================================================== */

@media (max-width: 1200px) {
    #app-container {
        flex-direction: column;
    }

    .side-menu {
        width: 100%;
        min-width: auto;
        max-height: none;
    }

    #canvas-wrapper {
        order: 1;
    }

    #image-slider-container {
        order: 2;
    }

    .side-menu {
        order: 3;
    }
}

@media (max-width: 768px) {
    #app-container {
        padding: 10px;
    }

    .slider-thumbnail {
        width: 60px;
        height: 60px;
    }

    .button-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }
}

/* =====================================================
   ANIMAÇÕES
   ===================================================== */

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slider-thumbnail {
    animation: fadeIn 0.3s ease forwards;
}

/* Loading state */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--bg-panel);
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9em;
    z-index: 9999;
    animation: slideInRight 0.3s ease;
}

.toast.error {
    border-color: var(--danger-color);
}

.toast.success {
    border-color: var(--success-color);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 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: 5;
    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);
}