/* 
 * Draw a Puzzle Tool - CSS Styles
 * Styles for the One Stroke Puzzle Creator interface
 */

/* Global styles and variables */
:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --primary-light: #BBDEFB;
    --secondary-color: #4CAF50;
    --secondary-dark: #388E3C;
    --warning-color: #F44336;
    --text-color: #333;
    --light-text: #666;
    --border-color: #ddd;
    --background-light: #f5f5f5;
    --background-white: #ffffff;
    --shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    --border-radius: 4px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-light);
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: var(--background-white);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Header styles */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 20px;
    text-align: center;
}

header h1 {
    margin-bottom: 5px;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

/* Main content layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 300px;
    min-height: 700px;
}

.drawing-container {
    display: flex;
    flex-direction: column;
    padding: 20px;
    background-color: var(--background-white);
}

/* Toolbar styles */
.toolbar-below {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    background-color: var(--background-light);
    border: 1px solid var(--border-color);
    border-top: none;
    padding: 15px;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    margin-bottom: 15px;
}

.tool-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.tool-section.horizontal {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.tool-section h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--primary-dark);
}

.tool-btn {
    padding: 8px 12px;
    background-color: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 100px;
    white-space: nowrap;
}

.tool-btn:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
}

.tool-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-dark);
}

.tool-btn.warning {
    color: var(--warning-color);
}

.tool-btn.warning:hover {
    background-color: #FFEBEE;
    border-color: var(--warning-color);
}

.icon {
    display: inline-block;
    width: 20px;
    text-align: center;
    margin-right: 5px;
}

.shape-select {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    flex: 2;
    min-width: 150px;
}

.import-section {
    background-color: var(--background-light);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 15px;
    max-height: 800px;
    overflow-y: auto;
}

.import-section h3 {
    margin-top: 15px;
    margin-bottom: 10px;
    color: var(--primary-dark);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.import-section h3:first-child {
    margin-top: 0;
}

.import-textarea {
    width: 100%;
    height: 80px;
    padding: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: monospace;
    font-size: 0.9rem;
    resize: vertical;
}

/* Drawing area styles */
.drawing-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--background-white);
    margin-bottom: 15px;
}

#puzzle-canvas {
    border: 1px solid var(--border-color);
    background-color: white;
    box-shadow: var(--shadow);
    cursor: crosshair;
}

.canvas-info {
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 10px;
    font-size: 0.9rem;
    color: var(--light-text);
}

/* Info panel styles */
.info-panel {
    background-color: var(--background-light);
    border-left: 1px solid var(--border-color);
    padding: 15px;
    overflow-y: auto;
}

.panel-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.panel-section h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--primary-dark);
}

.action-btn {
    padding: 8px 12px;
    margin-bottom: 10px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.action-btn:hover {
    background-color: var(--primary-dark);
}

.action-btn.primary {
    background-color: var(--secondary-color);
}

.action-btn.primary:hover {
    background-color: var(--secondary-dark);
}

.action-btn.small {
    padding: 5px 10px;
    font-size: 0.9rem;
}

.result-box {
    background-color: var(--background-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 10px;
    margin-top: 10px;
    min-height: 80px;
}

.result-box p {
    color: var(--light-text);
    font-size: 0.9rem;
}

.export-controls {
    margin-bottom: 10px;
}

.export-controls label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.export-controls input,
.export-controls select {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.json-output {
    width: 100%;
    height: 120px;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: monospace;
    font-size: 0.9rem;
    resize: vertical;
}

.collection-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.collection-controls .action-btn {
    flex: 1;
}

.puzzle-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
    min-height: 100px;
    max-height: 200px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 10px;
    background-color: var(--background-white);
    overflow-y: auto;
}

.puzzle-thumbnail {
    position: relative;
    width: 80px;
    height: 80px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
}

.puzzle-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border-color: var(--primary-color);
}

.puzzle-thumbnail canvas {
    width: 100%;
    height: 100%;
}

.puzzle-thumbnail .thumbnail-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.7rem;
    padding: 2px 4px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.puzzle-thumbnail .remove-thumbnail {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background-color: rgba(255, 255, 255, 0.8);
    color: var(--warning-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.puzzle-thumbnail:hover .remove-thumbnail {
    opacity: 1;
}

.empty-collection-message {
    width: 100%;
    text-align: center;
    color: var(--light-text);
    font-style: italic;
    padding: 20px 0;
}

.collection-json {
    width: 100%;
    height: 120px;
    padding: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: monospace;
    font-size: 0.9rem;
    resize: vertical;
    background-color: var(--background-white);
}

.export-actions {
    display: flex;
    gap: 10px;
}

.export-actions .action-btn {
    flex: 1;
}

/* Footer styles */
footer {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 10px;
    font-size: 0.9rem;
}

footer a {
    color: white;
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 1000px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .info-panel {
        grid-column: 1;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
    
    .tool-section.horizontal {
        flex: 100%;
        margin-bottom: 15px;
    }
}

@media (max-width: 768px) {
    .drawing-area canvas {
        max-width: 100%;
        height: auto;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .tool-btn {
        width: 100%;
    }
}

/* Status indicators */
.valid {
    color: var(--secondary-color);
    font-weight: bold;
}

.invalid {
    color: var(--warning-color);
    font-weight: bold;
}

/* Notification styles */
.notification-area {
    width: 100%;
    min-height: 40px;
    margin-bottom: 15px;
    padding: 0;
    transition: all 0.3s ease;
}

.notification {
    padding: 10px 15px;
    margin-bottom: 10px;
    border-radius: var(--border-radius);
    animation: fadeIn 0.3s ease-in-out;
    position: relative;
}

.notification.success {
    background-color: #e8f5e9;
    border-left: 4px solid var(--secondary-color);
    color: #2e7d32;
}

.notification.error {
    background-color: #ffebee;
    border-left: 4px solid var(--warning-color);
    color: #c62828;
}

.notification.info {
    background-color: #e3f2fd;
    border-left: 4px solid var(--primary-color);
    color: #1565c0;
}

.notification.warning {
    background-color: #fff8e1;
    border-left: 4px solid #ffc107;
    color: #ff8f00;
}

.notification-close {
    position: absolute;
    right: 10px;
    top: 10px;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.7;
}

.notification-close:hover {
    opacity: 1;
}

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

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

/* Canvas node and edge styles will be handled in JavaScript */

/* Image Tracing Styles */
.slider-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    width: 100%;
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slider-group label {
    min-width: 70px;
}

.slider-group input[type="range"] {
    flex: 1;
}

.slider-group span {
    min-width: 50px;
    text-align: right;
}

.tracing-instructions {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--light-text);
}

.tracing-instructions kbd {
    background-color: #f7f7f7;
    border: 1px solid #ccc;
    border-radius: 3px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.2);
    color: #333;
    display: inline-block;
    font-family: monospace;
    font-size: 0.85em;
    padding: 2px 4px;
}
