/**
 * Zumipic Coloring Book – Canvas Page Styles v2.4.0
 *
 * Compact icon-only toolbar in one row with localized tooltips.
 * Sidebar palette (desktop) | Top palette (mobile).
 * HSL color wheel + preset colors + custom saved colors.
 * Default bucket fill, bucket eraser tool.
 * Social sharing buttons and analytics tracking.
 * WordPress dashboard statistics.
 * Scroll-based zoom/pan, no blank canvas space.
 */

/* ==========================================
   RESET / BASE
   ========================================== */

.zumipic-app * {
    box-sizing: border-box;
}

.zumipic-app {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f0f0f0;
    color: #333;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

/* ==========================================
   LOADING OVERLAY
   ========================================== */

.zumipic-loading {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    transition: opacity 0.4s;
}

.zumipic-loading.zumipic-hidden {
    opacity: 0;
    pointer-events: none;
}

.zumipic-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e0e0e0;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: zumipic-spin 0.8s linear infinite;
}

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

.zumipic-loading p {
    margin: 0;
    font-size: 14px;
    color: #666;
}

/* ==========================================
   HEADER
   ========================================== */

.zumipic-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.zumipic-back-link {
    font-size: 13px;
    color: #0073aa;
    text-decoration: none;
    white-space: nowrap;
}

.zumipic-back-link:hover {
    text-decoration: underline;
}

.zumipic-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.zumipic-save-indicator {
    font-size: 12px;
    color: #999;
    opacity: 0;
    transition: opacity 0.3s;
    white-space: nowrap;
}

.zumipic-save-indicator.active {
    opacity: 1;
}

/* ==========================================
   TOOLBAR – single compact row, icons only
   ========================================== */

.zumipic-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 5px 10px 45px 10px; /* Extra bottom padding for tooltips */
    margin-bottom: -40px; /* Compensate for tooltip space */
    background: #fff;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
    flex-wrap: nowrap;
    overflow: visible; /* Allow tooltips to show */
}

/* Groups */
.zumipic-tool-group,
.zumipic-actions-group {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.zumipic-sliders-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.zumipic-zoom-group {
    display: inline-flex;
    gap: 1px;
}

/* Vertical dividers between sections */
.zumipic-toolbar-divider {
    width: 1px;
    height: 24px;
    background: #ddd;
    margin: 0 6px;
    flex-shrink: 0;
}

/* Icon-only tool/action buttons */
.zumipic-tool-btn,
.zumipic-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    background: none;
    border-radius: 6px;
    padding: 0;
    color: #555;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

.zumipic-tool-btn:hover,
.zumipic-action-btn:hover {
    background: #f0f0f0;
    color: #333;
    border-color: #ccc;
}

.zumipic-tool-btn.active {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
    box-shadow: 0 1px 4px rgba(0, 115, 170, 0.3);
}

/* Close gaps button - special styling when active */
.zumipic-close-gaps-btn.active {
    background: #00a32a;
    color: #fff;
    border-color: #00a32a;
    box-shadow: 0 1px 4px rgba(0, 163, 42, 0.3);
}

.zumipic-action-btn.disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

/* No text labels */
.zumipic-btn-label {
    display: none;
}

/* Sliders – compact icon + slider + value */
.zumipic-slider-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.zumipic-slider-icon {
    display: inline-flex;
    color: #888;
    flex-shrink: 0;
}

.zumipic-slider-label {
    display: none; /* hidden – replaced by icons */
}

.zumipic-slider {
    width: 60px;
    cursor: pointer;
    accent-color: #0073aa;
}

.zumipic-slider-value {
    font-size: 11px;
    min-width: 20px;
    text-align: center;
    color: #555;
    font-weight: 500;
    flex-shrink: 0;
}

.zumipic-tolerance-wrap {
    display: none;
}

/* ==========================================
   WORKSPACE – canvas + sidebar palette
   ========================================== */

.zumipic-workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    flex-direction: row;
    min-height: 0;
}

/* Canvas area fills remaining width */
.zumipic-canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Scrollable wrapper – enables scroll-based pan */
.zumipic-canvas-wrapper {
    flex: 1;
    overflow: scroll; /* Always show scrollbars */
    background: #e0e0e0;
    position: relative;
    /* Remove flex centering - it interferes with scroll when zoomed */
}

/* Force scrollbars to always be visible (macOS overlay scrollbars) */
.zumipic-canvas-wrapper::-webkit-scrollbar {
    width: 16px;
    height: 16px;
    -webkit-appearance: none; /* Override macOS overlay behavior */
}

.zumipic-canvas-wrapper::-webkit-scrollbar-track {
    background: #c0c0c0;
}

.zumipic-canvas-wrapper::-webkit-scrollbar-thumb {
    background: #666;
    border: 3px solid #c0c0c0;
    border-radius: 8px;
    min-height: 40px; /* Ensure thumb is always visible */
    min-width: 40px;
}

.zumipic-canvas-wrapper::-webkit-scrollbar-thumb:hover {
    background: #444;
}

.zumipic-canvas-wrapper::-webkit-scrollbar-corner {
    background: #c0c0c0;
}

/* Firefox scrollbar styling - always visible */
.zumipic-canvas-wrapper {
    scrollbar-width: auto;
    scrollbar-color: #666 #c0c0c0;
    scrollbar-gutter: stable; /* Reserve space for scrollbar */
}

/* Inner div sized to exact scaled canvas dimensions */
.zumipic-canvas-inner {
    display: block;
    position: relative;
    flex-shrink: 0;
    line-height: 0;
    /* Margin auto centers when smaller than wrapper, but allows scroll when larger */
    margin: auto;
}

.zumipic-canvas {
    display: block;
    image-rendering: auto;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

/* ==========================================
   PALETTE – sidebar on desktop
   ========================================== */

.zumipic-palette {
    width: 180px;
    flex-shrink: 0;
    background: #fff;
    border-left: 1px solid #ddd;
    padding: 14px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Color picker inline */
.zumipic-picker-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zumipic-current-color {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 2px solid #ccc;
    flex-shrink: 0;
}

.zumipic-color-picker {
    width: 36px;
    height: 36px;
    border: none;
    padding: 0;
    cursor: pointer;
    background: none;
    border-radius: 6px;
}

.zumipic-color-picker::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.zumipic-color-picker::-webkit-color-swatch {
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Color swatches grid */
.zumipic-swatches {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}

.zumipic-swatch {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
    padding: 0;
}

.zumipic-swatch:hover {
    transform: scale(1.15);
    z-index: 1;
    border-color: #999;
}

.zumipic-swatch.active {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.3);
    transform: scale(1.1);
}

.zumipic-swatch-light {
    border-color: #bbb;
}

/* ==========================================
   CURRENT COLOR SECTION
   ========================================== */

.zumipic-current-section {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

/* ==========================================
   HSL COLOR WHEEL
   ========================================== */

.zumipic-wheel-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.zumipic-wheel-label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.zumipic-hsl-wheel {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zumipic-hue-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 140px;
    height: 140px;
    cursor: crosshair;
}

.zumipic-sat-light-box {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 4px;
    cursor: crosshair;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* ==========================================
   PRESET COLORS SECTION
   ========================================== */

.zumipic-presets-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.zumipic-presets-label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==========================================
   CUSTOM COLORS SECTION
   ========================================== */

.zumipic-custom-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.zumipic-custom-label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.zumipic-custom-swatches {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    min-height: 32px;
}

.zumipic-custom-swatch {
    position: relative;
}

.zumipic-add-color-btn {
    width: 32px;
    height: 32px;
    border: 2px dashed #ccc;
    border-radius: 6px;
    background: #f8f8f8;
    color: #888;
    font-size: 20px;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    margin-top: 4px;
}

.zumipic-add-color-btn:hover {
    border-color: #0073aa;
    color: #0073aa;
    background: #f0f7fc;
}

/* ==========================================
   RESPONSIVE – Tablet
   ========================================== */

@media (max-width: 1024px) {
    .zumipic-palette {
        width: 160px;
        padding: 10px 8px;
    }

    .zumipic-slider {
        width: 50px;
    }
}

/* ==========================================
   RESPONSIVE – Mobile (<768px)
   ========================================== */

@media (max-width: 768px) {
    .zumipic-app {
        height: 100vh;
        height: 100dvh; /* dynamic viewport for mobile browsers */
    }

    .zumipic-header {
        padding: 5px 10px;
    }

    .zumipic-title {
        font-size: 13px;
    }

    .zumipic-toolbar {
        padding: 4px 6px;
        margin-bottom: 0; /* No tooltip space needed on mobile */
        gap: 1px;
    }

    .zumipic-tool-btn,
    .zumipic-action-btn {
        width: 30px;
        height: 30px;
    }

    .zumipic-tool-btn svg,
    .zumipic-action-btn svg {
        width: 16px;
        height: 16px;
    }

    .zumipic-slider {
        width: 40px;
    }

    .zumipic-slider-value {
        font-size: 10px;
        min-width: 16px;
    }

    .zumipic-toolbar-divider {
        height: 20px;
        margin: 0 3px;
    }

    /* Palette moves above canvas on mobile */
    .zumipic-workspace {
        flex-direction: column;
    }

    .zumipic-palette {
        width: 100%;
        border-left: none;
        border-bottom: 1px solid #ddd;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 6px 8px;
        overflow-x: auto;
        overflow-y: hidden;
        order: -1;
    }

    .zumipic-picker-wrap {
        flex-shrink: 0;
    }

    .zumipic-current-color {
        width: 28px;
        height: 28px;
    }

    .zumipic-color-picker {
        width: 28px;
        height: 28px;
    }

    .zumipic-swatches {
        display: flex;
        flex-wrap: nowrap;
        gap: 4px;
        flex-shrink: 0;
    }

    /* Hide wheel & labels on mobile - use native picker */
    .zumipic-wheel-section {
        display: none;
    }

    .zumipic-presets-label,
    .zumipic-custom-label {
        display: none;
    }

    .zumipic-current-section {
        flex-shrink: 0;
    }

    .zumipic-presets-section,
    .zumipic-custom-section {
        flex-shrink: 0;
        flex-direction: row;
        align-items: center;
    }

    .zumipic-custom-swatches {
        display: flex;
        flex-wrap: nowrap;
        gap: 4px;
    }

    .zumipic-add-color-btn {
        width: 28px;
        height: 28px;
        margin-top: 0;
        font-size: 16px;
    }

    .zumipic-swatch {
        width: 28px;
        height: 28px;
        aspect-ratio: auto;
        flex-shrink: 0;
    }

    .zumipic-canvas-wrapper {
        min-height: 45vh;
    }
}

/* ==========================================
   RESPONSIVE – Small phone (<480px)
   ========================================== */

@media (max-width: 480px) {
    .zumipic-header {
        padding: 4px 6px;
        gap: 6px;
    }

    .zumipic-back-link {
        font-size: 11px;
    }

    .zumipic-title {
        font-size: 12px;
    }

    .zumipic-toolbar {
        padding: 3px 4px;
    }

    .zumipic-tool-btn,
    .zumipic-action-btn {
        width: 28px;
        height: 28px;
    }

    .zumipic-tool-btn svg,
    .zumipic-action-btn svg {
        width: 14px;
        height: 14px;
    }

    .zumipic-slider {
        width: 32px;
    }

    .zumipic-palette {
        padding: 5px 6px;
        gap: 5px;
    }

    .zumipic-swatch {
        width: 24px;
        height: 24px;
    }

    .zumipic-current-color {
        width: 24px;
        height: 24px;
    }

    .zumipic-color-picker {
        width: 24px;
        height: 24px;
    }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
    .zumipic-header,
    .zumipic-toolbar,
    .zumipic-palette,
    .zumipic-loading {
        display: none !important;
    }

    .zumipic-app {
        background: #fff !important;
        height: auto !important;
        overflow: visible !important;
    }

    .zumipic-workspace {
        display: block !important;
    }

    .zumipic-canvas-wrapper {
        overflow: visible !important;
    }

    .zumipic-canvas-inner {
        width: auto !important;
        height: auto !important;
    }

    .zumipic-canvas {
        transform: none !important;
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
        box-shadow: none !important;
    }
}

/* ==========================================
   SCROLLBAR STYLING
   ========================================== */

.zumipic-canvas-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.zumipic-canvas-wrapper::-webkit-scrollbar-track {
    background: #e0e0e0;
}

.zumipic-canvas-wrapper::-webkit-scrollbar-thumb {
    background: #aaa;
    border-radius: 4px;
}

.zumipic-canvas-wrapper::-webkit-scrollbar-thumb:hover {
    background: #888;
}

.zumipic-canvas-wrapper {
    scrollbar-width: thin;
    scrollbar-color: #aaa #e0e0e0;
}

/* ==========================================
   SELECTION PREVENTION
   ========================================== */

.zumipic-canvas {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

.zumipic-canvas-wrapper {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* ==========================================
   TOOLTIP for icon-only buttons
   ========================================== */

.zumipic-tool-btn,
.zumipic-action-btn {
    position: relative;
}

/* Tooltip bubble - positioned BELOW buttons */
.zumipic-tool-btn[data-tooltip]::before,
.zumipic-action-btn[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: #333;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* Tooltip arrow - pointing UP (tooltip is below button) */
.zumipic-tool-btn[data-tooltip]::after,
.zumipic-action-btn[data-tooltip]::after {
    content: '';
    position: absolute;
    top: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: #333;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 1000;
}

/* Show tooltip on hover */
.zumipic-tool-btn:hover::before,
.zumipic-tool-btn:hover::after,
.zumipic-action-btn:hover::before,
.zumipic-action-btn:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Adjust tooltip position for buttons near right edge */
.zumipic-zoom-group .zumipic-action-btn[data-tooltip]::before {
    left: auto;
    right: 0;
    transform: none;
}

.zumipic-zoom-group .zumipic-action-btn[data-tooltip]::after {
    left: auto;
    right: 10px;
    transform: none;
}

/* Adjust tooltip for buttons near left edge */
.zumipic-actions-left .zumipic-action-btn[data-tooltip]::before {
    left: 0;
    transform: none;
}

.zumipic-actions-left .zumipic-action-btn[data-tooltip]::after {
    left: 10px;
    transform: none;
}

/* Hide tooltips on mobile/touch */
@media (max-width: 768px) {
    .zumipic-tool-btn::before,
    .zumipic-tool-btn::after,
    .zumipic-action-btn::before,
    .zumipic-action-btn::after {
        display: none !important;
    }
}

/* ==========================================
   SHARE MENU
   ========================================== */

.zumipic-share-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    min-width: 280px;
    max-width: 360px;
}

.zumipic-share-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.zumipic-share-menu-header {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
    color: #333;
}

.zumipic-share-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.zumipic-share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #fff;
}

.zumipic-share-btn svg {
    flex-shrink: 0;
}

.zumipic-share-facebook {
    background: #1877f2;
}

.zumipic-share-facebook:hover {
    background: #0d65d9;
}

.zumipic-share-twitter {
    background: #000;
}

.zumipic-share-twitter:hover {
    background: #333;
}

.zumipic-share-pinterest {
    background: #e60023;
}

.zumipic-share-pinterest:hover {
    background: #c50020;
}

.zumipic-share-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.zumipic-share-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .zumipic-share-menu {
        width: calc(100% - 32px);
        max-width: none;
    }
}

