/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Notification Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem 2rem;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    font-weight: 300;
}

header h1 i {
    margin-right: 0.5rem;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.tab-btn {
    flex: 1;
    padding: 1rem 2rem;
    border: 1px solid #dee2e6;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 1rem;
    color: #6c757d;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    border-radius: 4px 4px 0 0;
}

.tab-btn:hover {
    background: #e9ecef;
    color: #495057;
    text-decoration: none;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: white;
    text-decoration: none;
    border-color: #667eea;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
}

.tab-btn i {
    margin-right: 0.5rem;
}

/* Tab Content */
.tab-content {
    padding: 2rem;
}

.tab-pane {
    display: none;
}

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

/* Email Composer */
.email-composer h2 {
    margin-bottom: 1.5rem;
    color: #495057;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #495057;
}

.form-group.inline {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.form-group.inline label {
    margin-bottom: 0;
    min-width: 150px;
    flex-shrink: 0;
}

.form-group.inline select {
    flex: 1;
}

.form-separator {
    border: none;
    border-top: 2px solid #dee2e6;
    margin: 2rem 0;
}

.template-fields {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 1.5rem;
    margin-top: 1rem;
}

.template-placeholder {
    color: #6c757d;
    font-style: italic;
    text-align: center;
    margin: 0;
}

.template-field {
    margin-bottom: 1rem;
}

.template-field label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #495057;
}

.template-field input,
.template-field textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
}

.template-field textarea {
    min-height: 100px;
    resize: vertical;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input[type="file"] {
    padding: 0.5rem;
    background: #f8f9fa;
    border: 2px dashed #ced4da;
    cursor: pointer;
}

.form-group input[type="file"]:hover {
    border-color: #667eea;
    background: #f0f2ff;
}

/* Initially hide template-dependent fields (only in email tab) */
#email .form-group:not(.template-selector):not(.signature-selector) {
    display: none;
}

/* Email Preview Section */
.email-preview-section {
    margin-top: 2rem;
    display: none;
}

.email-preview-section h3 {
    color: #495057;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.5rem;
}

.email-preview {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 1.5rem;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.preview-placeholder {
    color: #6c757d;
    font-style: italic;
    text-align: center;
    margin: 2rem 0;
}

.email-preview-content {
    font-family: Arial, sans-serif;
    line-height: 1.1;
    color: #333;
}

.email-preview-content .preview-subject {
    font-weight: bold;
    color: #495057;
    margin-bottom: 0.25rem;
    padding-bottom: 0.125rem;
    border-bottom: 1px solid #dee2e6;
}

.email-preview-content .preview-body {
    white-space: pre-wrap;
    margin-bottom: 0.25rem;
}

.email-preview-content .preview-more-info {
    background: #f8f9fa;
    padding: 1rem;
    border-left: 4px solid #667eea;
    margin: 1rem 0;
    font-style: italic;
}

.email-preview-content .preview-signature {
    background: #e8f5e8;
    padding: 1rem;
    border-radius: 4px;
    margin-top: 1rem;
    border-left: 4px solid #28a745;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.25);
}

.form-group select[multiple] {
    height: 120px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

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

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: #6c757d;
    border-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

.btn-primary:disabled:hover {
    background: #6c757d;
    border-color: #6c757d;
    transform: none;
}

/* File Upload System */
.file-upload-container {
    border: 2px dashed #ced4da;
    border-radius: 8px;
    padding: 1rem;
    background: #f8f9fa;
}

.file-list {
    margin-top: 1rem;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    margin: 0.25rem 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.9rem;
}

.file-item .file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.file-item .file-name {
    font-weight: 500;
    color: #495057;
}

.file-item .file-size {
    color: #6c757d;
    font-size: 0.8rem;
}

.file-item .remove-file {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
}

.file-item .remove-file:hover {
    background: #c82333;
}

.file-size-warning {
    margin-top: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
}

.file-size-warning.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.file-size-warning.danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* Template Selector */
.template-selector {
    margin-bottom: 2rem;
    min-height: auto;
    display: block;
}

.template-selector .form-group {
    margin-bottom: 1rem;
}

.dropdowns-container {
    display: flex;
    gap: 2rem;
    align-items: end;
}

.dropdowns-container .form-group.inline {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.template-preview-container {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    min-height: 500px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.template-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 500px;
    color: #6c757d;
    text-align: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    padding: 3rem;
}

.template-preview-placeholder i {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.3;
    color: #667eea;
}

.template-preview-placeholder p {
    font-size: 1.2rem;
    margin: 0;
    font-weight: 500;
    color: #495057;
}

.template-preview-content {
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.template-preview-body.html-content {
    background: white;
    border: 1px solid #dee2e6;
    font-family: inherit;
}

.template-preview-body.html-content * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.template-raw-text {
    background: #ffffff;
    padding: 1rem;
    border: 1px solid #dee2e6;
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: #333;
    line-height: 1.5;
}

.template-raw-text hr {
    border: none;
    border-top: 1px solid #dee2e6;
    margin: 1rem 0;
}

.template-section {
    margin-bottom: 1rem;
}

.template-section h4 {
    color: #495057;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 2px solid #667eea;
    padding-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.template-section h4::before {
    content: '';
    width: 4px;
    height: 20px;
    background: #667eea;
    border-radius: 2px;
}

.template-subject {
    font-weight: 500;
    color: #495057;
    font-size: 0.9rem;
    padding: 0.25rem 0;
    max-height: 40px;
    overflow: hidden;
}

.template-body {
    background: #ffffff;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    white-space: pre-wrap;
    line-height: 1.6;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.9rem;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    position: relative;
}

.template-body::before {
    content: '📄';
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    font-size: 1rem;
    opacity: 0.3;
}

/* Scrollbar styling for template body */
.template-body::-webkit-scrollbar {
    width: 8px;
}

.template-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.template-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.template-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.template-editable-text {
    background: #fff3cd;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border: 1px solid #ffeaa7;
    white-space: pre-wrap;
    line-height: 1.6;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.9rem;
    font-style: italic;
    color: #856404;
    position: relative;
    margin: 1rem 0;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
}

.template-editable-text::before {
    content: '✏️';
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 1rem;
    opacity: 0.5;
}

.template-signature {
    background: #e8f5e8;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border: 1px solid #c3e6c3;
    white-space: pre-wrap;
    line-height: 1.6;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.9rem;
    color: #2d5a2d;
    position: relative;
    margin: 1rem 0 0 0;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
}

.template-signature::before {
    content: '✍️';
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 1rem;
    opacity: 0.5;
}

/* Contacts */
.contacts-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

.contacts-controls input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
}

.contacts-table-container {
    overflow-x: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.contacts-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.contacts-table th,
.contacts-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.contacts-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.contacts-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.contacts-table th.sortable:hover {
    background: #e9ecef;
}

.contacts-table th.sortable i {
    margin-left: 0.5rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.contacts-table th.sortable:hover i {
    opacity: 1;
}

.contacts-table tbody tr:hover {
    background: #f8f9fa;
}

.contacts-table .yes-value {
    color: #28a745;
    font-weight: bold;
}

.contacts-table .no-value {
    color: #dc3545;
    font-weight: bold;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 1.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #495057;
}

.close {
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    color: #6c757d;
}

.close:hover {
    color: #495057;
}

.modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.5rem;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.preview-email {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
}

.preview-header {
    background: #f8f9fa;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    font-size: 0.9rem;
}

.preview-body {
    padding: 1.5rem;
    white-space: pre-wrap;
    line-height: 1.6;
}

/* Loading States */
.loading {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        margin: 0;
        box-shadow: none;
    }
    
    .tab-navigation {
        flex-direction: column;
    }
    
    .tab-btn {
        text-align: center;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .contacts-controls {
        flex-direction: column;
    }
    
    .modal-content {
        width: 95%;
        margin: 2% auto;
    }
}

/* Home Page Styles */
.home-content {
    padding: 2rem 0;
}

.feature-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.feature-card {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.feature-icon {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 1rem;
}

.feature-card h3 {
    color: #495057;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.feature-card p {
    color: #6c757d;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.quick-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 2rem;
    margin-top: 2rem;
}

.quick-info h3 {
    color: #495057;
    margin-bottom: 1rem;
}

.quick-info ol {
    color: #6c757d;
    line-height: 1.8;
}

.quick-info li {
    margin-bottom: 0.5rem;
}

/* 404 Error Page */
.error-page {
    text-align: center;
    padding: 4rem 2rem;
    max-width: 600px;
    margin: 0 auto;
}

.error-icon {
    font-size: 4rem;
    color: #dc3545;
    margin-bottom: 2rem;
}

.error-page h2 {
    color: #495057;
    margin-bottom: 1rem;
    font-size: 2rem;
}

.error-page p {
    color: #6c757d;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.error-actions .btn {
    min-width: 150px;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-muted { color: #6c757d; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* Version Footer */
.version-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 0.75rem 1rem;
    text-align: center;
    margin-top: auto;
    font-size: 0.875rem;
    color: #6c757d;
}

.version-footer p {
    margin: 0;
    font-weight: 500;
}