* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0a0a0a;
    --surface: #111111;
    --surface-hover: #1a1a1a;
    --border: #252525;
    --border-light: #333333;
    --text: #e4e4e4;
    --text-muted: #8a8a8a;
    --text-dim: #6a6a6a;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --critical: #ef4444;
    --panel-bg: #0f0f0f;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
    background: var(--panel-bg);
    position: relative;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.github-link {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.75rem;
    transition: color 0.2s;
}

.github-link:hover {
    color: var(--text-muted);
}

.github-link svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.app-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;
    height: calc(100vh - 100px);
}

.input-panel, .output-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.input-panel {
    border-right: 1px solid var(--border);
}

.panel-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--panel-bg);
}

.panel-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.panel-content {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

textarea {
    flex: 1;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    color: var(--text);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.875rem;
    resize: none;
    transition: border-color 0.15s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
}

#convertBtn {
    margin-top: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

#convertBtn:hover:not(:disabled) {
    background: var(--primary-hover);
}

#convertBtn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loader {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#loadingText {
    font-size: 0.875rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    padding: 2rem;
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.875rem;
}

.results {
    padding: 2rem;
    overflow-y: auto;
    height: calc(100vh - 180px);
}

.result-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

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

.section-header h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
}

.badge {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.section-content {
    padding: 1.5rem;
}

.section-description {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
}

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

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

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

.action-btn.secondary:hover {
    background: var(--surface-hover);
    border-color: var(--border-light);
}

.action-btn.copied {
    background: var(--success) !important;
    border-color: var(--success) !important;
}

/* Alert Cards */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.alert-card {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    transition: all 0.15s;
}

.alert-card:hover {
    border-color: var(--border-light);
    background: var(--surface);
}

.alert-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

.alert-title-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

h4.alert-name,
.alert-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    word-break: break-word;
}

.alert-severity {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-weight: 500;
    text-transform: lowercase;
    white-space: nowrap;
    flex-shrink: 0;
}

.alert-severity svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.severity-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.severity-critical {
    background: rgba(239, 68, 68, 0.1);
    color: var(--critical);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.severity-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.alert-duration {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--surface);
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    white-space: nowrap;
}

.alert-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-summary {
    font-size: 0.813rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}

.alert-expr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    padding: 0.5rem 0.75rem;
    overflow-x: auto;
}

.alert-expr code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    display: block;
}

.no-alerts {
    text-align: center;
    color: var(--text-dim);
    padding: 2rem;
    font-size: 0.875rem;
}

/* YAML Section */
.yaml-section {
    margin-bottom: 1.5rem;
}

.yaml-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem 0.5rem 0 0;
}

.yaml-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.action-btn.small {
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
}

.alerts-preview {
    margin-bottom: 1rem;
}

.alert-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

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

.alert-name {
    font-size: 0.875rem;
    font-weight: 500;
    font-family: 'SF Mono', Monaco, monospace;
}

.alert-severity {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

.alert-severity.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-severity.critical {
    background: rgba(239, 68, 68, 0.1);
    color: var(--critical);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-summary {
    font-size: 0.813rem;
    color: var(--text-muted);
    margin: 0;
}

.more-alerts {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.813rem;
    margin-top: 0.5rem;
}

.alerts-yaml {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.813rem;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 1rem;
    white-space: pre;
}

.error-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .input-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        min-height: 400px;
    }
    
    .results {
        height: auto;
    }
}

@media (max-width: 768px) {
    header {
        padding: 1rem;
    }
    
    .panel-header {
        padding: 1rem 1.5rem;
    }
    
    .panel-content {
        padding: 1.5rem;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Enhanced Typography & Readability */
h1, h2, h3, h4 {
    letter-spacing: -0.025em;
}

.section-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.result-section {
    transition: all 0.2s;
}

.result-section:hover {
    background: rgba(255, 255, 255, 0.01);
}

/* Focus states */
button:focus-visible,
.action-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Enhanced empty state */
.empty-state svg {
    opacity: 0.3;
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 0.875rem;
    color: var(--text-dim);
}