/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --text-color: #1f2937;
    --light-bg: #f9fafb;
    --white: #ffffff;
    --gray: #6b7280;
    --border-color: #e5e7eb;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--white);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.site-header {
    background-color: var(--white);
    border-bottom: 2px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.logo a {
    text-decoration: none;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-image {
    height: 50px;
    width: auto;
    display: block;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.main-nav ul {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.main-nav a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.3s ease;
}

.main-nav a:hover {
    color: var(--primary-color);
}

/* Main Content */
main {
    min-height: calc(100vh - 200px);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--white);
    padding: 4rem 0;
    margin-bottom: 3rem;
}

.hero-content h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.hero-content h2 {
    font-size: 1.8rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.hero-content ul {
    list-style-position: inside;
    margin: 1rem 0;
}

.hero-content li {
    margin: 0.5rem 0;
    font-size: 1.1rem;
}

/* Robot Gallery */
.robot-gallery {
    padding: 3rem 0;
    background-color: var(--light-bg);
}

.robot-gallery h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.gallery-placeholder {
    text-align: center;
    padding: 3rem;
    color: var(--gray);
    font-style: italic;
    grid-column: 1 / -1;
}

.gallery-item {
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
}

.gallery-item-caption {
    padding: 1rem;
    font-size: 0.9rem;
    color: var(--gray);
    text-align: center;
}

/* Content Pages */
.content-page,
.list-page {
    padding: 3rem 0;
}

.content-page h1,
.list-page h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.content h2 {
    font-size: 1.8rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--secondary-color);
}

.content h3 {
    font-size: 1.4rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.content p {
    margin-bottom: 1rem;
    line-height: 1.8;
}

.content ul,
.content ol {
    margin: 1rem 0 1rem 2rem;
}

.content li {
    margin: 0.5rem 0;
}

.content hr {
    margin: 2rem 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

/* List Items */
.list-item {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.list-item:last-child {
    border-bottom: none;
}

.list-item h2 {
    margin-bottom: 0.5rem;
}

.list-item a {
    color: var(--primary-color);
    text-decoration: none;
}

.list-item a:hover {
    text-decoration: underline;
}

/* Footer */
.site-footer {
    background-color: var(--text-color);
    color: var(--white);
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
}

.footer-content p {
    margin: 0.5rem 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .main-nav ul {
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .hero-content h1 {
        font-size: 2rem;
    }

    .hero-content h2 {
        font-size: 1.5rem;
    }

    .content-page h1,
    .list-page h1 {
        font-size: 2rem;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
    }
}

/* Robot Designer Styles */
.designer-page {
    padding: 2rem 0;
}

.designer-page h1 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.designer-intro {
    margin-bottom: 2rem;
    color: var(--gray);
}

.designer-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Parts Palette */
.parts-palette {
    background: var(--light-bg);
    border-radius: 8px;
    padding: 1rem;
    max-height: 600px;
    overflow-y: auto;
}

.parts-palette h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.parts-category {
    margin-bottom: 1.5rem;
}

.parts-category h4 {
    font-size: 0.9rem;
    color: var(--gray);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.parts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.robot-part {
    background: var(--white);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem;
    cursor: grab;
    transition: all 0.2s ease;
    user-select: none;
}

.robot-part:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.robot-part.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.palette-part {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.part-emoji {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.25rem;
}

.part-name {
    font-size: 0.8rem;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.part-info {
    font-size: 0.65rem;
    color: var(--gray);
    display: block;
}

/* Design Area */
.design-area {
    display: flex;
    flex-direction: column;
}

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

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

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

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

.btn-secondary {
    background: var(--gray);
    color: var(--white);
}

.btn-secondary:hover {
    background: var(--text-color);
}

.canvas-wrapper {
    background: var(--white);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    overflow: auto;
}

.design-canvas {
    display: grid;
    position: relative;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    width: fit-content;
}

.grid-cell {
    width: 40px;
    height: 40px;
    border: 1px dashed var(--border-color);
    background: var(--white);
}

.grid-cell[data-occupied="true"] {
    background: rgba(37, 99, 235, 0.1);
}

.grid-cell.hover {
    background: rgba(34, 197, 94, 0.3);
    border-color: rgba(34, 197, 94, 0.6);
}

.grid-cell.hover[data-occupied="true"] {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.6);
}

.placed-part {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    cursor: grab;
    z-index: 10;
}

.placed-part .part-emoji {
    font-size: 1.2rem;
}

.placed-part .part-name,
.placed-part .part-info {
    display: none;
}

.delete-part {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.placed-part:hover .delete-part {
    opacity: 1;
}

/* Design Stats */
.design-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    padding: 1.5rem;
    background: var(--primary-color);
    color: var(--white);
    border-radius: 8px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    opacity: 0.9;
    margin-bottom: 0.25rem;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

/* Touch ghost element */
#touch-ghost {
    width: 60px;
    height: 60px;
    background: var(--white);
    border: 2px solid var(--primary-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#touch-ghost .part-name,
#touch-ghost .part-info {
    display: none;
}

/* Responsive Design for Designer */
@media (max-width: 768px) {
    .designer-container {
        grid-template-columns: 1fr;
    }

    .parts-palette {
        max-height: 300px;
    }

    .parts-list {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .palette-part {
        width: calc(50% - 0.25rem);
    }

    .design-stats {
        flex-direction: column;
        gap: 1rem;
    }

    .canvas-wrapper {
        overflow-x: auto;
    }

    .ai-result {
        padding: 1rem;
    }

    .ai-image-container {
        padding: 0.5rem;
        min-height: 150px;
    }

    .ai-image-container img {
        max-height: 400px;
    }

    .ai-prompt {
        font-size: 0.75rem;
        padding: 0.75rem;
        word-break: break-word;
    }
}

/* AI Generated Image Result */
.ai-result {
    margin-top: 2rem;
    padding: 2rem;
    background: var(--white);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
}

.ai-result h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
}

.ai-image-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
    background: var(--light-bg);
    padding: 1rem;
    border-radius: 8px;
    min-height: 200px;
    width: 100%;
}

.ai-image-container img {
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 600px;
    display: block;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.ai-prompt {
    font-size: 0.85rem;
    color: var(--gray);
    padding: 1rem;
    background: var(--light-bg);
    border-radius: 4px;
    margin-bottom: 1rem;
    font-style: italic;
}

#download-ai-image {
    display: block;
    margin: 0 auto;
}
