/* Global Styles */
:root {
    --primary-color: #009639;
    --primary-hover: #007a2e;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    
    /* Dark Mode (Default) */
    --background-color: #1a1a1a;
    --surface-color: #2d2d2d;
    --border-color: #3c3c3c;
    --text-color: #e4e4e4;
    --text-muted: #999999;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.5);
    
    /* Code Editor Dark Mode */
    --editor-bg: #1e1e1e;
    --editor-text: #d4d4d4;
    --editor-border: #3c3c3c;
    --editor-placeholder: #999999;
}

/* Light Mode */
body.light-mode {
    --background-color: #f5f7fa;
    --surface-color: #ffffff;
    --border-color: #dee2e6;
    --text-color: #212529;
    --text-muted: #6c757d;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
    
    /* Code Editor Light Mode */
    --editor-bg: #f8f9fa;
    --editor-text: #212529;
    --editor-border: #dee2e6;
    --editor-placeholder: #6c757d;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #006b2a 100%);
    color: white;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 15px;
}

.version-info {
    font-size: 0.9rem;
    opacity: 0.8;
    font-family: 'Courier New', monospace;
}

/* Main Sections */
main {
    display: grid;
    gap: 30px;
}

section {
    background: var(--surface-color);
    padding: 30px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

/* Form Groups */
.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.required {
    color: var(--danger-color);
}

.help-text {
    display: block;
    margin-top: 5px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Input Fields */
input[type="text"],
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    background-color: var(--surface-color);
    color: var(--text-color);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s ease, color 0.3s ease;
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 150, 57, 0.1);
}

textarea {
    font-family: 'Courier New', monospace;
    resize: vertical;
}

input.error,
textarea.error {
    border-color: var(--danger-color);
}

input.error:focus,
textarea.error:focus {
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

/* Code Editor */
.code-editor-wrapper {
    position: relative;
}

.code-editor {
    width: 100%;
    min-height: 400px;
    max-height: 600px;
    padding: 16px;
    border: 2px solid var(--editor-border);
    border-radius: 6px;
    font-family: 'Courier New', Consolas, Monaco, monospace;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.6;
    overflow: auto;
    background-color: var(--editor-bg);
    color: var(--editor-text);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s ease, color 0.3s ease;
    white-space: pre-wrap;
    word-wrap: break-word;
    tab-size: 4;
}

.code-editor:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 150, 57, 0.1);
}

.code-editor.error {
    border-color: var(--danger-color);
}

.code-editor.error:focus {
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.code-editor[data-placeholder]:empty:before {
    content: attr(data-placeholder);
    color: var(--editor-placeholder);
    font-style: italic;
}

.code-editor:focus[data-placeholder]:empty:before {
    content: '';
}

/* Dark Mode Syntax Colors */
.code-editor .token.comment,
.code-editor .token.prolog,
.code-editor .token.doctype,
.code-editor .token.cdata {
    color: #6a9955;
}

.code-editor .token.punctuation {
    color: #d4d4d4 !important;
}

.code-editor .token.property,
.code-editor .token.tag,
.code-editor .token.boolean,
.code-editor .token.number,
.code-editor .token.constant,
.code-editor .token.symbol,
.code-editor .token.deleted {
    color: #4ec9b0 !important;
}

.code-editor .token.selector,
.code-editor .token.attr-name,
.code-editor .token.string,
.code-editor .token.char,
.code-editor .token.builtin,
.code-editor .token.inserted {
    color: #ffa07a !important;
}

.code-editor .token.operator,
.code-editor .token.entity,
.code-editor .token.url,
.code-editor .language-css .token.string,
.code-editor .style .token.string {
    color: #d4d4d4 !important;
}

.code-editor .token.atrule,
.code-editor .token.attr-value,
.code-editor .token.keyword {
    color: #9cdcfe !important;
}

.code-editor .token.function,
.code-editor .token.class-name {
    color: #dcdcaa !important;
}

.code-editor .token.regex,
.code-editor .token.important,
.code-editor .token.variable {
    color: #f48771 !important;
}

/* Light Mode Syntax Colors Override */
body.light-mode .code-editor .token.comment,
body.light-mode .code-editor .token.prolog,
body.light-mode .code-editor .token.doctype,
body.light-mode .code-editor .token.cdata {
    color: #6a9955 !important;
}

body.light-mode .code-editor .token.punctuation {
    color: #212529 !important;
}

body.light-mode .code-editor .token.property,
body.light-mode .code-editor .token.tag,
body.light-mode .code-editor .token.boolean,
body.light-mode .code-editor .token.number,
body.light-mode .code-editor .token.constant,
body.light-mode .code-editor .token.symbol,
body.light-mode .code-editor .token.deleted {
    color: #0066cc !important;
}

body.light-mode .code-editor .token.selector,
body.light-mode .code-editor .token.attr-name,
body.light-mode .code-editor .token.string,
body.light-mode .code-editor .token.char,
body.light-mode .code-editor .token.builtin,
body.light-mode .code-editor .token.inserted {
    color: #a31515 !important;
}

body.light-mode .code-editor .token.operator,
body.light-mode .code-editor .token.entity,
body.light-mode .code-editor .token.url,
body.light-mode .code-editor .language-css .token.string,
body.light-mode .code-editor .style .token.string {
    color: #212529 !important;
}

body.light-mode .code-editor .token.atrule,
body.light-mode .code-editor .token.attr-value,
body.light-mode .code-editor .token.keyword {
    color: #0000ff !important;
}

body.light-mode .code-editor .token.function,
body.light-mode .code-editor .token.class-name {
    color: #795e26 !important;
}

body.light-mode .code-editor .token.regex,
body.light-mode .code-editor .token.important,
body.light-mode .code-editor .token.variable {
    color: #c00000 !important;
}

/* Error Messages */
.error-message {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 5px;
    min-height: 20px;
    display: none;
}

.error-message.show {
    display: block;
}

/* Tabs */
.input-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.tab-button {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    transition: all 0.2s;
    position: relative;
    bottom: -2px;
}

.tab-button:hover {
    color: var(--primary-color);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 500;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* File Upload */
.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    padding: 40px;
    text-align: center;
    transition: all 0.2s;
    background-color: #fafbfc;
}

.file-upload-area.dragover {
    border-color: var(--primary-color);
    background-color: rgba(0, 150, 57, 0.05);
}

.file-upload-area input[type="file"] {
    display: none;
}

.file-upload-area label {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.file-upload-area svg {
    color: var(--text-muted);
}

.upload-text {
    font-size: 1rem;
    color: var(--text-color);
    font-weight: 500;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.file-info {
    margin-top: 15px;
    padding: 10px;
    background-color: var(--background-color);
    border-radius: 4px;
    font-size: 0.875rem;
    display: none;
}

.file-info.show {
    display: block;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

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

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

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

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

.btn-secondary:hover:not(:disabled) {
    background-color: #5a6268;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn.loading .btn-text {
    opacity: 0;
}

.btn.loading .btn-spinner {
    display: block;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

/* Output Section */
.output-section {
    display: none;
}

.output-section.show {
    display: block;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.output-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: flex-end;
}

.output-content {
    background-color: var(--editor-bg);
    border: 1px solid var(--editor-border);
    border-radius: 6px;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

#nginx-output {
    margin: 0;
    padding: 0;
    overflow-x: auto;
    max-height: 600px;
    background-color: var(--editor-bg);
    transition: background-color 0.3s ease;
}

#nginx-output code {
    font-family: 'Courier New', Consolas, Monaco, monospace !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    line-height: 1.6 !important;
    color: var(--editor-text);
    transition: color 0.3s ease;
}

/* Prism.js theme customization for NGINX output */
pre[class*="language-"] {
    margin: 0;
    padding: 20px;
    background-color: var(--editor-bg) !important;
    font-family: 'Courier New', Consolas, Monaco, monospace !important;
    font-size: 0.9rem !important;
    line-height: 1.6 !important;
    transition: background-color 0.3s ease;
}

code[class*="language-"],
pre[class*="language-"] {
    background-color: var(--editor-bg) !important;
    color: var(--editor-text);
    font-family: 'Courier New', Consolas, Monaco, monospace !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    line-height: 1.6 !important;
    transition: background-color 0.3s ease, color 0.3s ease;
}

pre.line-numbers {
    position: relative;
    padding-left: 3.8em;
    counter-reset: linenumber;
    background-color: var(--editor-bg) !important;
    transition: background-color 0.3s ease;
}

pre.line-numbers > code {
    position: relative;
    white-space: pre-wrap;
    word-wrap: break-word;
    tab-size: 4;
    background-color: var(--editor-bg) !important;
    transition: background-color 0.3s ease;
}

.line-numbers .line-numbers-rows {
    position: absolute;
    pointer-events: none;
    top: 0;
    font-size: 100%;
    left: -3.8em;
    width: 3em;
    letter-spacing: -1px;
    border-right: 1px solid var(--editor-border);
    user-select: none;
    transition: border-color 0.3s ease;
}

.line-numbers-rows > span {
    display: block;
    counter-increment: linenumber;
}

.line-numbers-rows > span:before {
    content: counter(linenumber);
    color: var(--text-muted);
    display: block;
    padding-right: 0.8em;
    text-align: right;
    transition: color 0.3s ease;
}

/* Dark Mode Syntax Colors for NGINX Output */
code[class*="language-"] .token.comment,
code[class*="language-"] .token.prolog,
code[class*="language-"] .token.doctype,
code[class*="language-"] .token.cdata {
    color: #6a9955;
}

code[class*="language-"] .token.punctuation {
    color: #d4d4d4;
}

code[class*="language-"] .token.property,
code[class*="language-"] .token.tag,
code[class*="language-"] .token.boolean,
code[class*="language-"] .token.number,
code[class*="language-"] .token.constant {
    color: #4ec9b0 !important;
}

code[class*="language-"] .token.selector,
code[class*="language-"] .token.attr-name,
code[class*="language-"] .token.string,
code[class*="language-"] .token.char,
code[class*="language-"] .token.builtin {
    color: #ffa07a !important;
}

code[class*="language-"] .token.operator,
code[class*="language-"] .token.entity,
code[class*="language-"] .token.url {
    color: #d4d4d4 !important;
}

code[class*="language-"] .token.atrule,
code[class*="language-"] .token.attr-value,
code[class*="language-"] .token.keyword,
code[class*="language-"] .token.directive {
    color: #9cdcfe !important;
}

code[class*="language-"] .token.function,
code[class*="language-"] .token.class-name,
code[class*="language-"] .token.variable {
    color: #dcdcaa !important;
}

code[class*="language-"] .token.regex,
code[class*="language-"] .token.important {
    color: #f48771 !important;
}

/* Light Mode Syntax Colors Override for NGINX Output */
body.light-mode code[class*="language-"] .token.comment,
body.light-mode code[class*="language-"] .token.prolog,
body.light-mode code[class*="language-"] .token.doctype,
body.light-mode code[class*="language-"] .token.cdata {
    color: #6a9955 !important;
}

body.light-mode code[class*="language-"] .token.punctuation {
    color: #212529 !important;
}

body.light-mode code[class*="language-"] .token.property,
body.light-mode code[class*="language-"] .token.tag,
body.light-mode code[class*="language-"] .token.boolean,
body.light-mode code[class*="language-"] .token.number,
body.light-mode code[class*="language-"] .token.constant {
    color: #0066cc !important;
}

body.light-mode code[class*="language-"] .token.selector,
body.light-mode code[class*="language-"] .token.attr-name,
body.light-mode code[class*="language-"] .token.string,
body.light-mode code[class*="language-"] .token.char,
body.light-mode code[class*="language-"] .token.builtin {
    color: #a31515 !important;
}

body.light-mode code[class*="language-"] .token.operator,
body.light-mode code[class*="language-"] .token.entity,
body.light-mode code[class*="language-"] .token.url {
    color: #212529 !important;
}

body.light-mode code[class*="language-"] .token.atrule,
body.light-mode code[class*="language-"] .token.attr-value,
body.light-mode code[class*="language-"] .token.keyword,
body.light-mode code[class*="language-"] .token.directive {
    color: #0000ff !important;
}

body.light-mode code[class*="language-"] .token.function,
body.light-mode code[class*="language-"] .token.class-name,
body.light-mode code[class*="language-"] .token.variable {
    color: #795e26 !important;
}

body.light-mode code[class*="language-"] .token.regex,
body.light-mode code[class*="language-"] .token.important {
    color: #c00000 !important;
}

/* Theme Toggle */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-toggle-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.3);
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: rgba(255, 255, 255, 0.5);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-icon {
    font-size: 1.1rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer-links {
    margin-top: 10px;
}

.footer-links a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

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

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 15px 20px;
    background-color: var(--text-color);
    color: white;
    border-radius: 6px;
    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;
}

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        padding: 30px 15px;
    }

    header h1 {
        font-size: 2rem;
    }

    section {
        padding: 20px;
    }

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

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

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

    .toast {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }
}
