/* ========================================================================= */
/* CSS cho màn hình TÔ MÀU ONLINE (iPad-First Design, Kids UI)                 */
/* ========================================================================= */

:root {
    --gallery-bg: #f8f9fa;
    --hero-gradient: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
    --card-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    --primary-color: #ff6b6b;
    --canvas-bg: #e9ecef;
}

/* Base utility for screens */
.hidden-screen {
    display: none !important;
}

/* ================== GALLERY VIEW ================== */
.coloring-gallery {
    width: 100%;
    min-height: 100vh;
    background-color: var(--gallery-bg);
    padding-bottom: 80px;
    -webkit-overflow-scrolling: touch;
}

.gallery-hero {
    background: var(--hero-gradient);
    padding: 40px 20px;
    text-align: center;
    border-bottom-left-radius: 40px;
    border-bottom-right-radius: 40px;
    color: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.gallery-title {
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0 0 10px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.gallery-subtitle {
    font-size: 1.2rem;
    margin: 0;
    opacity: 0.9;
}

.gallery-filter-bar {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(248, 249, 250, 0.9);
    backdrop-filter: blur(10px);
}

.filter-pill {
    padding: 12px 24px;
    border-radius: 30px;
    border: none;
    background: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    font-size: 1.1rem;
    font-weight: 700;
    color: #555;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.filter-pill.active {
    background: var(--hero-gradient);
    color: white;
    box-shadow: 0 6px 15px rgba(251, 194, 235, 0.4);
    transform: scale(1.05);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.gallery-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: fadeInUp 0.5s ease backwards;
    -webkit-tap-highlight-color: transparent;
}

.gallery-card:active {
    transform: scale(0.95);
}

.gallery-card-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    padding: 15px;
    background: #fff;
}

.gallery-card-label {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================== WORKSPACE ================== */
.coloring-workspace {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* modern mobile viewport */
    background: var(--canvas-bg);
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.cw-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 10;
    padding-top: max(10px, env(safe-area-inset-top));
}

.cw-tool-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: none;
    background: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s;
}

.cw-tool-btn:active {
    transform: scale(0.9);
}

.cw-toolbar-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #333;
}

.cw-toolbar-right {
    display: flex;
    gap: 10px;
}

.canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: url('data:image/svg+xml;utf8,<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="2" r="2" fill="%23ddd"/></svg>') repeat;
    padding: 10px;
}

#coloring-canvas {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    touch-action: none; /* Prevent scroll on touch */
}

/* Tools Row */
.cw-tools-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
}

.cw-tool-select {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    border: 2px solid #eee;
    background: white;
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.cw-tool-select.active {
    border-color: transparent;
    background: linear-gradient(135deg, #6dd5ed, #2193b0);
    box-shadow: 0 4px 15px rgba(33, 147, 176, 0.4);
    transform: translateY(-2px);
}

.brush-size-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 20px;
    padding: 5px 15px;
    background: #f8f9fa;
    border-radius: 20px;
}

.size-dot {
    background: #ccc;
    border-radius: 50%;
}
.small-dot { width: 6px; height: 6px; }
.big-dot { width: 14px; height: 14px; }

.brush-slider {
    -webkit-appearance: none;
    width: 120px;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
}

.brush-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Color Palette */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    padding: 15px 20px;
    background: white;
    padding-bottom: max(15px, env(safe-area-inset-bottom));
}

.color-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    -webkit-tap-highlight-color: transparent;
}

@media (min-width: 768px) {
    .color-btn {
        width: 60px;
        height: 60px;
        gap: 15px;
    }
}

.color-btn.selected {
    transform: scale(1.2);
    border-color: #fff;
    box-shadow: 0 0 0 3px currentColor, 0 4px 15px rgba(0,0,0,0.3);
    animation: colorPulse 2s infinite;
}

@keyframes colorPulse {
    0% { box-shadow: 0 0 0 3px currentColor, 0 4px 15px rgba(0,0,0,0.3); }
    50% { box-shadow: 0 0 0 5px currentColor, 0 6px 20px rgba(0,0,0,0.4); }
    100% { box-shadow: 0 0 0 3px currentColor, 0 4px 15px rgba(0,0,0,0.3); }
}
