/* ===============================================
   Coloring Page Specific Styles
   =============================================== */

/* Coloring Page Layout */
.coloring-page {
    background: linear-gradient(135deg, #FFF8E7 0%, #FFE5E5 50%, #E5F5FF 100%);
    background-attachment: fixed;
}

.coloring-container {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr minmax(180px, 240px);
    grid-template-rows: 1fr;
    gap: 1rem;
    padding: 1rem;
    height: calc(100vh - 100px);
    width: 100vw;
    max-width: 100%;
    margin: 0 auto;
    grid-template-areas:
        "color-panel canvas-panel advanced-panel";
}

/* Left Panel - Color Palette */
.color-panel {
    grid-area: color-panel;
    background: linear-gradient(135deg, #FFFFFF 0%, #FFF8E7 100%);
    border-radius: 20px;
    padding: 1rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    border: 4px solid var(--accent-yellow);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
}

/* Pencil Indicator */
.pencil-indicator {
    text-align: center;
    padding: 0.5rem;
    background-color: #f9f9f9;
    border-radius: 8px;
}

#pencil-icon {
    display: block;
    margin: 0 auto;
    width: 72px;
    height: 72px;
    border: 4px solid #000;
    border-radius: 6px;
    padding: 4px;
    background-color: #FFFFFF; /* Static white background */
}

#pencil-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

#pencil-icon svg path {
    fill: currentColor;
}

#pencil-icon svg #pencil-tip {
    fill: #F5DEB3 !important; /* Static cream color for tip */
}

.indicator-label {
    font-size: 0.85rem;
    color: #666;
    margin: 0;
}

/* Color Palette */
.color-palette h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #333;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
}

.color-btn {
    width: 100%;
    aspect-ratio: 1;
    min-width: 44px;
    min-height: 44px;
    border: 3px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.color-btn.active {
    border-color: #333;
    border-width: 4px;
    box-shadow: 0 0 0 2px white, 0 0 0 4px #333;
}

/* Center Panel - Canvas */
.canvas-panel {
    grid-area: canvas-panel;
    background-color: white;
    border-radius: 20px;
    padding: 0.0rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    border: 4px solid var(--accent-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.svg-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #CCCCCC;
    border-radius: 10px;
    padding: 0px;
    position: relative;
}

/* Flexible Ratio Container with White Background */
.svg-ratio-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 1125px; /* Increased by 25% from 900px (900 * 1.25 = 1125) */
    max-height: 1125px; /* Increased by 25% from 900px (900 * 1.25 = 1125) */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* White Colorable Background (behind SVG) */
.svg-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #FFFFFF;
    border-radius: 10px;
    z-index: 1;
}

/* SVG Content Layer */
.svg-content {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.svg-content svg {
    pointer-events: all;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Ensure SVG fits within container */
}

.svg-container svg path,
.svg-container svg ellipse,
.svg-container svg circle,
.svg-container svg rect {
    transition: opacity 0.1s ease;
}

.svg-container svg path:hover {
    opacity: 0.8;
}

/* Right Panel - Advanced Options (Gradients & Patterns) */
.advanced-panel {
    grid-area: advanced-panel;
    background: linear-gradient(135deg, #FFFFFF 0%, #FFF8E7 100%);
    border-radius: 20px;
    padding: 1rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    border: 4px solid var(--accent-green);
    overflow-x: visible;
    overflow-y: auto;
    white-space: normal;
}

.advanced-toggle {
    display: none;
    width: 100%;
    padding: 1rem;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 1rem;
}

.advanced-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.advanced-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.advanced-section h3 {
    font-size: 1.1rem;
    margin: 0;
    color: #333;
}

/* Gradient Palette Grid */
.gradient-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.gradient-btn {
    width: 100%;
    aspect-ratio: 1;
    min-width: 44px;
    min-height: 44px;
    border: 3px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.gradient-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.gradient-btn.active {
    border-color: #333;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    transform: scale(1.08);
}

/* Pattern Controls */
.pattern-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pattern-color-info {
    display: none;
}

.pattern-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.pattern-btn {
    background-color: #FFFFFF;
    border: 3px solid transparent;
    border-radius: 8px;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    min-width: 44px;
    min-height: 44px;
    position: relative;
}

.pattern-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.pattern-btn.active {
    border-color: #333;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    transform: scale(1.08);
}

.pattern-btn svg {
    width: 70%;
    height: 70%;
    color: currentColor;
}

.pattern-btn span {
    display: none;
}

.pattern-preview {
    display: none;
}

/* Dialog/Modal */
.dialog-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.dialog-overlay.active {
    display: flex;
}

.dialog-box {
    background-color: white;
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
}

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

.dialog-box h3 {
    margin-bottom: 1rem;
    color: #333;
}

.dialog-box p {
    margin-bottom: 1.5rem;
    color: #666;
}

.dialog-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.dialog-actions .btn {
    flex: 1;
}

/* Clear Button */
#clear-btn {
    margin-top: auto;
}

/* Action Buttons Section (Color It & Download PDF) */
.action-buttons-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px dashed #e0e0e0;
}

.action-buttons-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-action svg {
    flex-shrink: 0;
}

.btn-color-it {
    background: linear-gradient(135deg, #FF6B6B 0%, #FFE66D 50%, #4ECDC4 100%);
    color: #333;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.btn-color-it:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.btn-color-it:active {
    transform: translateY(0);
}

.btn-download-pdf {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-download-pdf:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-download-pdf:active {
    transform: translateY(0);
}
