/* CSS Reset & Variables */
:root {
    /* Premium Dark Theme Core */
    --bg-dark: #0F1219;
    --bg-surface: rgba(30, 36, 48, 0.6);
    --bg-surface-hover: rgba(45, 55, 72, 0.8);

    /* Accents */
    --accent-primary: #6366F1;
    --accent-secondary: #8B5CF6;
    --accent-gradient: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);

    /* Text Colors */
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-tertiary: #64748B;

    /* UI Elements */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.5);

    /* Shadows & Effects */
    --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --glass-blur: 16px;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;

    /* Subtle Background Grid Element */
    background-image: radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(139, 92, 246, 0.1) 0%, transparent 40%);
    background-attachment: fixed;
}

/* Glassmorphism Utilities */
.blur-surface {
    background: var(--bg-surface);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}

/* Layout */
.app-container {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Header */
.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    gap: 0.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-icon {
    color: var(--accent-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Main Area */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    body {
        padding: 0.5rem;
    }

    .app-container {
        gap: 1rem;
    }

    .main-content {
        gap: 1rem;
    }

    .panels {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .header {
        padding: 0.75rem;
        gap: 0.25rem;
    }

    .logo {
        font-size: 1.25rem;
    }

    textarea,
    .output-container {
        min-height: 120px;
        padding: 0.75rem;
    }

    .panel-header {
        padding: 0.5rem 0.75rem;
    }

    .controls {
        padding: 0.75rem;
        gap: 1rem;
    }

    .primary-btn {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .info-banner {
        padding: 0.75rem;
        font-size: 0.8rem;
    }
}

.panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.panel:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.2);
}

.panel-header h2 {
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.panel-header i {
    color: var(--text-tertiary);
    width: 16px;
    height: 16px;
}

/* Input Styles */
textarea {
    width: 100%;
    flex-grow: 1;
    min-height: 250px;
    background: transparent;
    border: none;
    padding: 1.25rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
}

textarea::placeholder {
    color: var(--text-tertiary);
}

/* Output Data */
.output-container {
    padding: 1.25rem;
    flex-grow: 1;
    min-height: 250px;
    overflow-y: auto;
    position: relative;
}

.placeholder-text {
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-style: italic;
    font-size: 0.9rem;
}

.output-content {
    color: var(--text-primary);
    white-space: pre-wrap;
    font-size: 1rem;
    line-height: 1.7;
}

.hidden {
    display: none !important;
}

/* Controls */
.controls {
    padding: 1.25rem;
    border-top: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Slider Customization */
.slider-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.slider-labels label {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Select Dropdown Styling */
.model-select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.model-select-wrapper label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.styled-select {
    background: rgba(0, 0, 0, 0.4);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2394A3B8%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem top 50%;
    background-size: 0.65rem auto;
    transition: all 0.2s ease;
}

.styled-select:focus,
.styled-select:hover {
    border-color: rgba(99, 102, 241, 0.5);
    background-color: rgba(0, 0, 0, 0.6);
}

.styled-select option {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    padding: 0.5rem;
}

#errorRateValue {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: var(--accent-primary);
    font-weight: 600;
}

/* Range Input Styling - Webkit */
.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
    transition: transform 0.2s ease, box-shadow 0.2s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.8);
}

.slider-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

/* Buttons */
.primary-btn {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
    filter: brightness(1.1);
}

.primary-btn:active {
    transform: translateY(0);
}

.primary-btn.processing {
    opacity: 0.8;
    pointer-events: none;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    transition: all 0.2s;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Subtle hints */
.info-banner {
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.info-banner i {
    color: var(--accent-secondary);
    width: 18px;
    height: 18px;
}

.info-banner b {
    color: var(--text-primary);
}

/* Animations */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

/* Custom Scrollbar for Text Area & Output */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}