/* ============================================================
   Hoichi — Design System
   Modern dark theme with glassmorphism accents
   ============================================================ */

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(17, 24, 39, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-input: rgba(255, 255, 255, 0.05);
    --bg-input-focus: rgba(255, 255, 255, 0.08);

    --text-primary: #f0f4f8;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #818cf8;

    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --accent-hover: #7c3aed;

    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.1);
    --error: #f87171;
    --error-bg: rgba(248, 113, 113, 0.1);
    --warning: #fbbf24;

    --border: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.5);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px var(--accent-glow);
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* --- Background pattern --- */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.12), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(124, 58, 237, 0.08), transparent);
    pointer-events: none;
    z-index: 0;
}

.app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.header {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    background: rgba(10, 14, 26, 0.6);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-xl);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo h1 {
    font-size: 1.6rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.tagline {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 400;
}

/* --- Navigation --- */
.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-input-focus);
}

.nav-link.active {
    color: var(--text-accent);
    background: rgba(99, 102, 241, 0.1);
}

/* --- Main Layout --- */
.main {
    flex: 1;
    padding: var(--space-xl);
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
    align-items: start;
}

@media (max-width: 1024px) {
    .panels {
        grid-template-columns: 1fr;
    }
}

/* --- Panel --- */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-md);
    transition: box-shadow var(--transition-base);
}

.panel:hover {
    box-shadow: var(--shadow-lg);
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
}

.panel-icon {
    font-size: 1.2rem;
}

/* --- Form --- */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.label-hint {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
}

.form-textarea {
    width: 100%;
    padding: var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
    transition: all var(--transition-fast);
    outline: none;
}

.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea:focus {
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* --- Drop Zone --- */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--bg-glass);
    position: relative;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.drop-zone.has-file {
    border-color: var(--success);
    border-style: solid;
    background: var(--success-bg);
}

.drop-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-sm);
    opacity: 0.7;
}

.drop-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.drop-subtext {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.drop-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--space-sm);
}

.browse-btn {
    background: none;
    border: none;
    color: var(--accent-light);
    cursor: pointer;
    text-decoration: underline;
    font-size: inherit;
    font-family: inherit;
}

.browse-btn:hover {
    color: var(--accent);
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.file-name {
    font-weight: 500;
    color: var(--success);
}

.file-size {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.file-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.file-remove:hover {
    color: var(--error);
    background: var(--error-bg);
}

/* --- Analyze Button --- */
.analyze-btn {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm), 0 0 20px var(--accent-glow);
    position: relative;
    overflow: hidden;
}

.analyze-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.1) 50%, transparent 100%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.analyze-btn:hover:not(:disabled)::before {
    transform: translateX(100%);
}

.analyze-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.analyze-btn:active:not(:disabled) {
    transform: translateY(0);
}

.analyze-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.analyze-btn.loading {
    pointer-events: none;
}

.analyze-btn.loading .btn-icon,
.analyze-btn.loading .btn-text {
    display: none;
}

.analyze-btn.loading .btn-loading {
    display: flex !important;
    align-items: center;
    gap: var(--space-sm);
}

/* --- Spinner --- */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Output Panel --- */
.output-placeholder {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-muted);
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.4;
}

.output-placeholder p {
    font-size: 0.9rem;
}

/* --- Tabs --- */
.tabs {
    display: flex;
    gap: 2px;
    margin-bottom: var(--space-md);
    background: var(--bg-glass);
    border-radius: var(--radius-md);
    padding: 3px;
}

.tab {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab:hover {
    color: var(--text-secondary);
}

.tab.active {
    background: var(--bg-input-focus);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Result Actions --- */
.result-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: var(--space-sm);
}

.copy-btn {
    padding: var(--space-xs) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.copy-btn:hover {
    background: var(--bg-input-focus);
    color: var(--text-primary);
    border-color: var(--border-focus);
}

.copy-btn.copied {
    color: var(--success);
    border-color: var(--success);
}

/* --- JSON Output --- */
.json-output,
.raw-output {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 600px;
    overflow-y: auto;
    color: var(--text-primary);
}

/* JSON syntax highlighting */
.json-key {
    color: #818cf8;
}

.json-string {
    color: #34d399;
}

.json-number {
    color: #fbbf24;
}

.json-boolean {
    color: #f472b6;
}

.json-null {
    color: #94a3b8;
}

/* --- Excel Summary --- */
.summary-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.summary-card:last-child {
    margin-bottom: 0;
}

.summary-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.summary-detail {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.summary-detail span {
    color: var(--text-muted);
    margin-right: var(--space-xs);
}

.summary-headers {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-sm);
}

.header-tag {
    padding: 2px 8px;
    background: var(--accent-glow);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--accent-light);
}

/* --- Error --- */
.output-error {
    text-align: center;
    padding: var(--space-xl);
    background: var(--error-bg);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: var(--radius-md);
}

.error-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-sm);
}

.error-message {
    color: var(--error);
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}