/* =============================================
   BASIC RESET & GLOBAL STYLES
   ============================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background-color: #f9f9f9;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* =============================================
   HEADER & NAVIGATION
   ============================================= */
header {
    background-color: #6b5b95;
    color: white;
    padding: 20px 0;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

header .tagline {
    font-size: 1.2rem;
    font-style: italic;
}

nav {
    background-color: #88d8b0;
    padding: 15px 0;
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

nav ul li {
    margin: 0 15px;
}

nav ul li a {
    color: #333;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.1rem;
    transition: color 0.3s;
}

nav ul li a:hover {
    color: #6b5b95;
}

/* =============================================
   LAYOUT COMPONENTS
   ============================================= */
.drawing-container, .painting-container, .image-puzzle-container, .jigsaw-puzzle-container {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin: 30px 0;
}

.drawing-panel, .painting-panel, .image-puzzle-panel, .reference-panel {
    flex: 1;
    min-width: 300px;
    background-color: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.drawing-panel h2, .painting-panel h2, .image-puzzle-panel h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: #6b5b95;
    text-align: center;
}

/* =============================================
   GRID COMPONENTS
   ============================================= */
.drawing-grid, .painting-grid, .image-puzzle-grid, .jigsaw-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.drawing-card, .painting-card, .image-puzzle-card {
    background-color: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s;
}

.drawing-card:hover, .painting-card:hover, .image-puzzle-card:hover {
    transform: translateY(-5px);
}

.drawing-card img, .painting-card img, .image-puzzle-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.drawing-card .card-content, .painting-card .card-content, .image-puzzle-card .card-content {
    padding: 15px;
}

.drawing-card h3, .painting-card h3, .image-puzzle-card h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #6b5b95;
}

.drawing-card .view-drawing, .painting-card .view-painting, .image-puzzle-card .view-image-puzzle {
    display: inline-block;
    background-color: #ffcc5c;
    color: #333;
    padding: 8px 15px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.3s;
}

.drawing-card .view-drawing:hover, .painting-card .view-painting:hover, .image-puzzle-card .view-image-puzzle:hover {
    background-color: #ffb347;
}

/* =============================================
   CANVAS & SVG STYLES
   ============================================= */
.canvas-container, .reference-image-container {
    width: 100%;
    height: 400px;
    border-radius: 5px;
    margin-bottom: 20px;
    overflow: hidden;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.canvas-container {
    border: 2px solid #88d8b0;
}

.reference-image-container {
    border: 2px solid #ffcc5c;
}

#drawing-canvas {
    border: 2px solid #ffcc5c;
    border-radius: 5px;
    display: block;
    margin: 0;
    cursor: crosshair;
    background-color: white;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

.reference-image {
    border: 2px solid #ffcc5c !important;
    border-radius: 5px !important;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

/* SVG Container Styles */
#svg-container {
    background: white !important;
    border: 2px solid #ffcc5c;
    border-radius: 5px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.svg-wrapper, .image-puzzle-wrapper {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
}

.svg-wrapper svg {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    stroke: none !important;
    stroke-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
}

.svg-wrapper svg path,
.svg-wrapper svg circle,
.svg-wrapper svg rect,
.svg-wrapper svg polygon,
.svg-wrapper svg ellipse {
    stroke: none !important;
    stroke-width: 0 !important;
    border: none !important;
    outline: none !important;
}

.coloring-svg, .svg-fallback, #svg-object {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.coloring-svg, #svg-object {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
}

.svg-wrapper object {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.svg-image {
    display: none;
}

.colorable-path {
    cursor: pointer;
    transition: fill 0.2s ease;
}

.colorable-path:hover {
    opacity: 0.8;
}

.no-svg-message, .no-reference-message {
    width: 100%;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 5px;
    color: #888;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
}



/* =============================================
   TOOLS & CONTROLS
   ============================================= */
.drawing-tools, .painting-tools {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin: 20px 0;
}

.tool-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
}

.tool-group label {
    margin-bottom: 5px;
    font-weight: bold;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.action-buttons button, .tool-button {
    background-color: #88d8b0;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

.action-buttons button:hover, .tool-button:hover {
    background-color: #6b5b95;
}

.tool-button.active {
    background-color: #6b5b95;
}

.tool-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#reset-painting {
    background: #f44336;
    color: white;
}

#save-painting {
    background: #4CAF50;
    color: white;
}

/* =============================================
   COLOR MANAGEMENT
   ============================================= */
.color-picker {
    width: 50px;
    height: 50px;
    border: 2px solid #88d8b0;
    border-radius: 50%;
    cursor: pointer;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

.brush-size {
    width: 100px;
}

/* Color Mixer */
.color-mixer-container {
    margin-top: 15px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 5px;
    justify-content: center;
}

.color-mixer {
    margin-bottom: 10px;
}

.color-mixer-inputs {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 5px;
    flex-wrap: wrap;
}

.mixer-color {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.color-mixer-preview {
    width: 100%;
    height: 30px;
    border-radius: 5px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
}

#apply-mixed-color {
    background-color: #88d8b0;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
    width: 100%;
}

#apply-mixed-color:hover {
    background-color: #6b5b95;
}

/* Color Sliders */
.color-slider-group {
    width: 100%;
    margin-top: 15px;
}

.slider-container {
    margin-bottom: 10px;
}

.color-slider {
    width: 100%;
    height: 5px;
    border-radius: 5px;
    background: linear-gradient(to right, #000, var(--slider-color));
    outline: none;
    -webkit-appearance: none;
}

#red-slider, #painting-red-slider {
    --slider-color: #FF0000;
}

#green-slider, #painting-green-slider {
    --slider-color: #00FF00;
}

#blue-slider, #painting-blue-slider {
    --slider-color: #0000FF;
}

.color-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #88d8b0;
    cursor: pointer;
}

.color-slider::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #88d8b0;
    cursor: pointer;
}

.color-preview {
    width: 100%;
    height: 40px;
    border-radius: 5px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
}

.apply-button {
    display: block;
    width: 100%;
    padding: 8px;
    background-color: #88d8b0;
    color: white;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

.apply-button:hover {
    background-color: #6b5b95;
}

/* Preset Colors */
.preset-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    justify-content: center;
}

.color-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.preset-color {
    width: 30px;
    height: 30px;
    border: 2px solid #666;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

.preset-color:hover {
    transform: scale(1.1);
}

.color-label {
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    line-height: 1;
    text-align: center;
}

/* Color Dropdown */
.color-dropdown-container {
    position: relative;
    width: 100%;
}

.color-name-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.color-name-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    z-index: 1000;
    display: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.color-name-dropdown.show {
    display: block;
}

.color-option {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
}

.color-option:last-child {
    border-bottom: none;
}

.color-option:hover {
    background-color: #f5f5f5;
}

.color-preview-box {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    margin-right: 10px;
    border: 1px solid #ddd;
}

.color-name-text {
    flex-grow: 1;
}

/* Brush Cursor */
#brush-cursor {
    position: fixed;
    border: 2px solid #000;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1000;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.5);
}

/* =============================================
   CATEGORIES & NAVIGATION
   ============================================= */
.categories-container {
    margin-bottom: 30px;
}

.category-section {
    margin-bottom: 40px;
}

.category-section h2 {
    color: #6b5b95;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #88d8b0;
}

.subcategories {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.subcategory-link {
    background-color: #ffcc5c;
    color: #333;
    padding: 5px 15px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.3s;
}

.subcategory-link:hover {
    background-color: #ffb347;
}

/* Category Tabs */
.category-tabs {
    margin-bottom: 30px;
}

.category-list {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    padding: 0;
}

.category-item {
    margin: 0 10px 10px 0;
}

.category-item a {
    display: block;
    padding: 8px 15px;
    background-color: #88d8b0;
    color: #333;
    text-decoration: none;
    border-radius: 20px;
    transition: background-color 0.3s;
}

.category-item.active a {
    background-color: #6b5b95;
    color: white;
}

.category-item a:hover {
    background-color: #6b5b95;
    color: white;
}

/* =============================================
   ACTION BUTTONS & LINKS
   ============================================= */
.more-container {
    text-align: center;
    margin-top: 20px;
}

.more-button {
    background-color: #88d8b0;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

.more-button:hover {
    background-color: #6b5b95;
}

.more-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.all-drawings-link, .all-image-puzzles-link, .all-jigsaw-puzzles-link {
    text-align: center;
    margin: 30px 0;
}

.all-link {
    display: inline-block;
    background-color: #6b5b95;
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.3s;
}

.all-link:hover {
    background-color: #5a4d84;
}

/* =============================================
   CONTENT SECTIONS
   ============================================= */
.painting-info {
    margin-top: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 5px;
}

.painting-info h3 {
    color: #6b5b95;
    margin-bottom: 10px;
}

/* =============================================
   FOOTER
   ============================================= */
footer {
    background-color: #6b5b95;
    color: white;
    text-align: center;
    padding: 20px 0;
    margin-top: 30px;
}

/* =============================================
   JIGSAW IMAGE PUZZLE SPECIFIC STYLES
   ============================================= */

/* Jigsaw Container */
.jigsaw-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.image-puzzle-title {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #6b5b95, #88d8b0);
    border-radius: 15px;
    color: white;
}

.image-puzzle-title h1 {
    font-size: 2.5rem;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

/* Jigsaw Sections Layout */
.jigsaw-sections {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-bottom: 30px;
}

.jigsaw-top-section,
.jigsaw-bottom-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    border: 2px solid #e0e0e0;
}

.jigsaw-top-section h3,
.jigsaw-bottom-section h3 {
    color: #6b5b95;
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.5rem;
    border-bottom: 2px solid #88d8b0;
    padding-bottom: 10px;
}

/* Reference and Image Puzzle Containers */
.reference-container,
.image-puzzle-container {
    position: relative;
    border: 4px solid #88d8b0;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(45deg, #f8f9fa, #e9ecef);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
}
/* Jigsaw Pieces */
.jigsaw-piece {
    position: relative;
    background-size: 600% 600%;
    background-repeat: no-repeat;
    border: 1px solid rgba(0,0,0,0.15);
    cursor: grab;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    background-clip: content-box;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.5);
}

.jigsaw-piece:hover {
    transform: scale(1.08);
    z-index: 20;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    cursor: grabbing;
}

.jigsaw-piece.dragging {
    opacity: 0.9;
    z-index: 1000;
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}

.jigsaw-piece.correct {
    opacity: 1 !important;
    border-color: #4CAF50;
    box-shadow: 
        inset 0 0 0 2px #4CAF50,
        0 0 10px rgba(76, 175, 80, 0.5);
    animation: pieceCorrect 0.6s ease;
}

.jigsaw-piece.reference {
    cursor: default;
    opacity: 0.4;
    filter: brightness(0.8);
}

.jigsaw-piece.reference:hover {
    transform: none;
    box-shadow: none;
}

/* Reference Overlay */
.reference-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.25;
    pointer-events: none;
    background: rgba(0,0,0,0.02);
}

.reference-overlay img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(1px);
}

/* Jigsaw Controls */
.jigsaw-controls {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.jigsaw-controls .image-puzzle-info {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    padding: 25px;
    border-left: 4px solid #6b5b95;
}

.jigsaw-controls .image-puzzle-info h3 {
    color: #6b5b95;
    margin-bottom: 15px;
    border-bottom: 2px solid #88d8b0;
    padding-bottom: 8px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: row;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.tool-button {
    padding: 15px 25px;
    background: linear-gradient(135deg, #6b5b95, #88d8b0);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(107, 91, 149, 0.3);
    text-align: center;
    flex: 1;
    min-width: 150px;
}

.tool-button:hover {
    background: linear-gradient(135deg, #5a4d84, #77c4a0);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(107, 91, 149, 0.4);
}

.tool-button:active {
    transform: translateY(-1px);
}

/* Reference Panel */
.reference-panel {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    border: 2px solid #ffcc5c;
}

.reference-panel h3 {
    color: #6b5b95;
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.5rem;
    border-bottom: 2px solid #ffcc5c;
    padding-bottom: 10px;
}

.full-reference-container {
    border: 3px solid #ffcc5c;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 25px;
    background: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.full-reference-image {
    width: 100%;
    height: 350px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.full-reference-image:hover {
    transform: scale(1.02);
}

/* Modified CSS for mobile devices */

@media (max-width: 768px) {
    .jigsaw-image-puzzle-container {
        flex-direction: column;
    }
    
    .jigsaw-image-puzzle-top-section {
        height: 300px;
    }
    
    .reference-image-container {
        height: 300px;
    }
    
    /* Modified bottom section for mobile - adjust height to fit all pieces */
    .jigsaw-image-puzzle-bottom-section {
        height: auto;
        min-height: 150px;
        max-height: 250px;
    }
    
    /* Adjust piece sizes for mobile to fit all pieces */
    .jigsaw-image-puzzle-piece {
        max-width: 45px;
        max-height: 45px;
        min-width: 35px;
        min-height: 35px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .tool-button {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .jigsaw-image-puzzle-top-section {
        height: 240px;
    }
    
    .reference-image-container {
        height: 240px;
    }
    
    /* Further adjust bottom section for smaller mobile screens */
    .jigsaw-image-puzzle-bottom-section {
        min-height: 120px;
        max-height: 200px;
    }
    
    /* Further adjust piece sizes for smaller screens */
    .jigsaw-image-puzzle-piece {
        max-width: 35px;
        max-height: 35px;
        min-width: 25px;
        min-height: 25px;
    }
}

/* =============================================
   RESPONSIVE DESIGN
   ============================================= */
@media (max-width: 768px) {
    .drawing-container, .painting-container, .image-puzzle-container {
        flex-direction: column;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    nav ul li {
        margin: 5px 10px;
    }
    
    .svg-wrapper, #svg-container, .reference-image-container, 
    .canvas-container, .image-puzzle-wrapper {
        height: 350px;
    }
    
    .no-svg-message, .no-reference-message {
        height: 350px;
    }
    
    .drawing-panel, .painting-panel, .image-puzzle-panel {
        width: 100%;
    }
    
    .drawing-grid, .painting-grid, .image-puzzle-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .container {
        width: 95%;
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .svg-wrapper, #svg-container, .reference-image-container, 
    .canvas-container, .image-puzzle-wrapper {
        height: 300px;
    }
    
    .no-svg-message, .no-reference-message {
        height: 300px;
    }
    
    .action-buttons {
        gap: 10px;
    }
    
    .action-buttons button, .tool-button {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
}

@media (max-width: 320px) {
    .svg-wrapper, #svg-container, .reference-image-container, 
    .canvas-container, .image-puzzle-wrapper {
        height: 250px;
    }
    
    .no-svg-message, .no-reference-message {
        height: 250px;
    }
    
    .drawing-grid, .painting-grid, .image-puzzle-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}