/* Coloring Image Plugin - Frontend Styles */

.coloring-book-wrapper {
    max-width: 1200px !important;
    width: 100%;
    margin: 0 auto 30px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
}

.coloring-book-wrapper *,
.coloring-book-wrapper *::before,
.coloring-book-wrapper *::after {
    box-sizing: border-box;
}

/* Header */
.coloring-book-header {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    padding: 16px 24px;
    text-align: center;
}

.coloring-book-title {
    margin: 0 !important;
    padding: 0 !important;
    color: #ffffff !important;
    font-size: 20px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
}

/* Image Preview Gallery */
.coloring-book-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 20px;
    background: #f9f9f9;
    border-bottom: 1px solid #e0e0e0;
    justify-content: center;
}

.coloring-book-gallery-item {
    width: 120px;
    height: 120px;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    overflow: hidden;
    padding: 8px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coloring-book-gallery-item:hover {
    border-color: #9ca3af;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.coloring-book-gallery-item.is-active {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.coloring-book-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

/* Body - Desktop: grid (artboard + toolbar sidebar) */
.coloring-book-body {
    display: grid;
    grid-template-columns: 3fr 1fr;
}

/* Main area (canvas only) */
.coloring-book-main {
    min-width: 0;
}

/* Canvas Area - Drawing Board */
.coloring-book-canvas {
    position: relative;
    background: #e8e8e8;
    padding: 20px;
    width: 100%;
}

.coloring-book-svg-container {
    background: #ffffff;
    border: 2px solid #c0c0c0;
    border-radius: 6px;
    padding: 20px;
    text-align: center;
    overflow: hidden;
    box-shadow:
        inset 0 1px 3px rgba(0, 0, 0, 0.06),
        0 2px 8px rgba(0, 0, 0, 0.1);
}

.coloring-book-svg-container svg {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 600px;
    display: block;
    margin: 0 auto;
    overflow: hidden;
}

.coloring-book-svg-container svg path,
.coloring-book-svg-container svg polygon,
.coloring-book-svg-container svg circle,
.coloring-book-svg-container svg ellipse,
.coloring-book-svg-container svg rect {
    cursor: pointer;
    transition: fill 0.15s ease;
    pointer-events: all;
}

.coloring-book-svg-container svg path:hover,
.coloring-book-svg-container svg polygon:hover,
.coloring-book-svg-container svg circle:hover,
.coloring-book-svg-container svg ellipse:hover,
.coloring-book-svg-container svg rect:hover {
    filter: brightness(0.95);
}

/* Toolbar - Desktop: right sidebar with scroll / Mobile: bottom */
.coloring-book-toolbar {
    position: relative;
    background: #f5f5f5;
    border-left: 1px solid #e0e0e0;
    min-height: 0;
}

.coloring-book-toolbar br {
    display: none;
}

/* Inner wrapper: scrollable within the artboard height */
.coloring-book-toolbar-inner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    padding: 14px;
}

/* Toolbar buttons: responsive auto-fit grid */
.coloring-book-toolbar-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.coloring-book-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    text-transform: uppercase;
    text-shadow: 1px 1px 2px #000;
    background: linear-gradient(45deg, #ff0066, #ffcc00);
    border: 2px solid #fff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
    line-height: 1.4;
    text-align: center;
    white-space: nowrap;
}

.coloring-book-btn:hover {
    background: linear-gradient(45deg, #ff0066, #ff6600);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

.coloring-book-btn:active {
    background: linear-gradient(45deg, #ff0066, #ff6600);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
    transform: scale(0.98);
}


/* Color Picker Panel (always visible inside toolbar) */
.coloring-book-color-panel {
    background: transparent;
}

.coloring-book-current-color {
    padding: 8px 0;
    margin-bottom: 14px;
    background: #ffffff;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    transition: background-color 0.15s ease;
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

/* Swatch group label */
.coloring-book-swatch-label {
    font-size: 11px;
    font-weight: 600;
    color: #555;
    text-align: center;
    margin: 0 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Palettes wrapper */
.coloring-book-palettes {
    /* Contains all dynamically created palette groups */
}

/* Color Swatches - shared group style */
.coloring-book-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    margin: 0 0 8px;
    padding: 8px;
    border: 1px solid #dddddd;
    border-radius: 10px;
}

.coloring-book-swatch {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid transparent;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s ease, border-color 0.15s ease;
}

.coloring-book-swatch:hover {
    transform: scale(1.2);
}

.coloring-book-swatch.is-active {
    border-color: #333;
    transform: scale(1.15);
}

.coloring-book-swatch[data-color="#FFFFFF"],
.coloring-book-swatch[data-color="#ffffff"] {
    border-color: #ddd;
}

.coloring-book-swatch[data-color="#FFFFFF"].is-active,
.coloring-book-swatch[data-color="#ffffff"].is-active {
    border-color: #333;
}

/* Responsive - below 768px: single column stacked layout */
@media (max-width: 768px) {
    .coloring-book-body {
        display: flex;
        flex-direction: column;
    }

    .coloring-book-toolbar {
        position: static;
        border-left: none;
        border-top: 1px solid #e0e0e0;
    }

    .coloring-book-toolbar-inner {
        position: static;
        overflow-y: visible;
        padding: 14px;
    }

    .coloring-book-gallery-item {
        width: 100px;
        height: 100px;
        padding: 6px;
    }
}

@media (max-width: 600px) {
    .coloring-book-wrapper {
        border-radius: 8px;
        margin: 0 auto 20px auto;
    }

    .coloring-book-header {
        padding: 12px 16px;
    }

    .coloring-book-title {
        font-size: 16px !important;
    }

    .coloring-book-canvas {
        padding: 12px;
    }

    .coloring-book-svg-container {
        padding: 12px;
    }

    .coloring-book-swatch {
        width: 22px;
        height: 22px;
    }

    .coloring-book-toolbar-inner {
        padding: 10px 12px;
    }

    .coloring-book-toolbar-buttons {
        gap: 6px;
    }

    .coloring-book-gallery-item {
        width: 100px;
        height: 100px;
        padding: 6px;
    }

    .coloring-book-gallery {
        gap: 8px;
        padding: 12px;
    }
}

@media (max-width: 500px) {
    .coloring-book-toolbar-buttons {
        grid-template-columns: 1fr 1fr;
    }

    .coloring-book-gallery-item {
        width: 60px;
        height: 60px;
        padding: 2px;
    }
}
