/* ===========================
   Email Templates Page Styles
   =========================== */

/* Main Container */
.email-templates-container {
    padding: 24px;
}

/* Template Selector */
.template-selector {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
}

.template-selector label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 12px;
    font-size: 15px;
}

.template-selector select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 15px;
    color: #1f2937;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.template-selector select:hover {
    border-color: #667eea;
}

.template-selector select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Editor and Preview Container */
.editor-preview-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

@media (max-width: 1400px) {
    .editor-preview-container {
        grid-template-columns: 1fr;
    }
}

/* Section Common Styles */
.editor-section,
.preview-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    height: 700px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 2px solid #f3f4f6;
}

.section-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    color: #1f2937;
    margin: 0;
}

.section-header h3 i {
    color: #667eea;
}

/* Editor Actions */
.editor-actions,
.preview-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: #f3f4f6;
    color: #4b5563;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.btn-icon:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.btn-icon:active {
    transform: translateY(0);
}

/* Search Bar */
.editor-search-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    gap: 16px;
}

.search-input-group {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Monaco', 'Menlo', monospace;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-results-count {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    min-width: 80px;
}

.search-controls {
    display: flex;
    gap: 4px;
}

.btn-search {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e7eb;
    background: white;
    color: #4b5563;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
}

.btn-search:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.btn-search.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.btn-search.btn-close {
    border-color: #ef4444;
    color: #ef4444;
}

.btn-search.btn-close:hover {
    background: #ef4444;
    color: white;
}

/* Editor Wrapper */
.editor-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.email-code-editor {
    flex: 1;
    width: 100%;
    padding: 20px;
    border: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #1f2937;
    background: #f9fafb;
    resize: none;
    outline: none;
}

.email-code-editor:focus {
    background: #ffffff;
}

.email-code-editor::placeholder {
    color: #9ca3af;
    font-style: italic;
}

/* Editor Footer */
.editor-footer {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    background: #f3f4f6;
    border-top: 1px solid #e5e7eb;
    font-size: 12px;
    color: #6b7280;
}

.editor-footer span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.editor-footer i {
    color: #667eea;
}

#line-count,
#char-count {
    font-weight: 600;
    color: #1f2937;
}

/* Preview Wrapper */
.preview-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.preview-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    color: #9ca3af;
    gap: 12px;
}

.preview-placeholder i {
    font-size: 48px;
    opacity: 0.5;
}

.preview-placeholder p {
    font-size: 15px;
    margin: 0;
}

.email-preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    display: none;
}

.email-preview-frame.active {
    display: block;
}

/* Preview Mode: Mobile */
.preview-wrapper.mobile-mode .email-preview-frame {
    width: 375px;
    margin: 0 auto;
    height: 100%;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
}

/* Template Variables Info */
.template-variables-info {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    user-select: none;
}

.info-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    color: white;
    margin: 0;
}

.btn-collapse {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-collapse:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn-collapse i {
    transition: transform 0.3s ease;
}

.info-header.collapsed .btn-collapse i {
    transform: rotate(-90deg);
}

.variables-content {
    max-height: 400px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.variables-content.collapsed {
    max-height: 0;
}

.variables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    padding: 20px;
}

.variable-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.variable-item:hover {
    background: #eff6ff;
    border-color: #667eea;
    transform: translateY(-2px);
}

.variable-item code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    font-size: 13px;
    color: #667eea;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    border: 1px solid #e5e7eb;
}

.variable-item span {
    font-size: 12px;
    color: #6b7280;
}

/* Success/Error Messages */
.template-message {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.template-message.success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.template-message.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.template-message.info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.template-message i {
    font-size: 18px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .editor-preview-container {
        grid-template-columns: 1fr;
    }
    
    .editor-section,
    .preview-section {
        height: 500px;
    }
    
    .variables-grid {
        grid-template-columns: 1fr;
    }
}

/* Loading State */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.loading-spinner-small {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f4f6;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Syntax Highlighting (basic) */
.email-code-editor.highlighted {
    background: #1e1e1e;
    color: #d4d4d4;
}

/* Code Editor Scrollbar */
.email-code-editor::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.email-code-editor::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.email-code-editor::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 5px;
}

.email-code-editor::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

/* Button animations */
.btn-primary:hover,
.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:active,
.btn-secondary:active {
    transform: translateY(0);
}

