/* Fabric.js Coloring Editor Styles */

#coloring-image-editor {
    border-radius: 10px;
    overflow: hidden;
    background: white;
    position: relative;
    border: 1px solid #ececec;
    min-height: 980px;
}
#coloring-editor-image-source-buttons {
    min-height: 60px;
}

@media (max-width: 1200px) {
    #coloring-image-editor {
        min-height: 960px;
    }
}

@media (max-width: 991px) {
    #coloring-image-editor {
        min-height: 775px;
    }
}

@media (max-width: 768px) {
    #coloring-image-editor {
        min-height: 1087px;
    }
}

@media (max-width: 451px) {
    #coloring-image-editor {
        min-height: 849px;
    }
    #coloring-editor-image-source-buttons {
        min-height: 100px;
    }
}

.coloring-editor-loading {
    padding: 40px;
    text-align: center;
    border: 2px dashed #ddd;
    border-radius: 8px;
    background: #f9f9f9;
    color: #666;
}

.coloring-editor-loading h3 {
    margin-bottom: 15px;
    color: #333;
}

.coloring-editor-loading p {
    margin-bottom: 20px;
}

.coloring-editor-loading button {
    padding: 10px 20px;
    background: #007cba;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
    transition: background-color 0.2s;
}

.coloring-editor-loading button:hover {
    background: #005a87;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.coloring-toolbar {
    padding: 10px 0;
    background: #ffffff;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.coloring-toolbar .coloring-tool-group {
    border-bottom: 1px dotted #ececec;
    padding-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.coloring-toolbar .coloring-tool-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* Brush Size Control */
.brush-size-control {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

.brush-size-control input[type="range"] {
    -webkit-appearance: none;
    width: 120px;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    cursor: pointer;
}

.brush-size-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.3);
    transition: all 0.2s ease;
}

.brush-size-control input[type="range"]::-webkit-slider-thumb:hover {
    background: #0056b3;
    transform: scale(1.1);
}

.brush-size-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.3);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.action-buttons button {
    padding: 12px 18px;
    border: 2px solid;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-buttons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.action-buttons button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Canvas Container */
.canvas-container {
    position: relative;
    overflow: hidden;
    margin: 0 auto;
    border-left: 1px solid #ececec;
    border-right: 1px solid #ececec;
}

.canvas-container canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Tool Controls */
.coloring-brush-controls-bar {
    border-bottom: 1px solid #ececec;
}
.coloring-tool-group.brush-controls {
    padding-top: 0;
    justify-content: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
}
.tool-container, .shape-container, .text-container, .brush-controls {
    background: white;
    padding: 10px;
}

.coloring-tool-group .shapes-wrapper {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
 }

.tool-button {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    color: #333;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 70px;
}

.tool-button.active {
    border-color: #007bff;
    background: #007bff;
    color: white;
}

.tool-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.shape-button, .text-button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    color: #333;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.shape-button:hover, .text-button:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

/* Opacity Control */
.opacity-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.opacity-control input[type="range"] {
    -webkit-appearance: none;
    width: 100px;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    cursor: pointer;
}

.opacity-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #28a745;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
    transition: all 0.2s ease;
}

.opacity-control input[type="range"]::-webkit-slider-thumb:hover {
    background: #218838;
    transform: scale(1.1);
}

/* Text Input */
.text-input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    width: 120px;
    outline: none;
    transition: border-color 0.2s;
}

.text-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* File Upload Button */
.file-upload-button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    color: #333;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.file-upload-button:hover {
    background: #f8f9fa;
    transform: scale(1.05);
}

/* Responsive Design */
@media (max-width: 768px) {
    #coloring-image-editor .coloring-editor-wrapper {
        grid-template-columns: 1fr;
    }

    .coloring-toolbar {
        padding: 10px;
        gap: 8px;
        border-bottom: 1px solid #ececec;
    }

    .coloring-toolbar .coloring-tool-group {
        flex-direction: row;
        overflow-x: auto;
        padding: 0 10px 10px 10px;
    }

    .coloring-tool-group .shapes-wrapper {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        gap: 5px;
    }
    
    #coloring-image-editor .coloring-color-palette {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        overflow-x: auto;
        gap: 2px;
        padding: 5px 10px;
        justify-content: center;
        border: 0;
        border-bottom: 1px solid #ececec;
    }

    .coloring-color-palette .coloring-color-button {
        width: 20px;
        height: 20px;
    }

    #coloring-image-editor .coloring-color-picker-trigger {
        margin-top: 3px;
        width: 20px;
        height: 20px;
    }

    .coloring-toolbar .color-palette button {
        width: 30px;
        height: 30px;
        margin: 2px;
    }
    
    .brush-size-control, .opacity-control {
        width: 100%;
        justify-content: center;
        padding: 10px 15px;
    }
    
    .brush-size-control input[type="range"], 
    .opacity-control input[type="range"] {
        width: 100px;
    }
    
    .action-buttons {
        width: 100%;
        justify-content: center;
        gap: 8px;
    }
    
    .action-buttons button {
        padding: 10px 14px;
        font-size: 12px;
        flex: 1;
        min-width: 0;
    }
    
    .tool-button {
        min-width: 60px;
        font-size: 11px;
    }
    
    .text-input {
        width: 100px;
    }
}

@media (max-width: 480px) {
    .coloring-toolbar {
        padding: 8px;
    }
    
    .coloring-toolbar .color-palette button {
        width: 25px;
        height: 25px;
    }
    
    .action-buttons button {
        padding: 8px 10px;
        font-size: 11px;
    }
    
    .action-buttons button span {
        display: none; /* Hide text on very small screens, show only icons */
    }
}

/* Loading States */
.coloring-editor-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background: #f8f9fa;
    border-radius: 8px;
    flex-direction: column;
    gap: 20px;
}

.coloring-editor-loading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Custom Cursor */
.fabric-canvas-container {
    cursor: crosshair;
}

/* Toolbar Labels */
.toolbar-label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
    white-space: nowrap;
}

/* Color Preview */
.color-preview {
    width: 40px;
    height: 40px;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: inline-block;
    vertical-align: middle;
    margin-left: 10px;
}

/* Tooltips */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 8px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Success/Error Messages */
.message {
    padding: 12px 20px;
    border-radius: 8px;
    margin: 10px 0;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.message.success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.message.error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.message.info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .coloring-toolbar .color-palette button,
    .action-buttons button,
    .brush-size-control input[type="range"]::-webkit-slider-thumb {
        transition: none;
    }
    
    .spinner {
        animation: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .coloring-toolbar {
        border: 2px solid #000;
    }
    
    .coloring-toolbar .color-palette button {
        border: 2px solid #000;
    }
    
    .action-buttons button {
        border: 2px solid #000;
    }
}

/* Print styles */
@media print {
    .coloring-toolbar {
        display: none;
    }
    
    #tui-image-editor {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* Main Canvas Wrapper */
.coloring-editor-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
    background: #f9f2ff;
    text-align: center;
    display: grid;
    grid-template-columns: 100px 50px 1fr;
    justify-content: center;
    align-items: start;
}

/* Tool Groups */
.coloring-tool-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    background: white;
}

.coloring-tool-group.download-controls {
    padding: 15px 20px;
    flex-wrap: wrap;
}

/* Tool Group Labels */
.coloring-tool-label {
    color: #333;
    font-size: 13px;
    white-space: nowrap;
}

/* Tool Buttons */
.coloring-tool-button {
    height: 27px;
    padding: 3px 5px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    color: #333;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 78px;
}

.coloring-tool-button.active {
    border-color: #007bff;
    background: #007bff;
    color: white;
}

/* Brush Type Select */
.coloring-brush-select {
    width: 100%;
    height: 30px;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    color: #333;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    outline: none;
}

.coloring-brush-select:hover {
    border-color: #28a745;
}

.coloring-brush-select:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.25);
}

/* Shape Tool Buttons */
button.coloring-shape-button {
    padding: 0;
    border: 0;
    height: 30px;
    background: white;
    color: #333;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s;
    margin: 0 !important;
}

.coloring-shape-button:hover {
    background: #f0f0f0;
}

/* Text Input */
.coloring-text-input {
    margin: 0 5px !important;
    padding: 5px !important;
    height: 30px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 12px;
    width: 80px !important;
}

/* Text Add Button */
.coloring-text-button {
    margin: 0 !important;
    padding: 5px;
    height: 30px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.coloring-text-button:hover {
    background: #007bff;
    color: white;
}

/* Control Sliders Container */
.coloring-control-container {
    display: flex;
    align-items: center;
    gap: 5px;
}

.coloring-control-container.brush-size {
    padding-right: 10px;
    width: auto;
}

.coloring-control-container.download-size {
    gap: 15px;
    flex-wrap: wrap;
}

/* Sliders */
.coloring-slider {
    cursor: pointer;
}

input.coloring-slider.opacity,
input.coloring-slider.bucket-tolerance,
input.coloring-slider.brush-size {
    height: 30px;
    -webkit-appearance: auto;
    width: 80px;
}

.coloring-slider.brush-size {
    width: auto;
}

.coloring-slider.opacity {
    width: auto;
}

.coloring-slider.download-size {
    width: 120px;
}

/* Display Values */
.coloring-display {
    text-align: center;
    color: #333;
    font-weight: bold;
    font-size: 14px;
}

.coloring-display.brush-size {
    min-width: 35px;
}

.coloring-display.opacity {
    min-width: 35px;
}

.coloring-display.download-size {
    min-width: 40px;
}

.coloring-display.download-dimensions {
    color: #666;
    font-size: 12px;
    min-width: 100px;
}

/* Color Palette */
.coloring-color-palette {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-items: center;
    background-color: #ffffff;
    height: 100%;
    padding: 10px 0;
    gap: 3px;
    border-right: 1px solid #ececec;
    border-left: 1px solid #ececec;
}

/* Current color preview rectangle */
.coloring-current-color {
    width: 80%;
    height: 24px;
    border: 1px solid #ececec;
    border-radius: 6px;
    margin: 0;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
}
@media (max-width: 768px) {
    .coloring-current-color {
        width: auto;
        min-width: 30px;
        margin: 0 3px 0 0;
    }
}

/* Pipette button removed from palette */

.coloring-color-button {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0;
    border: 0;
}

.coloring-color-button.white {
    border: 2px solid #999999;
}

.coloring-color-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.coloring-color-button.active {
    border-color: #333;
}

/* Color picker wrapper */
.coloring-color-picker-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 5px;
}

/* Hidden color picker input positioned at trigger location */
input.coloring-color-picker {
    position: absolute;
    top: 0;
    left: 0;
    width: 30px;
    height: 30px;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

/* Rainbow circle color picker trigger */
.coloring-color-picker-trigger {
    width: 30px;
    height: 30px;
    display: flex;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    background: conic-gradient(
        from 0deg,
        #ff0000,
        #ff8000,
        #ffff00,
        #80ff00,
        #00ff00,
        #00ff80,
        #00ffff,
        #0080ff,
        #0000ff,
        #8000ff,
        #ff00ff,
        #ff0080,
        #ff0000
    );
    position: relative;
}

.coloring-color-picker-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.coloring-color-picker-trigger:active {
    transform: scale(0.95);
}

.coloring-color-picker-trigger::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 15px;
    height: 15px;
    background: white;
    border-radius: 50%;
    box-shadow: inset 0 0 3px rgba(0,0,0,0.2);
}

/* Action Buttons */
.coloring-action-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    padding: 10px;
    justify-content: center;
    min-height: 60px;
}

.coloring-action-button {
    padding: 5px;
    height: 30px;
    border: 1px solid #ececec;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    color: #333;
}

.coloring-action-button:hover {
    background: #f5faff;
}

.coloring-action-button.show-original {
    border: 1px solid red;
    background: #fff5f5;
}

select.coloring-download-size-select {
    width: auto;
    height: 30px;
}

/* Download Button */
.coloring-download-button {
    padding: 10px 20px;
    border: 1px solid #28a745;
    border-radius: 6px;
    background: white;
    color: #28a745;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 5px;
}

.coloring-download-button:hover {
    background: #28a745;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Print Styles */
@media print {
    .coloring-toolbar {
        display: none !important;
    }
    
    .coloring-editor-wrapper {
        border: none !important;
        box-shadow: none !important;
        background: white !important;
    }
}
.coloring-editor-image-source-buttons {
    margin-bottom: 10px;
}
.coloring-editor-image-source-buttons button.coloring-action-button {
    font-size: 16px;
    border: 1px solid #dfdfdf;
    background: #ffffff;
    color: #10377a;
    padding: 5px 10px;
    height: auto;
}
.coloring-editor-image-source-buttons button.coloring-action-button img {
    width: 25px;
    height: 25px;
}
.coloring-control-container .coloring-tool-checkbox-label {
    display: flex;
    align-items: center;
    gap:3px;
}
.coloring-checkbox.avoid-dark-fill {
    -webkit-appearance: checkbox;
    -moz-appearance: checkbox;
    appearance: checkbox;
    width: 15px;
    height: 15px;
    margin-right: 5px;
    border-radius: 2px;
    cursor: pointer;
    margin-top: 0;
}