/* Modern Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Google Brand Colors */
    --primary: #4285F4; /* Google Blue */
    --primary-hover: #3367D6; /* Darker Blue */
    --primary-light: #E8F0FE; /* Light Blue */
    --secondary-brand: #EA4335; /* Google Red */
    
    --bg-body: #f8fafc; /* Slate 50 */
    --bg-surface: #ffffff;
    --bg-surface-secondary: #f1f5f9; /* Slate 100 */
    --bg-input: #ffffff;
    --bg-code: #f8fafc;
    
    --text-main: #0f172a; /* Slate 900 */
    --text-secondary: #64748b; /* Slate 500 */
    --text-on-primary: #ffffff;
    
    --border-color: #e2e8f0; /* Slate 200 */
    --border-focus: #4285F4; /* Match Primary */
    
    --success: #34A853; /* Google Green */
    --error: #EA4335; /* Google Red */
    --warning: #FBBC05; /* Google Yellow */

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Monaco', 'Consolas', monospace;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

[data-theme="dark"] {
    --primary: #669DF6; /* Lighter Google Blue */
    --primary-hover: #4285F4;
    --primary-light: #172554; /* Blue 950 */
    --secondary-brand: #EE675C; /* Lighter Google Red */
    
    --bg-body: #0f172a; /* Slate 900 */
    --bg-surface: #1e293b; /* Slate 800 */
    --bg-surface-secondary: #0b1221; /* Slate 950 */
    --bg-input: #0f172a; /* Slate 900 */
    --bg-code: #0b1221;
    
    --text-main: #f1f5f9; /* Slate 100 */
    --text-secondary: #94a3b8; /* Slate 400 */
    --text-on-primary: #ffffff;
    
    --border-color: #334155; /* Slate 700 */
    --border-focus: #669DF6;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 40px; /* Footer space */
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header Structure */
header {
    padding: 2rem 0;
    margin-bottom: 1rem;
    position: relative;
    text-align: center;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    position: relative;
    width: 100%;
    max-width: 100%;
    padding: 0;
}

.top-nav, .header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Navigation Menu */
.mobile-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    min-width: 220px;
    z-index: 100;
    margin-top: 0.5rem;
}

.mobile-menu.open {
    display: flex;
}

.mobile-menu a {
    padding: 0.75rem 1rem;
    color: var(--text-main);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    font-weight: 500;
}

.mobile-menu a:hover {
    background: var(--bg-surface-secondary);
    color: var(--primary);
}

/* Logo & Title */
.logo-link {
    display: inline-block;
    text-decoration: none;
    margin-bottom: 1rem;
}

.app-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
    transition: transform 0.2s ease;
}

.logo-link:not(.logo-link-disabled):hover .app-logo {
    transform: scale(1.05) rotate(-3deg);
}

.logo-link-disabled { cursor: default; }

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--primary) 0%, var(--success) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    line-height: 1.2;
    padding-bottom: 0.1em; /* Prevent descender clipping */
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Controls Bar */
.controls {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.direction-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-right: auto;
    font-weight: 600;
    color: var(--text-main);
    background: var(--bg-surface-secondary);
    padding: 0.375rem 0.75rem 0.375rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.format-label {
    font-size: 0.9rem;
    min-width: 40px;
    text-align: center;
}

.arrow-toggle {
    width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Buttons & Interactions */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid transparent;
    line-height: 1;
    min-height: 40px; /* Touch target */
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--success) 100%);
    color: var(--text-on-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--success) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(66, 133, 244, 0.3);
}

.btn-secondary {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-surface-secondary);
    border-color: var(--text-secondary);
    color: var(--text-main);
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    min-height: 32px;
}

.btn.is-hidden { display: none !important; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.25rem;
    padding: 0;
}

.icon-btn__glyph {
    width: 28px;
    height: 28px;
}


.icon-btn:hover {
    background: var(--bg-surface-secondary);
    color: var(--primary);
    border-color: var(--primary);
}

.layout-toggle {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.layout-icon {
    width: 20px;
    height: 20px;
}

/* Main Editor Area */
.content {
    display: flex;
    gap: 1.5rem;
    min-height: 600px;
}

.content.horizontal { flex-direction: row; }
.content.vertical { flex-direction: column; }

.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: box-shadow 0.3s ease, border-color 0.2s;
}

.panel:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.panel-header {
    padding: 0.875rem 1.25rem;
    background: var(--bg-surface-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.char-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.textarea {
    flex: 1;
    width: 100%;
    padding: 1.5rem;
    border: none;
    resize: none;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-main);
    background: var(--bg-input);
    outline: none;
}

.textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* Inputs & File Upload */
.file-upload {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.file-upload:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-surface);
}

.file-upload input { display: none; }
.input-upload { margin-left: auto; }

.language-selector {
    height: 40px;
    padding: 0 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-main);
    font-size: 1rem;
    cursor: pointer;
}

/* Feedback & States */
.error-message {
    color: var(--error);
    font-size: 0.875rem;
    padding: 0.75rem 1.25rem;
    background: rgba(234, 67, 53, 0.05); /* Using Google Red */
    border-top: 1px solid rgba(234, 67, 53, 0.1);
    display: none;
}
.error-message.show { display: block; }

.notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-main);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.notification.show {
    transform: translateY(0);
    opacity: 1;
}

.notification.success { border-left-color: var(--success); }
.notification.error { border-left-color: var(--error); }

/* History */
.history-section {
    margin-top: 3rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.history-header h2 { font-size: 1.25rem; font-weight: 600; }

.history-list { display: grid; gap: 1rem; }

.history-item {
    background: var(--bg-surface-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    transition: border-color 0.2s;
}

.history-item:hover { border-color: var(--primary); }

.history-meta {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.history-preview {
    background: var(--bg-input);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    margin: 0.75rem 0;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

.history-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Footer */
.site-footer {
    margin-top: auto;
    padding: 3rem 1rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.footer-copy {
    color: var(--text-secondary);
}

.footer-copy a {
    color: var(--text-main);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.2s;
}

.footer-copy a:hover {
    color: var(--primary);
}

/* Code Copy Button */
.code-block-wrapper { position: relative; }

.code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.code-block-wrapper:hover .code-copy-btn { opacity: 1; }

/* Blog & Articles - REINSTATED & IMPROVED */
.blog-hero {
    padding: 4rem 1rem;
    text-align: center;
    background: var(--bg-surface-secondary);
    border-bottom: 1px solid var(--border-color);
}

.blog-hero-content {
    max-width: 900px;
    margin: 0 auto;
    text-align: center;
}

.blog-hero-content p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 2rem;
}

.blog-hero-actions {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    padding: 3rem 0;
}

.blog-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.blog-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.blog-card h2 {
    font-size: 1.5rem;
    line-height: 1.3;
    color: var(--text-main);
}

.blog-card-meta {
    display: flex;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.blog-card-summary {
    color: var(--text-secondary);
    line-height: 1.6;
    flex-grow: 1;
}

.blog-card-quote {
    font-style: italic;
    color: var(--text-secondary);
    border-left: 3px solid var(--primary);
    padding-left: 1rem;
    margin: 0.5rem 0;
}

.blog-card-link {
    align-self: flex-start;
    margin-top: 1rem;
}

.blog-tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary-hover);
    font-weight: 600;
    white-space: nowrap;
    display: inline-block;
}

[data-theme="dark"] .blog-tag {
    background: rgba(102, 157, 246, 0.2); /* Match new Primary */
    color: var(--primary);
}

.blog-article-hero {
    padding: 3rem 1rem;
    background: var(--bg-surface-secondary);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

.blog-article-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 2rem 0;
}

.blog-article-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.blog-article-quote {
    font-size: 1.25rem;
    line-height: 1.6;
    color: var(--text-main);
    border-left: 4px solid var(--primary);
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
}

.blog-article-list {
    margin-left: 1.5rem;
    color: var(--text-secondary);
    line-height: 1.8;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.related-articles {
    padding: 3rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface-secondary);
}

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

.related-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.related-meta {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.blog-cta {
    padding: 3rem 2rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-top: 3rem;
    margin-bottom: 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
    align-items: center;
}

.blog-cta .cta-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

@media (min-width: 768px) {
    .blog-cta {
        flex-direction: row;
        text-align: left;
        justify-content: space-between;
    }
    
    .blog-cta .cta-actions {
        justify-content: flex-end;
    }
}

/* Examples Section */
.examples-section {
    background: var(--bg-surface-secondary) !important;
    border-top: 1px solid var(--border-color) !important;
    border-radius: var(--radius-lg);
    margin-top: 2rem;
}

.example-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.example-item {
    min-width: 0; /* Allow shrinking */
}

.example-item .code-block {
    overflow-x: auto;
}

@media (max-width: 768px) {
    .examples-section {
        padding: 20px !important;
    }
    
    .example-grid {
        display: flex;
        flex-direction: row;
        gap: 20px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        padding-bottom: 10px;
        margin-left: -20px;
        margin-right: -20px;
        padding-left: 20px;
        padding-right: 20px;
        margin-bottom: 20px;
    }
    
    .example-item {
        flex: 0 0 85vw;
        max-width: 85vw;
        min-width: 85vw;
        scroll-snap-align: start;
    }
    
    .example-item .code-block {
        min-width: 0;
        overflow-x: auto;
        white-space: pre;
    }
}

.code-block {
    background: var(--bg-code);
    padding: 1rem;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .content.horizontal { flex-direction: column; }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .direction-toggle {
        margin-right: 0;
        justify-content: center;
        margin-bottom: 1rem;
    }
    
    .header-top {
        margin-bottom: 1rem;
    }
    
    header h1 { font-size: 2rem; }
    
    .mobile-menu {
        width: 100%;
        left: 0;
        right: 0;
    }
    
    .panel { border-radius: var(--radius-md); }
}
