/* CSS Reset and Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --success: #10b981;
    --error: #ef4444;
    --code-bg: #1e293b;
    --code-text: #e2e8f0;
    --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);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: 150ms ease;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

/* Header */
header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

h1 {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
    margin-top: 0.5rem;
}

/* Main Content */
main {
    flex: 1;
}

/* Converter Container */
.converter-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1.5rem;
    align-items: stretch;
    margin-bottom: 3rem;
}

/* Panels */
.panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

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

.panel-header h2 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Textarea */
textarea {
    flex: 1;
    width: 100%;
    min-height: 400px;
    padding: 1.25rem;
    border: none;
    resize: none;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--surface);
}

textarea:focus {
    outline: none;
}

textarea::placeholder {
    color: var(--text-muted);
}

/* Output Area */
.output-area {
    flex: 1;
    min-height: 400px;
    padding: 1.25rem;
    margin: 0;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.7;
    background: var(--code-bg);
    color: var(--code-text);
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.output-area code {
    font-family: inherit;
    color: inherit;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* Convert Button Container */
.convert-button-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-convert {
    padding: 1rem 2rem;
    font-size: 1rem;
    border-radius: var(--radius-lg);
}

.btn-convert svg {
    transition: transform var(--transition);
}

.btn-convert:hover svg {
    transform: translateX(4px);
}

/* Features Section */
.features {
    margin-top: 2rem;
}

.features h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    text-align: center;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.feature-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    transition: all var(--transition);
}

.feature-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.feature-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.feature-card h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.feature-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

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

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

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

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

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--code-bg);
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    transition: all 300ms ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast svg {
    color: var(--success);
}

.toast.error svg {
    color: var(--error);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .converter-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .convert-button-container {
        padding: 0.5rem 0;
    }

    .btn-convert {
        width: 100%;
    }

    .btn-convert svg {
        transform: rotate(90deg);
    }

    .btn-convert:hover svg {
        transform: rotate(90deg) translateX(4px);
    }

    textarea,
    .output-area {
        min-height: 300px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 1.5rem 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .logo {
        width: 40px;
        height: 40px;
    }

    .feature-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .feature-card {
        padding: 1.25rem;
    }

    .panel-header {
        padding: 0.875rem 1rem;
    }

    textarea,
    .output-area {
        min-height: 250px;
        padding: 1rem;
        font-size: 0.8125rem;
    }

    .btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.8125rem;
    }

    .btn-convert {
        padding: 0.875rem 1.5rem;
    }
}

/* Scrollbar Styling */
.output-area::-webkit-scrollbar,
textarea::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.output-area::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track {
    background: transparent;
}

.output-area::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

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

.output-area::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

textarea::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Selection */
::selection {
    background: var(--primary-light);
    color: var(--primary-color);
}

.output-area ::selection {
    background: var(--primary-color);
    color: white;
}
