/* Modern CSS Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors */
    --primary-color: #6366f1;
    --primary-hover: #5855eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --background: #ffffff;
    --surface: #f8fafc;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --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);

    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'SF Mono', Monaco, Inconsolata, 'Roboto Mono', monospace;

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #0f172a;
        --surface: #1e293b;
        --surface-hover: #334155;
        --border: #334155;
        --text-primary: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-muted: #64748b;
    }
}

body {
    font-family: var(--font-family);
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-xl);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--space-sm);
    letter-spacing: -0.025em;
}

.logo p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-2xl);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    align-items: center;
}

.preset-buttons {
    display: flex;
    gap: var(--space-xs);
    background: var(--surface);
    padding: 4px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.preset-btn {
    background: transparent;
    border: none;
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius);
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

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

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

.options-panel {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-lg);
    justify-content: center;
}

.option {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    user-select: none;
}

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

.option span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.editor-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    flex: 1;
}

.editor-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.panel-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-hover) 100%);
}

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

.stats {
    display: flex;
    gap: var(--space-lg);
}

.stat {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-value {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat.savings .stat-value {
    color: var(--success-color);
}

.editor-container {
    flex: 1;
    position: relative;
}

textarea {
    width: 100%;
    height: 100%;
    min-height: 400px;
    padding: var(--space-lg);
    border: none;
    background: transparent;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-primary);
    resize: none;
    outline: none;
}

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

textarea:focus {
    outline: none;
}

#minifiedText {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.02) 0%, rgba(99, 102, 241, 0.05) 100%);
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}

.action-group {
    display: flex;
    gap: var(--space-sm);
}

.btn {
    background: var(--background);
    border: 1px solid var(--border);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-primary);
    text-decoration: none;
}

.btn:hover:not(:disabled) {
    background: var(--surface-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

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

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

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

.btn span {
    font-size: 1rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: var(--space-xl) 0;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--border);
    margin-top: var(--space-2xl);
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    background: var(--success-color);
    color: white;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .editor-section {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }

    .container {
        padding: var(--space-md);
    }

    .stats {
        gap: var(--space-md);
    }
}

@media (max-width: 640px) {
    .logo h1 {
        font-size: 2rem;
    }

    .controls {
        gap: var(--space-md);
    }

    .preset-buttons {
        flex-wrap: wrap;
    }

    .options-panel {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .panel-header {
        flex-direction: column;
        gap: var(--space-sm);
        align-items: flex-start;
    }

    .stats {
        align-self: stretch;
        justify-content: space-around;
    }

    .action-bar {
        flex-direction: column;
        gap: var(--space-md);
    }

    .action-group {
        width: 100%;
        justify-content: center;
    }

    textarea {
        min-height: 300px;
        padding: var(--space-md);
    }

    .toast {
        bottom: var(--space-md);
        right: var(--space-md);
        left: var(--space-md);
    }
}

/* Loading and transition animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading .stat-value {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

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

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

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

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

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