/* CSS Variables */
:root {
    --primary-color: #2d7d46;
    --primary-hover: #236636;
    --secondary-color: #6c757d;
    --secondary-hover: #5a6268;
    --background-color: #f5f7fa;
    --card-background: #ffffff;
    --border-color: #e1e5eb;
    --text-primary: #1a1a2e;
    --text-secondary: #6c757d;
    --text-muted: #9ca3af;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --code-background: #1e1e2e;
    --code-text: #cdd6f4;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --transition: all 0.2s ease;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), #1a5c32);
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
}

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

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

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.tagline {
    font-size: 1rem;
    opacity: 0.9;
    margin-top: 0.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Config Panel */
.config-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Config Sections */
.config-section {
    background: var(--card-background);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--card-background);
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.section-header:hover {
    background: var(--background-color);
}

.section-header h2 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.section-header .icon {
    font-size: 1.25rem;
}

.toggle-icon {
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.section-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.section-content {
    padding: 1.25rem;
    border-top: 1px solid var(--border-color);
    display: block;
}

.section-content.hidden {
    display: none;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

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

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--card-background);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(45, 125, 70, 0.15);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Input with Unit */
.input-with-unit {
    display: flex;
    gap: 0.5rem;
}

.input-with-unit input {
    flex: 1;
}

.input-with-unit select {
    width: auto;
    min-width: 80px;
}

/* Checkbox Styles */
.checkbox-group {
    margin-bottom: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    user-select: none;
}

.checkbox-label.small {
    font-size: 0.8125rem;
}

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

.checkbox-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

/* Range Input */
input[type="range"] {
    width: calc(100% - 50px);
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
    vertical-align: middle;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.range-value {
    display: inline-block;
    width: 40px;
    text-align: center;
    font-weight: 600;
    color: var(--primary-color);
}

/* Cache Settings */
.cache-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border-color);
}

.cache-item:last-child {
    border-bottom: none;
}

.cache-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.cache-input {
    display: flex;
    gap: 0.375rem;
}

.cache-input input {
    width: 60px;
    padding: 0.375rem 0.5rem;
    font-size: 0.8125rem;
}

.cache-input select {
    width: auto;
    padding: 0.375rem 0.5rem;
    font-size: 0.8125rem;
}

/* Custom Redirects */
.custom-redirects {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.custom-redirects h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.redirect-item {
    display: grid;
    grid-template-columns: 1fr 1fr auto auto;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.redirect-item input {
    padding: 0.5rem;
    font-size: 0.8125rem;
}

.redirect-item select {
    padding: 0.5rem;
    font-size: 0.8125rem;
}

.btn-remove {
    background: var(--danger-color);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-remove:hover {
    background: #c82333;
}

/* SSL, Proxy, Logging Options */
.ssl-options,
.proxy-options,
.logging-options,
.caching-options {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

#ssl-options,
#proxy-options,
#logging-options,
#caching-options,
#hsts-options,
#gzip-options {
    display: none;
}

#ssl-options.visible,
#proxy-options.visible,
#logging-options.visible,
#caching-options.visible,
#hsts-options.visible,
#gzip-options.visible {
    display: block;
}

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

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

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

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

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

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

.btn-block {
    width: 100%;
}

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

/* Output Panel */
.output-panel {
    background: var(--card-background);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
}

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

.output-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.output-actions {
    display: flex;
    gap: 0.5rem;
}

.output-content {
    flex: 1;
    overflow: auto;
    background: var(--code-background);
    margin: 0;
}

.output-content pre {
    margin: 0;
    padding: 1.25rem;
    font-size: 0.8125rem;
    line-height: 1.6;
    overflow-x: auto;
}

.output-content code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    color: var(--code-text);
    white-space: pre;
}

.output-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

/* Footer */
.footer {
    background: var(--card-background);
    border-top: 1px solid var(--border-color);
    padding: 1.25rem;
    text-align: center;
}

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

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

.footer a:hover {
    text-decoration: underline;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

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

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .output-panel {
        position: static;
        max-height: 500px;
    }
}

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

    .header h1 {
        font-size: 1.5rem;
    }

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

    .main-content {
        padding: 1rem;
        gap: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .redirect-item {
        grid-template-columns: 1fr 1fr;
    }

    .redirect-item input:first-child {
        grid-column: 1 / -1;
    }

    .cache-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .output-actions {
        flex-direction: column;
    }

    .output-actions .btn {
        width: 100%;
    }

    .output-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .output-header h2 {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.25rem;
    }

    .tagline {
        font-size: 0.875rem;
    }

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

    .section-content {
        padding: 1rem;
    }

    .checkbox-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .input-with-unit {
        flex-direction: column;
    }

    .input-with-unit select {
        width: 100%;
    }
}

/* Syntax Highlighting for Config */
.config-comment {
    color: #6a9955;
}

.config-directive {
    color: #569cd6;
}

.config-value {
    color: #ce9178;
}

.config-block {
    color: #c586c0;
}

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

.output-content::-webkit-scrollbar-track {
    background: var(--code-background);
}

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

.output-content::-webkit-scrollbar-thumb:hover {
    background: #5a5a6a;
}

/* Animation for sections */
.section-content {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
