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

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    padding: 2rem 0;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

main {
    flex: 1;
}

.converter-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1.5rem;
    align-items: start;
}

.panel {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}

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

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.format-selector {
    display: flex;
    gap: 0.5rem;
}

.format-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.format-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.format-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.output-format-badge {
    padding: 0.3rem 0.6rem;
    background: var(--surface-light);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

textarea {
    width: 100%;
    height: 400px;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease;
}

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

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

textarea:read-only {
    cursor: default;
}

.panel-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 0;
}

.convert-btn {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.convert-icon {
    font-size: 1.2rem;
}

.options {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    width: 100%;
    min-width: 200px;
}

.options h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.option-group {
    margin-bottom: 0.75rem;
}

.option-group:last-child {
    margin-bottom: 0;
}

.option-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.option-group select {
    width: 100%;
    padding: 0.5rem;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    margin-top: 0.25rem;
}

.option-group select:focus {
    border-color: var(--primary-color);
}

.option-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.validation-message {
    margin-top: 1.5rem;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.validation-message.hidden {
    display: none;
}

.validation-message.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.validation-message.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

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

footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
}

footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .converter-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .controls {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 1rem;
        background: var(--surface);
        border-radius: 12px;
        border: 1px solid var(--border-color);
    }

    .convert-btn {
        order: -1;
        width: 100%;
        justify-content: center;
    }

    .options {
        border: none;
        padding: 0;
        background: transparent;
    }

    .options h3 {
        display: none;
    }

    .option-group {
        margin-bottom: 0;
    }

    textarea {
        height: 300px;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0.75rem;
    }

    header {
        padding: 1.5rem 0;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .panel {
        padding: 1rem;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .panel-actions {
        flex-wrap: wrap;
    }

    .btn {
        flex: 1;
        justify-content: center;
        min-width: 100px;
    }

    textarea {
        height: 250px;
        font-size: 0.85rem;
    }

    .controls {
        flex-direction: column;
    }

    .option-group select {
        width: auto;
        min-width: 120px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.validation-message:not(.hidden) {
    animation: fadeIn 0.3s ease;
}

/* Copy button animation */
.btn-secondary.copied {
    background: var(--success);
    border-color: var(--success);
}

/* Focus visible for accessibility */
button:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

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

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

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

textarea::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}
