/* Import modern web fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables for theming */
:root {
    /* Dark theme (default) */
    --bg-primary: #1e1e1e;
    --bg-secondary: #2d2d30;
    --bg-tertiary: #3e3e42;
    --text-primary: #e5e7eb;
    --text-secondary: #a1a1aa;
    --text-muted: #858585;
    --border-primary: #52525b;
    --border-secondary: #71717a;
    --code-bg: #1e1e1e;
    --code-line-bg: #1e1e1e;
    --code-var: #4fc1ff;
    --code-string: #ce9178;
    --code-number: #b5cea8;
    --success-bg: rgba(16, 185, 129, 0.1);
    --success-border: #10b981;
    --success-text: #10b981;
    --error-bg: rgba(239, 68, 68, 0.1);
    --error-border: #ef4444;
    --error-text: #ef4444;
    --scrollbar-track: #1e1e1e;
    --scrollbar-thumb: #3f3f46;
    --scrollbar-thumb-hover: #52525b;
}

/* Light theme */
body.light-theme {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-primary: #dee2e6;
    --border-secondary: #adb5bd;
    --code-bg: #f8f9fa;
    --code-line-bg: #f8f9fa;
    --code-var: #0366d6;
    --code-string: #d73a49;
    --code-number: #28a745;
    --success-bg: rgba(40, 167, 69, 0.1);
    --success-border: #28a745;
    --success-text: #28a745;
    --error-bg: rgba(220, 53, 69, 0.1);
    --error-border: #dc3545;
    --error-text: #dc3545;
    --scrollbar-track: #f8f9fa;
    --scrollbar-thumb: #dee2e6;
    --scrollbar-thumb-hover: #adb5bd;
}

body {
    font-family: 'Inter', 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    counter-reset: global-line-number 49;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-primary);
    transition: background-color 0.3s ease;
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
    padding: 8px 16px;
    height: 48px;
    box-sizing: border-box;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.top-bar-left {
    display: flex;
    align-items: center;
}

.top-bar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.app-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.file-icon {
    font-size: 16px;
}

.file-name {
    color: var(--text-primary);
    font-weight: 600;
    transition: color 0.3s ease;
}

.file-status {
    color: var(--text-muted);
    font-size: 12px;
    transition: color 0.3s ease;
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    margin-right: 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Button Group */
.button-group {
    display: flex;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-primary);
    transition: border-color 0.3s ease;
}

.top-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border: none;
    border-right: 1px solid var(--border-primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    height: 28px;
    box-sizing: border-box;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 0;
}

.top-btn:last-child {
    border-right: none;
}

.top-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Copy button feedback states */
.top-btn.copy-success {
    background: var(--success-bg);
    color: var(--success-text);
    animation: flashSuccess 0.6s ease;
}

.top-btn.copy-success:not(:last-child) {
    border-right-color: var(--border-primary);
}

.top-btn.copy-error {
    background: var(--error-bg);
    color: var(--error-text);
    animation: flashError 0.6s ease;
}

.top-btn.copy-error:not(:last-child) {
    border-right-color: var(--border-primary);
}

.top-btn.clear-success {
    background: var(--success-bg);
    color: var(--success-text);
    animation: flashSuccess 0.6s ease;
}

.top-btn.clear-success:not(:last-child) {
    border-right-color: var(--border-primary);
}

@keyframes flashSuccess {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

@keyframes flashError {
    0% { opacity: 1; }
    25% { opacity: 0.7; }
    50% { opacity: 1; }
    75% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Notifications */
.notification {
    margin: 16px;
    padding: 12px 16px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    animation: slideIn 0.3s ease;
}

.notification-success {
    background-color: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success-text);
}

.notification-error {
    background-color: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--error-text);
}

.notification-icon {
    font-size: 16px;
}

.notification-text {
    flex: 1;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Editor Container */
.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--code-bg);
    overflow: hidden;
    transition: background-color 0.3s ease;
}

/* Form styles */
.smtp-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--code-bg);
    overflow-y: auto;
    transition: background-color 0.3s ease;
}

.form-section {
    margin-bottom: 0;
    background-color: var(--code-line-bg);
    border: none;
    border-radius: 0;
    padding: 0;
    position: relative;
    transition: background-color 0.3s ease;
}

.form-section h2 {
    display: none;
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-family: 'Fira Code', 'JetBrains Mono', 'Cascadia Code', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
}

.form-group label::before {
    content: "# ";
    color: #9ca3af;
    font-style: italic;
}

.form-group {
    position: relative;
    display: flex;
    background-color: var(--code-line-bg);
    border-radius: 0;
    margin-bottom: 0;
    min-height: 24px;
    line-height: 24px;
    transition: background-color 0.3s ease;
}

.form-group::before {
    content: counter(global-line-number);
    counter-increment: global-line-number;
    display: inline-block;
    width: 40px;
    padding: 0 16px 0 8px;
    color: var(--text-muted);
    font-size: 14px;
    font-family: 'Fira Code', 'JetBrains Mono', 'Cascadia Code', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
    text-align: right;
    background-color: var(--code-line-bg);
    border-right: 1px solid var(--bg-secondary);
    user-select: none;
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.form-group .var-name {
    color: var(--code-var);
    font-family: 'Fira Code', 'JetBrains Mono', 'Cascadia Code', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 14px;
    margin-right: 4px;
    font-weight: normal;
    white-space: nowrap;
    transition: color 0.3s ease;
}

.form-group input,
.form-group select,
.form-group textarea {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0 0 0 4px;
    font-size: 14px;
    font-family: 'Fira Code', 'JetBrains Mono', 'Cascadia Code', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
    color: var(--code-string);
    line-height: 24px;
    height: 24px;
    flex: 1;
    transition: color 0.3s ease, background-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    background-color: var(--bg-tertiary);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #ce9178;
    font-style: normal;
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 24px;
    padding: 0;
}

/* Different colors for different input types to match .env syntax */
.form-group input[type="text"],
.form-group input[type="email"] {
    color: var(--code-string);
}

.form-group input[type="password"] {
    color: var(--code-string);
}

.form-group input[type="number"] {
    color: var(--code-number);
}

.form-group select {
    color: var(--code-string);
}

.form-group select option {
    background-color: var(--code-bg);
    color: var(--code-string);
}

/* Handle quoted values */
.form-group input[type="email"]::before,
.form-group input[name="smtp_username"]::before,
.form-group input[name="smtp_password"]::before,
.form-group input[name="from_name"]::before,
.form-group textarea::before {
    content: '"';
    color: var(--code-string);
}

.form-group input[type="email"]::after,
.form-group input[name="smtp_username"]::after,
.form-group input[name="smtp_password"]::after,
.form-group input[name="from_name"]::after,
.form-group textarea::after {
    content: '"';
    color: var(--code-string);
}

/* Password input wrapper */
.password-input-wrapper {
    display: flex;
    align-items: center;
    flex: 1;
    position: relative;
}

.password-input-wrapper input {
    flex: 1;
    margin: 0;
}

.password-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 8px;
    margin: 0;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: color 0.2s ease;
}

.password-toggle:hover {
    color: var(--code-var);
}

.password-toggle:focus {
    outline: none;
    color: var(--code-var);
}

.password-toggle-icon {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1;
}

/* Keep all existing .env form group styling exactly as it is */

/* Responsive design */
@media (max-width: 768px) {
    .top-bar {
        padding: 8px 12px;
        flex-wrap: wrap;
        height: auto;
        min-height: 48px;
    }
    
    .top-bar-right {
        gap: 6px;
    }
    
    .top-btn {
        font-size: 11px;
        padding: 4px 8px;
        height: 24px;
    }
    
    .app-title {
        font-size: 12px;
    }
    
    .notification {
        margin: 12px;
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* Console */
.console-container {
    background: var(--bg-secondary);
    border-top: 1px solid var(--bg-tertiary);
    max-height: 300px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, border-color 0.3s ease, max-height 0.3s ease;
}

.console-container.collapsed {
    max-height: 32px;
    min-height: 32px;
}

.console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
    height: 32px;
    box-sizing: border-box;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.console-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.console-icon {
    color: var(--code-var);
    font-family: monospace;
    font-weight: bold;
    transition: color 0.3s ease;
}

.console-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 2px;
    font-size: 14px;
    line-height: 1;
    transition: all 0.2s ease;
    font-family: monospace;
    font-weight: bold;
}

.console-toggle:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.console-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    font-family: 'Fira Code', 'JetBrains Mono', 'Cascadia Code', 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 12px;
    line-height: 1.4;
    background: var(--bg-secondary);
    transition: background-color 0.3s ease;
}

.console-message {
    margin-bottom: 4px;
    display: flex;
    gap: 8px;
}

.console-timestamp {
    color: var(--text-muted);
    white-space: nowrap;
    transition: color 0.3s ease;
}

.console-text {
    flex: 1;
    word-wrap: break-word;
}

.console-info .console-text {
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.console-success .console-text {
    color: var(--success-text);
    transition: color 0.3s ease;
}

.console-error .console-text {
    color: var(--error-text);
    transition: color 0.3s ease;
}

.console-warning .console-text {
    color: #f59e0b;
    transition: color 0.3s ease;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
} 