@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #111111;
    --primary-dark: #000000;
    --primary-light: #333333;
    --secondary: #555555;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --dark: #ffffff;
    --dark-light: #f8f8f8;
    --dark-lighter: #eeeeee;
    --text: #111111;
    --text-muted: #666666;
    --border: #dddddd;
    --shadow: rgba(0, 0, 0, 0.08);
}

.user-info {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #f0f0f0;
    border-radius: 0.5rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f2f2f2;
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Table Embed Styles */
.ql-table-embed {
    margin: 10px 0;
    overflow-x: auto;
}

.ql-table-embed table {
    border-collapse: collapse;
    width: 100%;
}

.ql-table-embed td,
.ql-table-embed th {
    border: 1px solid #ccc;
    padding: 5px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Card */
.card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px var(--shadow);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 16px var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary);
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.card-icon {
    font-size: 1.25rem;
}

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

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

textarea,
input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    resize: vertical;
}

input[type="password"] {
    resize: none;
}

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

textarea {
    min-height: 150px;
}

textarea.body-editor {
    min-height: 250px;
    font-family: 'Inter', sans-serif;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

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

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

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

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

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

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

.btn-success:hover:not(:disabled) {
    background: #15803d;
}

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

.btn-sm {
    padding: 0.4rem 0.875rem;
    font-size: 0.85rem;
}

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

/* Variables List */
.variables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.variable-chip {
    background: var(--dark-light);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    padding: 0.6rem 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--text);
}

.variable-chip:hover {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.variable-chip:active {
    transform: scale(0.98);
}

.preset-email-chip {
    background: var(--dark-light);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    color: var(--text-muted);
    user-select: none;
}

.preset-email-chip:hover {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border-color: var(--primary);
}

.preset-email-chip.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    font-weight: 500;
}

/* Email Preview */
.email-preview {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-top: 1rem;
}

.email-subject {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* Navigation Controls */
.nav-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.nav-buttons {
    display: flex;
    gap: 0.5rem;
}

.nav-info {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Copy Buttons */
.copy-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Alert Messages */
#alertContainer {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 10000;
    width: auto;
    max-width: 420px;
}

.alert {
    padding: 0.875rem 1.25rem;
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.25s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    font-size: 0.9rem;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.alert-info {
    background: #f8f8f8;
    border: 1px solid var(--border);
    color: var(--primary);
}

/* Temporary Classes */
.btn-success-temporary {
    background: var(--success) !important;
    color: white !important;
    border-color: var(--success) !important;
    transform: scale(1.02);
    transition: all 0.2s ease;
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

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

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

    .card {
        padding: 1.25rem;
    }

    .variables-grid {
        grid-template-columns: 1fr;
    }

    .nav-controls {
        flex-direction: column;
    }

    .copy-buttons {
        flex-direction: column;
    }

    .btn-block {
        width: 100%;
    }
}

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

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Tooltip */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.4rem 0.75rem;
    background: var(--primary);
    color: #fff;
    border-radius: 0.3rem;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    margin-bottom: 0.4rem;
}

.tooltip:hover::after {
    opacity: 1;
}

/* Stats */
.stats {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.stat-item {
    background: var(--dark-light);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem 1.5rem;
    flex: 1;
    min-width: 150px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* Template Select */
.template-select {
    padding: 0.5rem 1rem;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 200px;
}

.template-select:focus {
    outline: none;
    border-color: var(--primary);
}

.template-select option {
    background: #ffffff;
    color: var(--text);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.2s ease;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 0.25rem;
}

.modal-close:hover {
    background: var(--dark-lighter);
    color: var(--text);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* Quill Editor Customization */
.rich-editor {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    min-height: 300px;
}

.ql-toolbar.ql-snow {
    background: var(--dark-lighter);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 0.375rem 0.375rem 0 0;
    padding: 0.5rem;
}

.ql-container.ql-snow {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0 0 0.375rem 0.375rem;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
}

.ql-editor {
    min-height: 250px;
    color: var(--text);
}

.ql-editor.ql-blank::before {
    color: var(--text-muted);
    font-style: normal;
}

/* Quill toolbar icons — dark on light */
.ql-snow .ql-stroke {
    stroke: #444444;
}

.ql-snow .ql-fill {
    fill: #444444;
}

.ql-snow .ql-picker-label {
    color: #444444;
}

.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow .ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke,
.ql-snow .ql-toolbar button.ql-active .ql-stroke {
    stroke: var(--primary);
}

.ql-snow.ql-toolbar button:hover .ql-fill,
.ql-snow .ql-toolbar button:hover .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-fill,
.ql-snow .ql-toolbar button.ql-active .ql-fill {
    fill: var(--primary);
}

.ql-snow.ql-toolbar button:hover,
.ql-snow .ql-toolbar button:hover,
.ql-snow.ql-toolbar button.ql-active,
.ql-snow .ql-toolbar button.ql-active {
    background: #e5e5e5;
    border-radius: 0.25rem;
}

.ql-snow .ql-picker-options {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.ql-snow .ql-picker-item:hover {
    background: var(--dark-lighter);
    color: var(--primary);
}

/* Email body HTML rendering */
.email-body {
    white-space: normal;
    line-height: 1.8;
    color: var(--text);
    background: #ffffff;
}

.email-body p {
    margin-bottom: 0.75rem;
}

.email-body a {
    color: var(--primary);
    text-decoration: underline;
}

.email-body strong {
    font-weight: 600;
}

.email-body ul,
.email-body ol {
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

/* Table Styles - Editor */
.ql-editor table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    border: 1px solid #cccccc;
}

.ql-editor table td,
.ql-editor table th {
    border: 1px solid #cccccc;
    padding: 0.5rem 0.75rem;
    min-width: 50px;
}

.ql-editor table th {
    background-color: #f0f0f0;
    font-weight: 600;
    color: var(--primary);
}

.ql-editor table tr:nth-child(even) {
    background-color: #fafafa;
}

.ql-editor table tr:hover {
    background-color: #f5f5f5;
}

/* Table Styles - Preview */
.email-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    border: 1px solid #ddd;
}

.email-body table td,
.email-body table th {
    border: 1px solid #ddd;
    padding: 0.5rem 0.75rem;
}

.email-body table th {
    background-color: #f3f4f6;
    font-weight: 600;
    color: #1f2937;
}

.email-body table tr:nth-child(even) {
    background-color: #f9fafb;
}

/* Table button icon */
.ql-snow .ql-toolbar button.ql-table::before {
    content: '⊞';
    font-size: 16px;
    font-weight: bold;
}

/* Better Table Module Styles */
.quill-better-table-wrapper {
    overflow-x: auto;
}

.qlbt-operation-menu {
    background: #ffffff !important;
    border: 1px solid var(--border) !important;
    border-radius: 0.375rem !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
}

.qlbt-operation-menu-item {
    color: var(--text) !important;
    padding: 0.5rem 1rem !important;
}

.qlbt-operation-menu-item:hover {
    background: var(--dark-lighter) !important;
    color: var(--primary) !important;
}