/* Medieval Helmet Pixel Art Forge Styles */

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

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    color: #333;
    min-height: 100vh;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header Styles */
.header {
    text-align: center;
    background: linear-gradient(135deg, #1a237e, #3949ab);
    color: white;
    padding: 2rem;
    border-radius: 12px 12px 0 0;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M0 100h20L0 80z" fill="rgba(255,193,7,0.1)"/><path d="M80 100h20V0L80 100z" fill="rgba(255,193,7,0.1)"/></svg>');
    pointer-events: none;
}

.app-title {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

/* Main Layout */
.main-layout {
    display: grid;
    grid-template-columns: 300px 1fr 280px;
    gap: 1.5rem;
    background: white;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    min-height: 600px;
}

/* Left Panel */
.left-panel {
    padding: 1.5rem;
    border-right: 2px solid #f0f0f0;
    overflow-y: auto;
}

.helmet-selector h3,
.tools-panel h3 {
    font-family: 'Cinzel', serif;
    color: #1a237e;
    margin-bottom: 1rem;
    border-bottom: 2px solid #ffc107;
    padding-bottom: 0.5rem;
}

.helmet-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding-right: 0.5rem;
}

.helmet-card {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.helmet-card:hover {
    border-color: #ffc107;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255,193,7,0.3);
}

.helmet-card.selected {
    border-color: #1a237e;
    background: #e8eaf6;
}

.helmet-thumbnail {
    width: 48px;
    height: 48px;
    margin: 0 auto 0.5rem;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.helmet-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.helmet-placeholder svg {
    width: 48px;
    height: 48px;
    filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.2));
}

.helmet-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.helmet-info h4 {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: #1a237e;
}

.helmet-info p {
    font-size: 0.65rem;
    color: #666;
}

/* Tools Panel */
.tools-panel {
    margin-top: 2rem;
}

.tool-group,
.color-group {
    margin-bottom: 1.5rem;
}

.tool-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tool-btn {
    width: 40px;
    height: 40px;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 6px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tool-btn:hover {
    border-color: #ffc107;
}

.tool-btn.active {
    border-color: #1a237e;
    background: #e8eaf6;
}

.size-control {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.size-control label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #546e7a;
}

.size-control input[type="range"] {
    width: 100%;
    accent-color: #1a237e;
}

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

.color-swatch {
    width: 32px;
    height: 32px;
    border: 3px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.color-swatch:hover {
    transform: scale(1.1);
    border-color: #ffc107;
}

.color-swatch.active {
    border-color: #1a237e;
    transform: scale(1.1);
}

#color-picker {
    width: 100%;
    height: 40px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
}

/* Canvas Area */
.canvas-area {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.canvas-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.canvas-container {
    position: relative;
    display: inline-block;
    border: 3px solid #1a237e;
    border-radius: 8px;
    background: white;
    margin-bottom: 1rem;
    transform-origin: center;
    transition: transform 0.3s ease;
}

#pixel-canvas,
#grid-canvas,
#template-canvas {
    display: block;
    border-radius: 4px;
}

.canvas-actions {
    display: flex;
    gap: 1rem;
}

/* Right Panel */
.right-panel {
    padding: 1.5rem;
    border-left: 2px solid #f0f0f0;
    overflow-y: auto;
}

.style-presets h3,
.my-collection h3,
.helmet-info h3 {
    font-family: 'Cinzel', serif;
    color: #1a237e;
    margin-bottom: 1rem;
    border-bottom: 2px solid #ffc107;
    padding-bottom: 0.5rem;
}

.preset-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.preset-btn {
    padding: 0.75rem 1rem;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.preset-btn:hover {
    border-color: #ffc107;
}

.preset-btn.active {
    border-color: #1a237e;
    background: #e8eaf6;
    color: #1a237e;
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.collection-slot {
    aspect-ratio: 1;
    border: 2px dashed #ccc;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    font-size: 0.75rem;
    color: #999;
    overflow: hidden;
}

.collection-slot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.helmet-info {
    margin-top: 2rem;
}

#helmet-details {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.875rem;
    line-height: 1.5;
}

#helmet-details h4 {
    font-family: 'Cinzel', serif;
    color: #1a237e;
    margin-bottom: 0.5rem;
}

#helmet-details p {
    margin-bottom: 0.5rem;
}

#helmet-details strong {
    color: #1a237e;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: #1a237e;
    color: white;
}

.btn-primary:hover {
    background: #303f9f;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #546e7a;
    color: white;
}

.btn-secondary:hover {
    background: #607d8b;
    transform: translateY(-1px);
}

.btn-danger {
    background: #d32f2f;
    color: white;
}

.btn-danger:hover {
    background: #f44336;
    transform: translateY(-1px);
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn.active {
    background: #ffc107;
    color: #1a237e;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    font-size: 4rem;
    animation: spin 2s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 250px 1fr 250px;
    }
    
    .app-title {
        font-size: 2rem;
    }
}

@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    
    .left-panel,
    .right-panel {
        border: none;
        border-bottom: 2px solid #f0f0f0;
    }
    
    .helmet-grid {
        grid-template-columns: repeat(4, 1fr);
        max-height: 200px;
    }
    
    .canvas-area {
        order: -1;
    }
}

@media (max-width: 640px) {
    .app-container {
        padding: 0.5rem;
    }
    
    .main-layout {
        gap: 1rem;
    }
    
    .left-panel,
    .right-panel,
    .canvas-area {
        padding: 1rem;
    }
    
    .app-title {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .helmet-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .canvas-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Scrollbar Styling */
.helmet-grid::-webkit-scrollbar,
.left-panel::-webkit-scrollbar,
.right-panel::-webkit-scrollbar {
    width: 6px;
}

.helmet-grid::-webkit-scrollbar-track,
.left-panel::-webkit-scrollbar-track,
.right-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.helmet-grid::-webkit-scrollbar-thumb,
.left-panel::-webkit-scrollbar-thumb,
.right-panel::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.helmet-grid::-webkit-scrollbar-thumb:hover,
.left-panel::-webkit-scrollbar-thumb:hover,
.right-panel::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}