/* ==========================================================================
   Modern Professional Design System
   ========================================================================== */

:root {
    /* Primary Color Palette - Based on #49a14d */
    --primary-50: #f0f9f0;
    --primary-100: #dcf2dd;
    --primary-200: #bbe5be;
    --primary-300: #8fd194;
    --primary-400: #6bb872;
    --primary-500: #49a14d;
    --primary-600: #3a8140;
    --primary-700: #2f6535;
    --primary-800: #28522d;
    --primary-900: #234427;
    
    /* Accent Colors - Complementary to #49a14d */
    --accent-green: #49a14d;
    --accent-green-hover: #3a8140;
    --accent-red: #6aa16e;
    --accent-red-hover: #5a8b5e;
    --accent-amber: #7db581;
    --accent-amber-hover: #6ba371;
    
    /* Neutral Colors - Harmonious with green */
    --neutral-50: #f8faf8;
    --neutral-100: #f1f5f1;
    --neutral-200: #e5ebe5;
    --neutral-300: #d1d9d1;
    --neutral-400: #9ca69c;
    --neutral-500: #6b756b;
    --neutral-600: #556055;
    --neutral-700: #454d45;
    --neutral-800: #2d332d;
    --neutral-900: #1a1e1a;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    
    /* Typography Scale - Professional Sizing */
    --text-xs: 0.75rem;     /* 12px - Small labels, meta text */
    --text-sm: 0.875rem;    /* 14px - Body text, descriptions */
    --text-base: 1rem;      /* 16px - Default body text */
    --text-lg: 1.125rem;    /* 18px - Large body text */
    --text-xl: 1.25rem;     /* 20px - Small headings */
    --text-2xl: 1.5rem;     /* 24px - Medium headings */
    --text-3xl: 1.875rem;   /* 30px - Large headings */
    --text-4xl: 2.25rem;    /* 36px - Extra large headings */
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 0.75rem;
    --space-lg: 1rem;
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
    --space-3xl: 3rem;
    --space-4xl: 4rem;
    
    /* Border radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Shadows */
    --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);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--neutral-50);
    color: var(--neutral-900);
    font-size: var(--text-base);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* ==========================================================================
   Layout Components
   ========================================================================== */

.app-container {
    min-height: 100vh;
    background: var(--neutral-50);
}

.app-header {
    background: transparent;
    color: var(--neutral-900);
}

.header-content {
    max-width: 1440px;
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-xl);
    text-align: center;
}

.app-title {
    font-size: clamp(var(--text-2xl), 4vw, var(--text-4xl));
    font-weight: 700;
    margin-bottom: var(--space-sm);
    letter-spacing: -0.02em;
}

.app-subtitle {
    font-size: var(--text-sm);
    color: var(--neutral-600);
    margin: 0;
    font-weight: 400;
}

.app-footer {
    background: transparent;
    border-top: 1px solid var(--neutral-200);
    margin-top: var(--space-2xl);
}

.footer-content {
    max-width: 1440px;
    margin: 0 auto;
    padding: var(--space-xl);
    text-align: center;
}

.footer-content p {
    font-size: var(--text-sm);
    color: var(--neutral-600);
    margin: 0;
}

.footer-link {
    color: var(--primary-600);
    text-decoration: none;
    font-weight: 500;
}

.footer-link:hover {
    color: var(--primary-700);
    text-decoration: underline;
}

.author-link {
    color: var(--primary-600);
    text-decoration: none;
    font-weight: 600;
    transition: border-color var(--transition-fast);
}

.author-link:hover {
    border-bottom-color: var(--accent-green);
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.nav-container {
    background: white;
    position: sticky;
    top: 0;
    z-index: 100;
    max-width: 1440px;
    margin: 0 auto;
}

.nav-tabs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0 var(--space-xl);
    min-height: 56px;
    background: var(--neutral-50);
    border: none;
    box-shadow: none;
}

.nav-tab {
    background: none;
    border: none;
    padding: var(--space-lg) var(--space-xl);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--neutral-600);
    border-bottom: 3px solid transparent;
    transition: all var(--transition-fast);
    position: relative;
    text-transform: capitalize;
    letter-spacing: 0.025em;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-tab:hover {
    color: var(--neutral-800);
    background: var(--neutral-50);
}

.nav-tab.active {
    color: var(--primary-600);
    border-bottom-color: var(--primary-600);
    font-weight: 600;
    background: var(--primary-50);
}

.nav-tab:focus-visible {
    outline: 2px solid var(--primary-600);
    outline-offset: -2px;
}

/* Navigation indicator for better visual feedback */
.nav-tab::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 3px;
    background: var(--primary-600);
    transition: width var(--transition-fast);
}

.nav-tab.active::after {
    width: 100%;
}

/* ==========================================================================
   Main Content
   ========================================================================== */

.main-content {
    max-width: 1440px;
    margin: 0 auto;
    background: white;
    min-height: calc(100vh - 200px);
    box-shadow: var(--shadow-sm);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}
/* ==========================================================================
   Workspace Layout
   ========================================================================== */

.workspace-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: calc(100vh - 200px);
    position: relative;
}

.control-panel {
    background: var(--neutral-50);
    border-right: 1px solid var(--neutral-200);
    overflow-y: auto;
    padding: var(--space-xl);
}

.editor-section {
    background: var(--neutral-50);
    overflow-y: auto;
}

.output-panel {
    position: fixed;
    top: 200px;
    right: 0;
    width: 400px;
    height: calc(100vh - 220px);
    background: var(--primary-50);
    border: 1px solid var(--primary-200);
    border-right: none;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.json-toggle-btn {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    background: var(--primary-800);
    color: white;
    border: none;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 1001;
    box-shadow: var(--shadow-md);
}

/* ==========================================================================
   Panel Sections
   ========================================================================== */

.panel-section {
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.panel-section:last-child {
    margin-bottom: 0;
}

.section-header {
    margin-bottom: var(--space-md);
}

.section-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--neutral-900);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-xs);
}

.section-description {
    font-size: var(--text-xs);
    color: var(--neutral-600);
    line-height: 1.5;
    font-weight: 400;
}

/* ==========================================================================
   Form Components
   ========================================================================== */

.form-section {
    background: white;
    border: 1px solid var(--primary-200);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-top: var(--space-xl);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    cursor: default;
}

.form-section:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-300);
}

.form-section:last-child {
    margin-bottom: 0;
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.form-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-900);
    margin-bottom: var(--space-xs);
    line-height: 1.3;
}

.form-control {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-family: var(--font-family);
    background: white;
    color: var(--neutral-900);
    line-height: 1.5;
    transition: border-color var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-500);
}

.form-control::placeholder {
    color: var(--neutral-400);
}

.form-control-code {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    line-height: 1.6;
}

textarea.form-control {
    resize: vertical;
    min-height: 60px;
}

select.form-control {
    cursor: pointer;
}

/* ==========================================================================
   Button Components
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    font-family: var(--font-family);
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.2;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: var(--space-md) var(--space-lg);
    margin-top: var(--space-sm);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    transition: all var(--transition-fast);
}

.btn:focus {
    outline: none;
}

/* Button Variants */
.btn-primary {
    background: var(--accent-green);
    color: white;
    border-color: var(--accent-green);
}

.btn-primary:hover {
    background: var(--accent-green-hover);
    border-color: var(--accent-green-hover);
}

.btn-success {
    background: var(--primary-600);
    color: white;
    border-color: var(--primary-600);
}

.btn-success:hover {
    background: var(--primary-700);
    border-color: var(--primary-700);
}

.btn-danger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.btn-danger:hover {
    background: #c82333;
    border-color: #bd2130;
}

.btn-danger:focus {
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.btn svg {
    flex-shrink: 0;
}

.clear-history-btn {
    margin-top: var(--space-md);
    align-self: flex-start;
}

.btn-secondary {
    background: var(--neutral-600);
    color: white;
    border-color: var(--neutral-600);
}

.btn-secondary:hover {
    background: var(--neutral-700);
    border-color: var(--neutral-700);
}

.btn-outline {
    background: white;
    color: var(--neutral-700);
    border-color: var(--neutral-300);
}

.btn-outline:hover {
    background: var(--neutral-50);
    border-color: var(--neutral-400);
}

/* Button Sizes */
.btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-xs);
}

.btn-block {
    width: 100%;
}

.action-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* ==========================================================================
   Output Panel
   ========================================================================== */

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    border-bottom: 1px solid var(--neutral-200);
    background: white;
}

.panel-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-900);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.panel-actions {
    display: flex;
    gap: var(--space-sm);
}

.json-output-container {
    flex: 1;
    padding: var(--space-md);
    overflow: hidden;
}

.json-output {
    background: var(--neutral-800);
    color: var(--neutral-100);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    line-height: 1.6;
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    height: 100%;
    overflow-y: auto;
}

/* JSON Syntax Highlighting */
.json-key { 
    color: #7e72f0; 
    font-weight: 600; 
}

.json-string { 
    color: #8fd194; 
}

.json-number { 
    color: #f39c12; 
}

.json-boolean { 
    color: #4a90e2; 
    font-weight: 500; 
}

.json-null { 
    color: #9ca69c; 
    font-style: italic; 
}

/* ==========================================================================
   Content Pages (Characters & History)
   ========================================================================== */

.content-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: var(--space-2xl) var(--space-xl);
    border-bottom: 1px solid var(--neutral-200);
    background: var(--neutral-50);
}

.header-text h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--neutral-900);
    margin-bottom: var(--space-xs);
}

.header-text p {
    font-size: 0.875rem;
    color: var(--neutral-600);
    line-height: 1.5;
}

.header-actions {
    display: flex;
    gap: var(--space-md);
}

.content-body {
    padding: var(--space-2xl) var(--space-xl);
}

/* ==========================================================================
   Grid Layouts
   ========================================================================== */

.characters-grid,
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--space-xl);
    min-height: 60vh;
    align-content: start;
}

/* Empty state positioning */
.characters-grid .empty-state,
.history-grid .empty-state {
    grid-column: 1 / -1;
    justify-self: center;
    align-self: start;
    margin-top: var(--space-4xl);
}

/* ==========================================================================
   Card Components
   ========================================================================== */

.character-card,
.history-card {
    background: white;
    border: 1px solid var(--primary-200);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    transition: all var(--transition-normal);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.character-card:hover,
.history-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--accent-green);
}

.character-name,
.content-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-900);
    margin-bottom: var(--space-sm);
    line-height: 1.3;
}

.character-description,
.content-description {
    font-size: 0.875rem;
    color: var(--primary-600);
    margin-bottom: var(--space-lg);
    line-height: 1.5;
}

.character-details {
    font-size: var(--text-sm);
    color: var(--primary-500);
    margin-bottom: var(--space-lg);
    padding: var(--space-md);
    background: var(--primary-50);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-green);
}

.character-actions,
.history-actions {
    display: flex;
    gap: var(--space-md);
}

.btn-load,
.btn-load-history {
    flex: 1;
    background: var(--primary-800);
    color: white;
    border-color: var(--primary-800);
}

.btn-load:hover,
.btn-load-history:hover {
    background: var(--primary-800);
    border-color: var(--primary-800);
}

.btn-delete,
.btn-delete-history {
    background: var(--accent-red);
    color: white;
    border-color: var(--accent-red);
}

.btn-delete:hover,
.btn-delete-history:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

/* History specific styles */
.history-timestamp {
    font-size: var(--text-xs);
    color: var(--primary-400);
    margin-bottom: var(--space-sm);
    font-weight: 500;
}

.history-preview {
    font-size: var(--text-sm);
    color: var(--primary-700);
    margin-bottom: var(--space-sm);
    line-height: 1.5;
    max-height: 80px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
}

.history-summary {
    font-size: var(--text-sm);
    color: var(--primary-500);
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    background: var(--primary-50);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-amber);
}

/* ==========================================================================
   Empty States
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--primary-500);
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
}

.empty-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--primary-700);
    margin-bottom: var(--space-sm);
}

.empty-description {
    font-size: var(--text-sm);
    color: var(--primary-500);
    margin-bottom: var(--space-lg);
    line-height: 1.5;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 1024px) {
    .workspace-layout {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        border-right: none;
        border-bottom: 1px solid var(--primary-200);
        padding: var(--space-md);
    }
    
    .output-panel {
        position: fixed;
        top: 200px;
        right: 0;
        width: 350px;
        height: calc(100vh - 220px);
        border: 1px solid var(--primary-200);
        border-right: none;
        box-shadow: var(--shadow-lg);
        z-index: 1000;
    }
    
    .json-toggle-btn {
        position: fixed;
        top: 50%;
        right: 15px;
        transform: translateY(-50%);
        background: var(--primary-800);
        color: white;
        border: none;
        padding: var(--space-sm) var(--space-md);
        border-radius: var(--radius-md);
        cursor: pointer;
        font-size: var(--text-xs);
        font-weight: 600;
        z-index: 1001;
        box-shadow: var(--shadow-md);
    }
}

@media (max-width: 768px) {
    .app-title {
        font-size: var(--text-xl);
    }
    
    .header-content {
        padding: var(--space-lg);
    }
    
    .nav-tabs {
        padding: 0 var(--space-lg);
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        justify-content: center;
    }
    
    .nav-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .nav-tab {
        padding: var(--space-md) var(--space-lg);
        flex-shrink: 0;
        min-height: 48px;
        font-size: var(--text-sm);
        white-space: nowrap;
    }
    
    .control-panel,
    .content-body {
        padding: var(--space-md);
    }
    
    .panel-section,
    .form-section {
        padding: var(--space-md);
    }
    
    .form-group-row {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }
    
    .characters-grid,
    .history-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
        min-height: 50vh;
    }
    
    .characters-grid .empty-state,
    .history-grid .empty-state {
        margin-top: var(--space-2xl);
        max-width: 90%;
    }
    
    .content-header {
        flex-direction: column;
        gap: var(--space-md);
        align-items: stretch;
        padding: var(--space-lg) var(--space-md);
    }
    
    .header-actions {
        width: 100%;
    }
    
    .output-panel {
        width: 300px;
        top: 160px;
        height: calc(100vh - 180px);
    }
    
    .json-toggle-btn {
        right: 10px;
        font-size: var(--text-xs);
        padding: var(--space-xs) var(--space-sm);
    }
}

@media (max-width: 480px) {
    .output-panel {
        width: calc(100vw - 20px);
        right: 10px;
        left: 10px;
        top: 160px;
        height: calc(100vh - 180px);
    }
    
    .json-toggle-btn {
        right: 20px;
        bottom: 20px;
        top: auto;
        transform: none;
        font-size: var(--text-xs);
        padding: var(--space-sm);
        border-radius: 50%;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ==========================================================================
   Scrollbar Styling
   ========================================================================== */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--primary-100);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-300);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-400);
}

/* ==========================================================================
   Focus Accessibility
   ========================================================================== */

.btn:focus-visible,
.form-control:focus-visible,
.nav-tab:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}
