/**
 * Image Viewer Modal - Visualizador de Imagens com Zoom
 * Para visualização de páginas de jornais
 */

.image-viewer-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    animation: fadeIn 0.2s ease;
}

.image-viewer-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Header do viewer */
.image-viewer-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, transparent 100%);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10004;
}

.image-viewer-title {
    color: white;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.image-viewer-title i {
    color: #ffc107;
}

.image-viewer-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 32px;
    font-weight: 300;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.image-viewer-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* Container da imagem */
.image-viewer-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: grab;
    position: relative;
}

.image-viewer-container.dragging {
    cursor: grabbing;
}

.image-viewer-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    transition: transform 0.1s ease-out;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

/* Canvas para desenho */
.image-viewer-canvas {
    position: absolute;
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    pointer-events: auto;
    cursor: crosshair;
    transition: transform 0.1s ease-out;
}

/* ==========================================
   MODERN DRAW PANEL - Floating Bottom Style
   ========================================== */
.draw-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 220px;
    background: rgba(15, 15, 15, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5), 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10005;
    overflow: hidden;
    animation: slideInUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.draw-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.draw-panel-title {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.draw-panel-title i {
    color: #a78bfa;
    font-size: 14px;
}

.draw-panel-close {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: rgba(255, 255, 255, 0.6);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.draw-panel-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.draw-panel-section {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.draw-panel-label {
    display: block;
    color: rgba(255, 255, 255, 0.5);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

/* Modern Color Grid */
.draw-color-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.draw-color-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 2px solid transparent;
    background: var(--color);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.draw-color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.draw-color-btn.active {
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.5), inset 0 0 0 1px rgba(0,0,0,0.2);
}

.draw-color-btn.active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.draw-color-btn[data-color="#ffffff"].active::after {
    background: #1f2937;
}

/* Modern Stroke Width Row */
.draw-width-row {
    display: flex;
    gap: 6px;
}

.draw-width-btn {
    flex: 1;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.draw-width-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.draw-width-btn.active {
    background: rgba(139, 92, 246, 0.2);
    border-color: #8b5cf6;
}

.stroke-preview {
    display: block;
    width: 24px;
    height: var(--h);
    background: rgba(255, 255, 255, 0.7);
    border-radius: 2px;
}

.draw-width-btn.active .stroke-preview {
    background: #a78bfa;
}

/* Panel Actions */
.draw-panel-actions {
    padding: 12px 16px;
}

.draw-panel-btn {
    width: 100%;
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.draw-panel-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
}

/* Legacy styles - keep for backwards compatibility */
.image-viewer-draw-options {
    display: none !important;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.draw-option-group {
    margin-bottom: 15px;
}

.draw-option-group:last-child {
    margin-bottom: 0;
}

.draw-option-group label {
    display: block;
    color: #f4d03f;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Paleta de cores */
.draw-color-palette {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.draw-color-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.draw-color-btn:hover {
    transform: scale(1.15);
    border-color: #f4d03f;
    box-shadow: 0 0 12px rgba(244, 208, 63, 0.6);
}

.draw-color-btn.active {
    border-color: #f4d03f;
    border-width: 3px;
    box-shadow: 0 0 16px rgba(244, 208, 63, 0.8), inset 0 0 8px rgba(255, 255, 255, 0.3);
}

.draw-color-btn.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 16px;
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
}

/* Opcoes de espessura */
.draw-width-options {
    display: flex;
    gap: 10px;
}

.draw-width-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fdfbf7;
}

.draw-width-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #f4d03f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(244, 208, 63, 0.3);
}

.draw-width-btn.active {
    background: linear-gradient(135deg, #f4d03f 0%, #d4a574 100%);
    border-color: #f4d03f;
    box-shadow: 0 4px 16px rgba(244, 208, 63, 0.5);
}

.draw-width-btn div {
    border-radius: 2px;
}

.draw-width-btn.active div {
    background: #6a4f00 !important;
}

/* Setas de navegação */
.image-viewer-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, rgba(106, 79, 0, 0.9) 0%, rgba(139, 101, 0, 0.9) 100%);
    border: 2px solid #d4a574;
    color: #f4d03f;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 10004;
    box-shadow: 0 4px 20px rgba(106, 79, 0, 0.4);
}

.image-viewer-nav-btn:hover {
    background: linear-gradient(135deg, rgba(139, 101, 0, 0.95) 0%, rgba(160, 118, 0, 0.95) 100%);
    border-color: #f4d03f;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 30px rgba(106, 79, 0, 0.6);
}

.image-viewer-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.image-viewer-prev {
    left: 30px;
}

.image-viewer-next {
    right: 30px;
}

/* Toolbar de controles - Redesigned Minimalist FAB Style */
.image-viewer-toolbar {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 10px 16px;
    border-radius: 16px;
    display: flex;
    gap: 6px;
    align-items: center;
    z-index: 10004;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Auto-hide toolbar on inactivity */
.image-viewer-toolbar.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

/* Tool Groups */
.image-viewer-toolbar .tool-group {
    display: flex;
    gap: 4px;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 12px;
}

.image-viewer-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    position: relative;
}

.image-viewer-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: scale(1.05);
}

.image-viewer-btn:active {
    transform: scale(0.95);
}

.image-viewer-btn.primary {
    background: rgba(106, 79, 0, 0.6);
    color: #f4d03f;
}

.image-viewer-btn.primary:hover {
    background: rgba(106, 79, 0, 0.8);
    color: #fff;
}

.image-viewer-btn.active {
    background: linear-gradient(135deg, #6a4f00 0%, #8b6500 100%);
    color: #f4d03f;
    box-shadow: 0 2px 8px rgba(106, 79, 0, 0.4);
}

.image-viewer-btn.active:hover {
    background: linear-gradient(135deg, #8b6500 0%, #a07600 100%);
}

.image-viewer-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 4px;
}

/* Zoom info */
.image-viewer-zoom-info {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    font-weight: 600;
    min-width: 48px;
    text-align: center;
    padding: 0 6px;
    font-family: 'Inter', -apple-system, sans-serif;
}

/* Loading */
.image-viewer-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.image-viewer-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffc107;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Erro */
.image-viewer-error {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
    padding: 20px 30px;
    border-radius: 10px;
    border: 1px solid rgba(255, 107, 107, 0.3);
    text-align: center;
}

/* Tooltips */
.image-viewer-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    white-space: nowrap;
    margin-bottom: 8px;
    pointer-events: none;
}

/* Responsivo */
@media (max-width: 768px) {
    .image-viewer-header {
        padding: 10px 15px;
    }
    
    .image-viewer-title {
        font-size: 14px;
    }
    
    .image-viewer-toolbar {
        bottom: 15px;
        padding: 8px 12px;
        gap: 4px;
        border-radius: 14px;
        max-width: calc(100vw - 30px);
        overflow-x: auto;
    }
    
    .image-viewer-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
        flex-shrink: 0;
    }
    
    .image-viewer-zoom-info {
        font-size: 11px;
        min-width: 40px;
        padding: 0 4px;
    }
    
    .image-viewer-close {
        width: 38px;
        height: 38px;
        font-size: 28px;
    }
    
    .image-viewer-nav-btn {
        width: 46px;
        height: 46px;
        font-size: 18px;
    }
    
    .image-viewer-prev {
        left: 10px;
    }
    
    .image-viewer-next {
        right: 10px;
    }
    
    .image-viewer-draw-options {
        bottom: 70px;
        padding: 15px;
        max-width: calc(100vw - 40px);
    }
    
    .draw-color-btn {
        width: 28px;
        height: 28px;
    }
    
    .draw-width-btn {
        padding: 10px 12px;
    }
    
    .image-viewer-divider {
        display: none;
    }
}

/* Animação de entrada */
.image-viewer-image {
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==========================================
   SMART CLIPPING FEATURE STYLES
   ========================================== */

/* Clip Overlay Canvas */
.image-viewer-clip-overlay {
    position: fixed;
    z-index: 10002;
    cursor: crosshair;
    touch-action: none;
}

/* ==========================================
   MODERN CLIP PREVIEW - Clean Card Style
   ========================================== */
.clip-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10010;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.25s ease;
}

.clip-preview-card {
    position: relative;
    background: rgba(20, 20, 20, 0.95);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: min(600px, 90vw);
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    animation: scaleIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.clip-preview-card .clip-preview-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.7);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.clip-preview-card .clip-preview-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.clip-preview-canvas-wrap {
    padding: 24px;
    padding-top: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: calc(85vh - 80px);
    overflow: auto;
}

.clip-preview-canvas-wrap .clip-result-canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.clip-preview-actions {
    display: flex;
    gap: 10px;
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Modern Clip Buttons */
.clip-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clip-btn i {
    font-size: 14px;
}

.clip-btn-ghost {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.clip-btn-ghost:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.clip-btn-primary {
    background: linear-gradient(135deg, #6a4f00 0%, #8b6500 100%);
    color: #fff;
}

.clip-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(106, 79, 0, 0.4);
}

.clip-btn-share {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: #fff;
}

.clip-btn-share:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* Legacy classes - hidden */
.image-viewer-clip-preview {
    display: none !important;
}

.clip-preview-content,
.clip-preview-header,
.clip-preview-body,
.clip-preview-footer,
.clip-action-btn {
    display: none !important;
}

.clip-action-btn i {
    font-size: 16px;
}

.clip-action-btn.secondary {
    background: #f0f0f0;
    color: #555;
}

.clip-action-btn.secondary:hover {
    background: #e0e0e0;
}

.clip-action-btn.primary {
    background: #6a4f00;
    color: #fff;
}

.clip-action-btn.primary:hover {
    background: #8b6500;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(106, 79, 0, 0.3);
}

.clip-action-btn.share {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: #fff;
}

.clip-action-btn.share:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

/* Toast Notification */
.image-viewer-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 14px 24px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10020;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.image-viewer-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.image-viewer-toast.success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.image-viewer-toast.warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    color: #333;
}

.image-viewer-toast.info {
    background: linear-gradient(135deg, #6a4f00 0%, #8b6500 100%);
}

.image-viewer-toast.error {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

/* Clip Button Active State */
.image-viewer-btn#image-viewer-clip-btn.active {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border-color: #28a745;
    color: #fff;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    /* Draw Panel - Mobile */
    .draw-panel {
        bottom: 70px;
        right: 10px;
        left: 10px;
        width: auto;
        max-height: 45vh;
        overflow-y: auto;
    }
    
    .draw-panel-header {
        padding: 10px 14px;
    }
    
    .draw-panel-section {
        padding: 10px 14px;
    }
    
    .draw-color-grid {
        grid-template-columns: repeat(10, 1fr);
        gap: 4px;
    }
    
    .draw-color-btn {
        width: 24px;
        height: 24px;
        border-radius: 6px;
    }
    
    .draw-width-row {
        gap: 6px;
    }
    
    .draw-width-btn {
        height: 36px;
    }
    
    .draw-panel-actions {
        padding: 10px 14px;
    }
    
    /* Clip Modal - Mobile */
    .clip-modal-card {
        margin: 10px;
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
    }
    
    .clip-modal-header {
        padding: 12px 16px;
    }
    
    .clip-modal-header h3 {
        font-size: 14px;
    }
    
    .clip-modal-body {
        padding: 15px;
        max-height: 45vh;
    }
    
    .clip-modal-footer {
        flex-wrap: wrap;
        padding: 12px;
        gap: 8px;
    }
    
    .clip-modal-btn {
        flex: 1;
        min-width: 80px;
        justify-content: center;
        padding: 10px 12px;
        font-size: 12px;
    }
    
    /* Toast - Mobile */
    .image-viewer-toast {
        bottom: 80px;
        max-width: calc(100vw - 40px);
        white-space: normal;
        text-align: center;
    }
}
