/* ========================================
   Open GOAT - Optimized Design System
   Style: Vibrant & Block-based
   Supports Light/Dark Theme
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

/* ========================================
   CSS Variables & Design Tokens - Dark Theme (Default)
   ======================================== */
:root {
    /* Primary Colors - Dark */
    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --bg-card: #1E293B;
    --bg-card-hover: #334155;

    /* Text Colors - Dark */
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;

    /* Accent Colors */
    --accent-primary: #22C55E;
    --accent-primary-dark: #16A34A;
    --accent-primary-light: #4ADE80;

    /* Border Colors - Dark */
    --border-color: #334155;
    --border-color-hover: #475569;

    /* Shadow Colors */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);
}

/* ========================================
   Light Theme Variables
   ======================================== */
[data-theme="light"] {
    /* Primary Colors - Light */
    --bg-primary: linear-gradient(135deg, #E8F4F8 0%, #D1E8FF 100%);
    --bg-secondary: #FFFFFF;
    --bg-card: #F8FAFC;
    --bg-card-hover: #F1F5F9;

    /* Text Colors - Light */
    --text-primary: #0F172A;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;

    /* Border Colors - Light */
    --border-color: #E2E8F0;
    --border-color-hover: #CBD5E1;

    /* Shadow Colors - Light */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.12);
}

/* ========================================
   Spacing & Layout Tokens
   ======================================== */
:root {
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms ease;
}

/* ========================================
   Reset & Base Styles
   ======================================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Space Mono', 'Courier New', monospace;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    padding: var(--spacing-md);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background var(--transition-normal), color var(--transition-normal);
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   Container
   ======================================== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--spacing-2xl);
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    animation: containerFadeIn 0.4s ease-out;
    transition: background var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

@keyframes containerFadeIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ========================================
   Header Section
   ======================================== */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-2xl);
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0;
    text-shadow: 0 0 30px rgba(34, 197, 94, 0.3);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: color var(--transition-normal);
}

h1 .crown-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 8px rgba(34, 197, 94, 0.5));
}

/* ========================================
   Theme Toggle Button
   ======================================== */
.icon-btn {
    padding: var(--spacing-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.icon-btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.theme-icon {
    width: 24px;
    height: 24px;
}

/* ========================================
   Language Switcher
   ======================================== */
.language-switch {
    display: flex;
    gap: var(--spacing-sm);
    background: var(--bg-card);
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: background var(--transition-normal), border-color var(--transition-normal);
}

.lang-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 2px solid transparent;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: center;
    line-height: 1;
}

.lang-btn.active {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(34, 197, 94, 0.1);
}

.lang-btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* ========================================
   Form Groups
   ======================================== */
.form-group {
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-xl);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

h2 {
    color: var(--text-primary);
    margin: 0 0 var(--spacing-lg);
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: color var(--transition-normal);
}

h2::before {
    content: '';
    display: block;
    width: 4px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 2px;
}

/* ========================================
   Card Grid
   ======================================== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--spacing-md);
}

/* ========================================
   Card Styles
   ======================================== */
.card {
    position: relative;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    overflow: hidden;
}

.card:has(input:checked) {
    border-color: var(--accent-primary);
    background: rgba(34, 197, 94, 0.05);
}

/* Hide default checkbox/radio - use visually-hidden approach */
.card input[type="checkbox"],
.card input[type="radio"],
.tool-option input[type="radio"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Make sure labels and tool-options are clickable */
.card label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0;
    padding: var(--spacing-lg) var(--spacing-md);
    height: 100%;
}

.tool-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
}

.card:has(input:checked) label {
    font-weight: 600;
    color: var(--accent-primary);
}

/* ========================================
   Tool Icons (SVG)
   ======================================== */
.tool-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.card:has(input:checked) .tool-icon {
    color: var(--accent-primary);
}

/* ========================================
   AI Tool Options
   ======================================== */
.tool-options {
    display: flex;
    gap: var(--spacing-md);
}

.tool-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg) var(--spacing-md);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
}

.tool-option:has(input:checked) {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.tool-option input[type="radio"] {
    cursor: pointer;
}

.tool-option img.tool-logo {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    object-fit: contain;
}

/* Trae Logo special sizing */
.tool-option img[src*="trae.png"] {
    width: 60px;
    height: 20px;
}

.tool-option img[src*="trae.svg"] {
    /* Trae SVG color: #FF6B35 - SVG has this color built-in */
}

.tool-option img.tool-logo {
    /* SVG colors are preserved, this is just positioning */
}

/* Specific tool logo colors */
.tool-option:has(input[value="Claude Code"]:checked) img.tool-logo,
.tool-option:has(input[value="Claude Code"]:not(:checked)):hover img.tool-logo {
    filter: brightness(1.1);
}

.tool-option:has(input[value="Trae"]:checked) img.tool-logo,
.tool-option:has(input[value="Trae"]:not(:checked)):hover img.tool-logo {
    filter: brightness(1.1);
}

.tool-option:has(input[value="Google Gemini"]:checked) img.tool-logo,
.tool-option:has(input[value="Google Gemini"]:not(:checked)):hover img.tool-logo {
    filter: brightness(1.1);
}

/* SVG fill colors - using SVG's built-in colors */
.tool-option img[src*="claude.svg"] {
    /* Claude color: #D97757 - SVG has this color built-in */
}

.tool-option img[src*="trae.svg"] {
    /* Trae color: #FF6B35 - SVG has this color built-in */
}

.tool-option img[src*="googlegemini.svg"] {
    /* Google Gemini color: #8E75B2 - SVG has this color built-in */
}

.tool-option img[src*="cursor.svg"] {
    /* Cursor color: #0077B6 - SVG has this color built-in */
}

/* ========================================
   Button Section
   ======================================== */
.button-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: var(--spacing-lg) 0 var(--spacing-md) 0;
    font-weight: 500;
}

.button-row {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

button {
    flex: 1;
    padding: var(--spacing-md) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    outline: none;
}

button:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

button:active {
    transform: scale(0.98);
}

/* Primary Button */
#generateBtn {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-primary-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

/* Secondary Button */
#previewBtn,
#copyBtn {
    background: transparent;
    border: 2px solid var(--accent-primary);
    color: var(--accent-primary);
}

#previewBtn:hover,
#copyBtn:hover {
    background: rgba(34, 197, 94, 0.1);
}

/* ========================================
   Preview Area
   ======================================== */
.md-content {
    margin: var(--spacing-xl) 0;
    padding: var(--spacing-lg);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    max-height: 400px;
    overflow-y: auto;
    transition: all var(--transition-normal);
}

.md-content:hover {
    border-color: var(--border-color-hover);
}

.md-content::-webkit-scrollbar {
    width: 8px;
}

.md-content::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.md-content::-webkit-scrollbar-thumb {
    background: var(--border-color-hover);
    border-radius: var(--radius-sm);
}

.md-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

#mdDisplay {
    font-family: 'Space Mono', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.7;
    white-space: pre-wrap;
    margin: 0;
    color: var(--text-secondary);
}

/* ========================================
   Utility Classes
   ======================================== */
.hidden {
    display: none !important;
}

#downloadLink {
    display: none !important;
    position: absolute;
    left: -9999px;
    top: -9999px;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    body {
        padding: var(--spacing-sm);
    }

    .container {
        margin: 0;
        padding: var(--spacing-lg);
        border-radius: var(--radius-lg);
    }

    h1 {
        font-size: 1.5rem;
    }

    .header-row {
        flex-direction: column;
        align-items: stretch;
    }

    .header-controls {
        justify-content: center;
    }

    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .button-row {
        flex-direction: column;
    }

    button {
        width: 100%;
    }

    .md-content {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .card-grid {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 1.25rem;
        justify-content: center;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    body {
        background: #fff;
        color: #000;
    }

    .container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
