/* ============ CSS VARIABLES ============ */
:root {
    /* Colors */
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #eff6ff;
    --color-danger: #dc2626;
    --color-danger-light: #fee;
    --color-success: #10b981;
    --color-warning: #f97316;

    /* Grays */
    --color-text: #333;
    --color-text-light: #666;
    --color-text-lighter: #999;
    --color-bg: #f5f5f5;
    --color-bg-hover: #f5f5f5;
    --color-bg-active: #eff6ff;
    --color-border: #e0e0e0;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 50%;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);

    /* Transitions */
    --transition-base: 0.2s;
    --transition-slow: 0.3s;
    /* Sidebar width used by JS/CSS to align elements like minimized emails */
    --sidebar-width: 256px;
}

/* ============ DARK THEME ============ */
:root[data-theme="dark"] {
    --color-text: #e0e0e0;
    --color-text-light: #b0b0b0;
    --color-text-lighter: #808080;
    --color-bg: #1a1a1a;
    --color-bg-hover: #2a2a2a;
    --color-bg-active: #1e3a5f;
    --color-border: #404040;
    --color-primary-light: #0f172a;
}

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

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
}

/* ============ COMMON FORM ELEMENTS ============ */
.form-group {
    margin-bottom: 20px;
}

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    background-color: #fff;
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.form-textarea {
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--color-text-light);
}

.container {
    display: flex;
    height: 100%;
    position: relative;
}

body.blur-active .container {
    filter: blur(4px);
    pointer-events: none;
}

.sidebar {
    width: 256px;
    min-width: 200px;
    max-width: 500px;
    background: white;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    flex-shrink: 0;
    transition: transform var(--transition-slow) ease-in-out;
    position: relative;
}

.sidebar-app-info {
    padding: 8px 16px;
    font-size: 11px;
    color: #9ca3af;
    text-align: center;
    margin-top: auto;
    flex-shrink: 0;
}

.sidebar-resizer {
    position: absolute;
    top: 0;
    right: -4px;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    z-index: 101;
}

.sidebar-top-actions {
    display: flex;
    align-items: center;
    padding: 16px;
    gap: 8px;
}

.compose-btn {
    margin: 0;
    flex-grow: 1;
    padding: 12px 16px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    transition: background var(--transition-base);
}

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

#refreshViewBtn {
    padding: 12px;
    box-shadow: none;
    border: 1px solid var(--color-border);
    background: white;
}
#refreshViewBtn:hover {
    background: var(--color-bg-hover);
}

.folders {
    flex-shrink: 0;
    padding: 0 12px;
}

.folder-item {
    padding: 8px 8px 8px 0;
    margin: 2px 0;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: background 0.2s;
    position: relative;
}

.folder-item.important,
.folder-item.starred,
.folder-item.all-unread,
.folder-item.scheduled {
    padding-right: 36px;
}

.folder-item:hover {
    background: var(--color-bg-hover);
}

.folder-item.active {
    background: var(--color-bg-active);
    color: var(--color-primary);
}

.folder-item .folder-icon {
    width: 18px;
    height: 18px;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.folder-item.open > .folder-icon {
    transform: rotate(180deg);
}

.folder-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-name-edit-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.folder-name-input {
    flex: 1;
    min-width: 0;
    border: 1px solid #2563eb;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 14px;
    outline: none;
}

.folder-counts {
    display: flex;
    gap: 4px;
    font-size: 12px;
    cursor: pointer;
}

.account-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.account-counts {
    display: flex;
    gap: 4px;
    font-size: 12px;
    margin-top: 2px;
}

.unread-badge {
    background: var(--color-primary);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
}

.total-count {
    color: #999;
    margin-left: 5px;
}

.folder-actions {
    display: none;
    gap: 4px;
}

.folder-item:hover .folder-actions {
    display: flex;
}

#templatesContainer .folder-item .folder-actions {
    display: flex;
    visibility: hidden;
}
#templatesContainer .folder-item:hover .folder-actions {
    visibility: visible;
}

.more-actions-btn {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.folder-item:hover .more-actions-btn,
.tag-item:hover .more-actions-btn {
    opacity: 1;
    pointer-events: auto;
}

.folder-item.editing .more-actions-btn,
.tag-item.editing .more-actions-btn {
    opacity: 0;
    pointer-events: none;
}

.folder-action-btn {
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    /*height: 28px;*/
    width: 20px;
    color: var(--color-text-light);
    transition: background-color 0.2s, color 0.2s;
}

/*.folder-action-btn:hover {
    background-color: var(--color-bg-hover);
    color: var(--color-text);
}

:root[data-theme="dark"] .folder-action-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}*/

.subfolder {
    margin-left: 24px;
}

.add-folder-btn {
    margin: 8px 12px;
    padding: 8px 12px;
    border: 1px dashed #e0e0e0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s;
}

.add-folder-btn:hover {
    background: var(--color-bg-hover);
}

.tags-section {
    padding: 8px 12px;
    border-top: 1px solid #e0e0e0;
}

.tags-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    color: #666;
    font-weight: 600;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.tags-header:hover {
    background: #f5f5f5;
}

.tags-header .chevron-icon {
    transition: transform 0.2s;
}

.tags-header.open .chevron-icon {
    transform: rotate(180deg);
}

.tag-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
    margin: 2px 0;
    position: relative;
}

.tag-item.active {
    background: var(--color-bg-active);
    color: var(--color-primary);
}

.tag-item:hover {
    background: var(--color-bg-hover);
}

.tag-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
}

.tag-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tag-name-edit-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.tag-name-input {
    flex: 1;
    min-width: 0;
    border: 1px solid #2563eb;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13px;
    outline: none;
}

.tag-actions {
    display: none;
    gap: 4px;
    margin-left: auto;
}

.tag-item:hover .tag-actions {
    display: flex;
}

/* Drag and Drop Styles */
.dragging {
    opacity: 0.5;
    background: #eef2ff;
}
.drop-target-sort-above {
    border-top: 2px solid #2563eb;
}
.drop-target-sort-below {
    border-bottom: 2px solid #2563eb;
}
.drop-target-sort-invalid-above {
    border-top: 2px solid #dc2626;
}
.drop-target-sort-invalid-below {
    border-bottom: 2px solid #dc2626;
}
.drop-target-nest {
    background-color: #eff6ff;
    outline: 2px dashed #2563eb;
    outline-offset: -2px;
}
.no-drop {
    background-color: #fee2e2 !important;
    outline: 2px dashed #dc2626 !important;
    cursor: not-allowed;
}
.no-drop * {
    cursor: not-allowed;
}

.settings-btn {
    margin: 16px;
    padding: 10px 16px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
    margin-top: auto;
}

.settings-btn:hover {
    background: var(--color-bg-hover);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    min-width: 0;
}

#emailsList {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.search-bar {
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.menu-btn {
    display: none;
    padding: 8px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 50%;
}

.menu-btn:hover {
    background: #f0f0f0;
}

.search-container {
    flex: 1;
    position: relative;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #f9f9f9;
    width: 100%;
}

.search-input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 14px;
}

.search-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    z-index: 55;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.search-suggestions.active {
    display: block;
}

.suggestion-item {
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
}

.suggestion-item:hover {
    background: #f5f5f5;
}

.filter-btn {
    padding: 8px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: -8px;
}

.filter-btn:hover {
    background: #e0e0e0;
}

.filter-panel {
    display: none;
    margin-top: 12px;
    padding: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: absolute;
    top: 100%;
    left: 16px;
    right: 16px;
    z-index: 50;
}

.filter-panel.active {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-field label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.filter-field input,
.filter-field select {
    padding: 8px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
}

.apply-filters-btn {
    grid-column: 1 / -1;
    padding: 10px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.selection-toolbar {
    display: none;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.selection-toolbar.active {
    display: flex;
}

.selection-count {
    font-size: 14px;
    color: #666;
    margin-right: 8px;
}

.toolbar-btn {
    padding: 6px 8px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    transition: background 0.2s;
}

.toolbar-btn:hover {
    background: #e0e0e0;
}

.separator {
    width: 1px;
    height: 20px;
    background: #e0e0e0;
    margin: 0 4px;
}

.emails-list {
    flex: 1;
    overflow-y: auto;
}

.pinned-separator {
    margin-top: 15px;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
}

.email-item {
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
    display: flex;
    gap: 12px;
}

.email-item:hover {
    background: #f9f9f9;
}

.email-item.unread {
    border-left: 3px solid #3b82f6e6;
    font-weight: 600;
}

/* Visual container for expanded thread: separates thread from other emails */
.thread-block {
    margin: 8px 0;
    padding: 0px 0;
    border: 1px solid #ddd;
    border-left-width: 3px;
    /*border-radius: 12px;
    overflow: hidden;*/
    position: relative;
    transition: box-shadow var(--transition-base),
        background var(--transition-base);
}

.thread-block .email-item {
    background: white;
    margin-left: -3px;
}
.thread-block.opened {
    box-shadow: var(--shadow-sm);
}

/* Each child in an expanded thread: header + open body wrapper */
.thread-child {
    border-bottom: 1px solid #e0e0e0;
    border-left: 3px solid #ddd;
    padding: 16px 24px;
    background: transparent;
    margin-left: 24px;
}

.thread-child.unread {
    border-left: 3px solid #3b82f6e6;
}

.thread-child .email-item {
    margin: 0;
    padding: 0;
    border: none;
}

.thread-child .email-full-view {
    margin: 16px 0 0 0;
    padding: 0 0 8px 0;
    border: none;
    border-top: 1px solid #e0e0e0;
}

.email-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
}

.email-avatar.selected::after {
    content: "✓";
    position: absolute;
    inset: 0;
    background: rgba(37, 99, 235, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.email-content {
    flex: 1;
    min-width: 0;
}

.email-header {
    display: flex;
    align-items: center;
    gap: 0; /* Убран gap чтобы скрытые элементы не занимали место */
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.email-header > * {
    margin-right: 8px;
}

.email-header > *:last-child {
    margin-right: 0;
}

/* Дата прижимается вправо */
.email-header .email-date {
    margin-left: auto;
    margin-right: 0;
}

.email-sender {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.email-address {
    font-size: 13px;
    color: #666;
    display: none;
}

.email-date {
    font-size: 12px;
    color: #999;
    white-space: nowrap;
}

.email-subject {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.thread-folder-badge {
    display: inline-block;
    background: #e0e0e0;
    color: #666;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.email-preview {
    font-size: 13px;
    color: #888;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Строка с темой и тегами */
.email-subject-line {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    padding: 8px; /* Место для свечения тегов */
    margin-left: -8px;
    margin-top: -8px;
}

.email-subject-line .email-subject {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
    max-width: 70%;
}

/* Превью в строке с темой */
.email-subject-line .email-preview-inline {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    color: #888;
    font-size: 13px;
}

/* Разделитель между темой и превью */
.email-subject-line .email-preview-inline::before {
    content: "»";
    margin: 0 6px;
    color: #bbb;
    font-weight: bold;
    position: relative;
    top: -1px;
}

/* Контейнер для тегов в строке темы */
.email-tags-inline {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    padding-left: 4px; /* Место для свечения первого тега */
    margin-left: -4px;
}

/* Старый контейнер для тегов (для обратной совместимости) */
.email-tags {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.email-tag {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    transition: box-shadow 0.2s;
    gap: 4px;
}

.email-tag:hover {
    box-shadow: 0 0 8px currentColor;
}

/* Теги с кнопкой удаления в открытом письме */
.email-tag-removable {
    padding-right: 4px;
}

.tag-remove-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
    color: inherit;
}

.tag-remove-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
}

.icon-xs {
    width: 10px;
    height: 10px;
}

.thread-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #e0e0e0;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    margin-left: 6px;
}

.thread-toggle-btn span {
    position: relative;
    top: -1px;
}

.thread-toggle-btn:hover {
    background: #d0d0d0;
}

.email-full-view {
    display: none;
    padding: 0 24px 24px 24px;
    background: #fafafa;
    margin-left: 24px;
    border-left: 2px solid #ddd;
    border-bottom: 1px solid #e0e0e0;
}

.email-full-view.active {
    display: block;
}

.email-toolbar {
    padding: 12px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
}

/* Кнопка перевода в toolbar письма */
.email-toolbar .translate-btn {
    /*background: linear-gradient(to right, #a855f7, #ec4899);
    color: white;*/
    border-radius: 6px;
    transition: all 0.15s ease;
}

.email-toolbar .translate-btn:hover {
    background: linear-gradient(to right, #9333ea, #db2777);
    color: white;
}

.email-full-header {
    margin-bottom: 24px;
    display: flex;
    gap: 16px;
}

.email-full-sender {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.email-full-meta {
    font-size: 13px;
    color: #666;
}

.email-full-meta-recipients {
    font-size: 13px;
    color: #666;
    margin-top: 4px;
}

.email-full-subject {
    font-size: 20px;
    font-weight: 600;
    margin: 16px 0;
}

.email-full-body {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 24px;
    word-wrap: break-word;
}

/* Заголовок перевода письма */
.email-translation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    margin-bottom: 16px;
    background: linear-gradient(to right, #faf5ff, #fdf2f8);
    border: 1px solid #d8b4fe;
    border-radius: 8px;
}

.email-translation-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #7c3aed;
}

.email-translation-header .btn {
    padding: 6px 12px;
    font-size: 12px;
}

.attachments-section {
    margin-bottom: 16px;
    /*padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;*/
}

.attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachments-download-all {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #0066cc;
    background: none;
    border: 1px solid #0066cc;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.attachments-download-all:hover {
    background: #0066cc;
    color: #fff;
}

.attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    cursor: default;
    transition: all 0.2s;
    max-width: 300px;
}

.attachment-item:hover {
    background: #f0f0f0;
    border-color: #d0d0d0;
}

.attachment-link {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.attachment-link:hover {
    opacity: 0.8;
}

.attachment-filename {
    font-size: 13px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #0066cc;
    cursor: pointer;
}

.attachment-link:hover .attachment-filename {
    text-decoration: underline;
}

.attachment-size {
    font-size: 11px;
    color: #999;
    margin-right: 4px;
}

.attachment-download-btn {
    background: none;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    color: #666;
    transition: all 0.2s;
}

.quoted-text {
    border-left: 2px solid #ccc;
    padding-left: 10px;
    margin-top: 16px;
    color: #666;
    font-size: 13px;
}
.quoted-text blockquote {
    margin: 0;
    padding: 0;
    word-break: break-all;
}

.compose-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.compose-modal.active {
    display: flex;
}

.compose-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
    min-width: 500px;
    min-height: 500px;
    position: relative;
}

.compose-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.compose-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.compose-action-btn {
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.compose-action-btn:hover {
    background: #f0f0f0;
}

.compose-header-actions {
    display: flex;
    gap: 8px;
}

.compose-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.compose-fields {
    padding: 12px 24px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.compose-field {
    display: flex;
    align-items: center;
    padding: 8px 0;
    gap: 12px;
    flex-wrap: wrap;
}

.compose-field label {
    width: 80px;
    font-size: 14px;
    color: #666;
    flex-shrink: 0;
}

.compose-field input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    min-width: 150px;
}

.show-cc-btn {
    padding: 6px 12px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    margin-left: 12px;
    flex-shrink: 0;
}

.recipient-area-container {
    flex: 1;
    position: relative;
    min-width: 150px;
}

.recipient-area {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: text;
}

.recipient-area:focus-within {
    border-color: #2563eb;
}

.recipient-pill {
    background-color: #eef2ff;
    color: #4338ca;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.recipient-pill-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.2;
}

.recipient-name {
    font-size: 12px;
    font-weight: 600;
    color: #1e1b4b;
}

.recipient-email {
    font-size: 11px;
    color: #1f2937;
    opacity: 0.8;
    cursor: pointer;
}

.recipient-pill-remove {
    cursor: pointer;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #d1d5db;
    color: #4b5563;
}
.recipient-pill-remove:hover {
    background-color: #9ca3af;
    color: white;
}

.recipient-error-message {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #fee2e2;
    color: #dc2626;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    margin-top: 4px;
    border: 1px solid #fca5a5;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.15);
    z-index: 1000;
    animation: slideDown 0.2s ease-out;
}

.temporary-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.95);
    color: white;
    font-size: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 15000;
}

.temporary-notification.visible {
    opacity: 1;
    transform: translateY(0);
}

.recipient-error-message.show {
    display: block !important;
}

.recipient-input {
    border: none;
    outline: none;
    flex-grow: 1;
    min-width: 120px;
    font-size: 14px;
    padding: 2px;
    background: transparent;
}

.recipient-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    z-index: 1015;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
}
.recipient-suggestions .suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
}
.recipient-suggestions .suggestion-item:hover,
.recipient-suggestions .suggestion-item.active {
    background-color: #f5f5f5;
}
.recipient-suggestions .suggestion-item-name {
    font-weight: 500;
}
.recipient-suggestions .suggestion-item-email {
    font-size: 12px;
    color: #666;
    margin-left: 8px;
}

.compose-editor {
    padding: 12px 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
}

.editor-toolbar {
    padding: 8px;
    border: 1px solid #e0e0e0;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    display: flex;
    gap: 4px;
    background: #f9f9f9;
    flex-wrap: wrap;
    align-items: center;
}

.editor-btn {
    padding: 6px 8px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.editor-btn:hover {
    background: #e0e0e0;
}

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

.editor-btn.disabled,
.editor-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

#htmlModeLabel {
    font-size: 11px;
    margin-left: 4px;
    font-weight: 500;
}

.language-select {
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    margin-left: 4px;
}

.editor-content-wrapper {
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    background: white;
    resize: vertical;
    overflow: auto;
    min-height: 200px;
    flex: 1;
    margin-bottom: 12px;
}

/* Внутренний контейнер для flex-выравнивания колонок */
.editor-columns {
    display: flex;
    flex-direction: row;
    min-height: 100%;
}

/* Колонка редактора письма */
.editor-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.editor-column-header {
    padding: 8px 12px;
    font-weight: 600;
    font-size: 13px;
    display: none; /* Скрыт по умолчанию */
    justify-content: space-between;
    align-items: center;
    color: #374151;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
    flex-shrink: 0;
    height: 45px; /* Фиксированная высота для синхронизации */
    box-sizing: border-box;
}

/* Показывать заголовок редактора только когда панель перевода активна */
.editor-content-wrapper:has(.translation-panel.active) .editor-column-header {
    display: flex;
}

.editor-column-header span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.editor-content {
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    outline: none;
    flex: 1;
}

/* ============ TRANSLATION PANEL (бок о бок с редактором) ============ */
.translation-panel {
    display: none;
    flex: 1;
    min-width: 250px;
    border-left: 1px solid #e0e0e0;
    /*background: linear-gradient(to bottom right, #faf5ff, #fdf2f8);*/
    flex-direction: column;
}

.translation-panel.active {
    display: flex;
}

.translation-panel-header {
    padding: 8px 12px;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #374151;
    border-bottom: 1px solid #e0e0e0;
    background: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
    min-height: 37px; /* Фиксированная высота для синхронизации */
    box-sizing: border-box;
}

.translation-panel-header span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.translation-panel-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.translation-panel-header .editor-btn {
    padding: 4px;
    border-radius: 4px;
    background: transparent;
}

.translation-panel-header .editor-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.translation-panel-content {
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    flex: 1;
    color: var(--color-text);
}

/* На маленьких экранах - вертикальное расположение */
@media (max-width: 800px) {
    .editor-content-wrapper {
        flex-direction: column;
        overflow: visible;
    }

    .editor-column {
        overflow-y: auto;
        max-height: 50vh;
    }

    .translation-panel {
        width: 100%;
        max-width: 100%;
        min-width: auto;
        border-left: none;
        border-top: 1px solid #e0e0e0;
        max-height: 40vh;
        overflow-y: auto;
    }

    .translation-panel-content {
        overflow-y: visible;
    }
}

/* Блок для основного текста письма (невидимая обертка) */
.editor-content .email-body {
    display: block;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
}

/* Блок подписи */
.editor-content .email-signature {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
    color: var(--color-text-light);
}

/* Блок цитируемого текста */
.editor-content .quoted-text {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
    color: var(--color-text-lighter);
}

/* ============ AI ASSISTANT PANEL ============ */
.assistant-panel {
    display: none;
    border: 1px solid #d8b4fe; /* purple-300 */
    border-radius: 8px;
    background: linear-gradient(
        to bottom right,
        #faf5ff,
        #fdf2f8
    ); /* purple-50 → pink-50 */
    margin-bottom: 12px;
    overflow: hidden;
    flex-shrink: 0;
    max-height: 50vh;
}

.assistant-panel.active {
    display: block;
}

.assistant-header {
    padding: 12px 12px 6px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #374151; /* gray-700 */
}

.assistant-header span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.assistant-header span i,
.assistant-header span svg {
    color: #9333ea; /* purple-600 */
}

.assistant-header .editor-btn {
    padding: 4px;
    border-radius: 4px;
    background: transparent;
}

.assistant-header .editor-btn:hover {
    background: white;
}

.assistant-content {
    padding: 6px 12px 12px;
    overflow-y: auto;
    max-height: calc(50vh - 50px);
}

.assistant-response-box {
    padding: 12px;
    background: white;
    border: 1px solid #e9d5ff; /* purple-200 */
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.5;
    min-height: 60px;
    resize: vertical;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    color: #4b5563; /* gray-600 */
}

.ai-prompts {
    margin-bottom: 12px;
}

.ai-prompts-header {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #4b5563; /* gray-600 */
}

#aiPromptsContainer {
    max-height: 160px;
    overflow-y: auto;
}

.ai-prompt-item {
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.15s ease;
    background: white;
    border: 1px solid #e5e7eb; /* gray-200 */
    font-size: 13px;
}

.ai-prompt-item:hover {
    background: #f3e8ff; /* purple-100 */
    border-color: #d8b4fe; /* purple-300 */
}

.ai-prompt-item-text {
    flex-grow: 1;
    color: #374151; /* gray-700 */
}

.ai-prompt-actions {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.ai-prompt-actions button {
    padding: 4px;
    border-radius: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #6b7280; /* gray-500 */
    transition: background 0.15s ease;
    width: 24px;
}

.ai-prompt-actions button:hover {
    background: white;
}

/* Кнопка создать промт */
.ai-prompts .btn-secondary {
    border: 2px dashed #d8b4fe; /* purple-300 */
    color: #9333ea; /* purple-600 */
    background: transparent;
}

.ai-prompts .btn-secondary:hover {
    background: white;
}

.ai-custom-input {
    width: 100%;
    min-height: 70px;
    padding: 12px;
    border: 1px solid #d1d5db; /* gray-300 */
    border-radius: 8px;
    resize: none;
    font-size: 13px;
    font-family: inherit;
    margin-bottom: 8px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-custom-input:focus {
    outline: none;
    border-color: #a855f7; /* purple-500 */
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

.assistant-actions {
    display: flex;
    gap: 8px;
}

/* Кнопка отправить в AI панели - градиент */
.assistant-actions .btn-primary {
    background: linear-gradient(
        to right,
        #a855f7,
        #ec4899
    ); /* purple-500 → pink-500 */
    border: none;
    color: white;
    transition: all 0.15s ease;
}

.assistant-actions .btn-primary:hover {
    background: linear-gradient(
        to right,
        #9333ea,
        #db2777
    ); /* purple-600 → pink-600 */
}

/* Кнопка ИИ в тулбаре редактора */
.editor-btn.ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(to right, #a855f7, #ec4899);
    color: white;
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.editor-btn.ai-btn:hover {
    background: linear-gradient(to right, #9333ea, #db2777);
}

.editor-btn.ai-btn i,
.editor-btn.ai-btn svg {
    width: 16px;
    height: 16px;
}

.compose-actions {
    padding: 12px 24px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============ BUTTON STYLES ============ */
/* Base button styles - используется в index.html и auth страницах */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: opacity var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn:hover:not(:disabled) {
    opacity: 0.9;
}

.btn:disabled {
    background-color: var(--color-border);
    cursor: not-allowed;
    opacity: 0.7;
}

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

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

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

.btn-warning {
    background: #fbbf24;
    color: #78350f;
    font-weight: 500;
}

.btn-warning:hover {
    background: #f59e0b;
    color: #78350f;
}

.btn-success {
    background: #10b981;
    color: white;
    font-weight: 500;
}

.btn-success:hover {
    background: #059669;
    color: white;
}

.btn-info {
    background: #3b82f6;
    color: white;
    font-weight: 500;
}

.btn-info:hover {
    background: #2563eb;
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.btn-outline:hover {
    background-color: var(--color-bg-hover);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

:root[data-theme="dark"] .btn-outline {
    border-color: #404040;
    color: var(--color-text);
}

:root[data-theme="dark"] .btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--color-primary);
}

.split-btn-container {
    display: flex;
}
.split-btn-main {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.split-btn-arrow {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    padding: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
}
.split-btn-left {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    padding: 10px;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 11px;
    min-width: 45px;
}
.split-btn-right {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}
/* When Auto button is hidden, make save button fully rounded */
.split-btn-right.standalone {
    border-radius: 6px;
}

#blurOverlay {
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 1039;
    display: none;
}
#blurOverlay.active {
    display: block;
}

#scheduleSendContainer {
    position: absolute;
    z-index: 1040;
    display: none;
    gap: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}
#scheduleSendContainer.active {
    display: flex;
}
#scheduleSendContainer #sendOptionsDropdown {
    position: static;
    display: block;
    border: none;
    box-shadow: none;
    border-radius: 0;
}
#customDateTimePicker {
    width: 280px;
    font-size: 13px;
    display: none;
    flex-direction: column;
    border-left: 1px solid #e0e0e0;
    justify-content: space-between;
}
#customDateTimePicker.active {
    display: flex;
}

.settings-view {
    display: none;
    height: 100%;
    position: relative;
    z-index: 95;
}

.settings-view.active {
    display: flex;
}

.settings-sidebar {
    width: 200px;
    border-right: 1px solid #e0e0e0;
    padding: 16px;
    flex-shrink: 0;
}

.settings-category {
    padding: 10px 12px;
    margin: 4px 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.settings-category:hover {
    background: #f5f5f5;
}

.settings-category.active {
    background: #eff6ff;
    color: #2563eb;
}

.settings-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.settings-section {
    display: none;
}

.settings-section.active {
    display: block;
}

.settings-section h2 {
    font-size: 24px;
    margin-bottom: 24px;
}

.setting-item {
    margin-bottom: 24px;
}

.setting-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.setting-input,
.setting-select,
.setting-textarea {
    width: 100%;
    max-width: 400px;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
}

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

.toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    background: #ccc;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-switch.active {
    background: #2563eb;
}

.toggle-switch::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: left 0.3s;
}

.toggle-switch.active::after {
    left: 26px;
}

.settings-actions {
    margin-top: 32px;
    display: flex;
    gap: 12px;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.modal-header.with-icon {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-body {
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.dropdown {
    position: absolute;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 10001;
    min-width: 200px;
    padding: 4px;
    display: none;
}

.dropdown.active {
    display: block;
}

.dropdown-item {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.dropdown-item.has-flyout::after {
    content: "›";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    font-size: 16px;
}

.dropdown-item:hover {
    background: #f5f5f5;
}

.dropdown-item.active {
    background: #eff6ff;
    font-weight: 500;
}

.dropdown-item.active .tag-color {
    outline: 2px solid currentColor;
}

.flyout-menu {
    position: absolute;
    left: 100%;
    top: -8px;
    display: none;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 10002;
    min-width: 200px;
    padding: 8px;
}

.dropdown-item:hover > .flyout-menu {
    display: block;
}

.dropdown-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 4px 0;
}

.color-picker {
    display: none;
    position: absolute;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 10001;
    padding: 12px;
}

.color-picker.active {
    display: block;
}

/* Сетка цветов в палитре (4 столбца) */
.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: #333;
}

.color-option.palette-button {
    background: white;
    border: 2px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.color-option.palette-button:hover {
    border-color: #666;
}

.color-option.palette-button .internal-color-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    z-index: 2;
}

.color-option.palette-button .palette-icon {
    position: relative;
    z-index: 1;
    color: #666;
    width: 16px;
    height: 16px;
    pointer-events: none;
}

/* Модальное окно подтверждения цвета */
.color-picker-modal {
    position: fixed;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 12px;
    z-index: 10003;
    min-width: 200px;
    pointer-events: auto;
}

.color-picker-modal-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.color-picker-modal-preview .internal-color-input {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 2px solid #e0e0e0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-appearance: none;
    appearance: none;
}

.color-picker-modal-preview
    .internal-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: inherit;
}

.color-picker-modal-preview .internal-color-input::-webkit-color-swatch {
    border: none;
    border-radius: inherit;
}

.color-picker-modal-preview .internal-color-input::-moz-color-swatch {
    border: none;
    border-radius: inherit;
}

.color-picker-modal-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.color-option-confirm-btn {
    padding: 6px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.color-option-confirm-btn.cancel {
    background: #f5f5f5;
    color: #333;
}

.color-option-confirm-btn.cancel:hover {
    background: #e8e8e8;
}

.color-option-confirm-btn.apply {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.color-option-confirm-btn.apply:hover {
    background: #2563eb;
}

#manageSignaturesModal .modal-content {
    max-width: 700px;
}
.signatures-manager {
    display: flex;
    gap: 16px;
    min-height: 300px;
    flex-direction: column;
}
.signatures-list {
    width: 100%;
    border-right: none;
    padding-right: 0;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 16px;
}
.signature-item {
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 4px;
}
.signature-item.active {
    background: #eff6ff;
}
.signature-editor {
    flex: 1;
}
.signature-editor .setting-textarea {
    height: 150px;
}
.signature-editor-modern {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hidden {
    display: none !important;
}

.icon-sm {
    width: 16px;
    height: 16px;
}

/* ============ ИКОНКИ ФЛАГОВ ПИСЕМ ============ */

/* Иконка звезды (starred) - скрыта по умолчанию, видна при hover */
.email-star-icon {
    cursor: pointer;
    color: #aaa;
    transition: color 0.2s, fill 0.2s, width 0.15s, margin 0.15s;
    width: 0;
    overflow: hidden;
    margin-right: 0;
}

.email-item:hover .email-star-icon,
.email-star-icon.starred-icon {
    width: 16px;
    margin-right: 8px;
}

.toolbar-btn .email-star-icon {
    width: 16px;
    margin-right: 0;
}

.email-star-icon:hover {
    color: #fbbf24;
}

.email-star-icon.starred-icon {
    color: #fbbf24;
    fill: #fbbf24;
}

/* Иконка флажка (important) - скрыта по умолчанию, видна при hover */
.email-flag-icon {
    cursor: pointer;
    color: #aaa;
    transition: color 0.2s, fill 0.2s, width 0.15s, margin 0.15s;
    width: 0;
    overflow: hidden;
    margin-right: 0;
}

.email-item:hover .email-flag-icon,
.email-flag-icon.flagged-icon {
    width: 16px;
    margin-right: 8px;
}

.toolbar-btn .email-flag-icon {
    width: 16px;
    margin-right: 0;
}

.email-flag-icon:hover {
    color: #dc2626;
}

.email-flag-icon.flagged-icon {
    color: #dc2626;
    fill: #dc2626;
}

/* Иконка непрочитанности (unread) - скрыта по умолчанию, видна при hover */
.email-unread-icon {
    cursor: pointer;
    color: #aaa;
    transition: color 0.2s, width 0.15s, margin 0.15s;
    width: 0;
    overflow: hidden;
    margin-right: 0;
}

.email-item:hover .email-unread-icon {
    width: 16px;
    margin-right: 8px;
}

/* НЕ делаем видимой если письмо непрочитано (без класса unread-active-icon) */
/* Класс unread-active-icon добавляется когда письмо прочитано - чтобы было видно при hover */

.email-unread-icon:hover {
    color: #3b82f6;
}

/* Иконка удаления - скрыта по умолчанию, видна при hover */
.email-delete-icon {
    cursor: pointer;
    color: #aaa;
    transition: color 0.2s, width 0.15s, margin 0.15s;
    width: 0;
    overflow: hidden;
    margin-right: 0;
}

.email-item:hover .email-delete-icon {
    width: 16px;
    margin-right: 8px;
}

.email-delete-icon:hover {
    color: #dc2626;
}

/* Старый класс для обратной совместимости */
.email-importance-star {
    cursor: pointer;
    color: #aaa;
}

.star-icon {
    color: #fbbf24;
    fill: #fbbf24;
}

.pinned-icon {
    fill: black;
}

/* ============ EMAIL SECURITY ICON ============ */
.email-security-icon {
    cursor: pointer;
    transition: transform 0.2s;
}

.email-security-icon:hover {
    transform: scale(1.15);
}

/* ============ SECURITY DETAILS POPUP ============ */
.security-details-popup {
    position: fixed;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 16px;
    min-width: 320px;
    max-width: 400px;
    z-index: 1000;
    animation: fadeIn 0.2s;
}

:root[data-theme="dark"] .security-details-popup {
    background: #2a2a2a;
    border-color: #404040;
}

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

.security-details-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.security-no-data {
    color: var(--color-text-light);
    font-size: 13px;
    text-align: center;
    padding: 8px 0;
}

.security-server-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--color-primary-light);
    border-radius: var(--radius-md);
    font-size: 12px;
    margin-bottom: 4px;
}

:root[data-theme="dark"] .security-server-info {
    background: #1e3a5f;
}

.security-server-label {
    color: var(--color-text-light);
    font-weight: 500;
}

.security-server-value {
    color: var(--color-text);
    font-weight: 600;
}

.security-check-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

:root[data-theme="dark"] .security-check-item {
    background: #1a1a1a;
}

.security-check-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.security-check-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

.security-check-icon.check-pass {
    background: #d1fae5;
    color: #10b981;
}

:root[data-theme="dark"] .security-check-icon.check-pass {
    background: #065f46;
    color: #10b981;
}

.security-check-icon.check-fail {
    background: #fee;
    color: #dc2626;
}

:root[data-theme="dark"] .security-check-icon.check-fail {
    background: #7f1d1d;
    color: #dc2626;
}

.security-check-icon.check-none {
    background: #e5e7eb;
    color: #9ca3af;
}

:root[data-theme="dark"] .security-check-icon.check-none {
    background: #374151;
    color: #9ca3af;
}

.security-check-title {
    font-weight: 500;
    font-size: 13px;
    color: var(--color-text);
}

.security-check-details {
    font-size: 12px;
    color: var(--color-text-light);
    padding-left: 28px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.overlay.active {
    display: block;
}

/* ============ USER SETTINGS MODAL ============ */
.settings-modal-content {
    min-width: 600px;
}

.settings-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--color-border);
}

.settings-tab {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-light);
    transition: all 0.2s;
}

.settings-tab:hover {
    color: var(--color-text);
    background: var(--color-bg-hover);
}

.settings-tab.active {
    color: #0066cc;
    border-bottom-color: #0066cc;
}

.settings-modal-content .settings-section h3 {
    margin: 0 0 20px;
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
}

.settings-modal-content .toggle-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    padding: 8px 0;
}

.settings-modal-content .toggle-label span {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
}

.settings-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
    margin-top: 24px;
}

.accounts-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.accounts-panel-overlay.active {
    display: block;
    opacity: 1;
}

.accounts-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 360px;
    max-width: 90vw;
    height: 100%;
    background: white;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 2001;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.accounts-panel.active {
    transform: translateX(0);
}

.accounts-panel-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.accounts-panel-title {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
}

.accounts-panel-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    color: #666;
}

.accounts-panel-close:hover {
    background: #f5f5f5;
}

.accounts-panel-close:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.accounts-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.account-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    position: relative;
}

.account-card:hover {
    border-color: #2563eb;
    background: #f8faff;
}

.account-card:hover .account-actions {
    opacity: 1;
}

.account-card:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.account-card.active {
    border-color: #2563eb;
    background: #eff6ff;
}

.account-card.active::after {
    /* content: '✓'; Временно отключил галку аккаунта */
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: #2563eb;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.account-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    background: #fee;
    color: #dc2626;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.account-remove-btn:hover {
    background: #dc2626;
    color: white;
}

.account-remove-btn:focus {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

.account-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.account-edit-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e0f2fe;
    color: var(--color-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.account-edit-btn:hover {
    background: #0284c7;
    color: white;
}

.account-edit-btn:focus {
    outline: 2px solid #0284c7;
    outline-offset: 2px;
}

.account-card.active .account-remove-btn {
    display: none !important;
}

.account-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 18px;
}

.account-info {
    flex: 1;
    min-width: 0;
}

.account-name {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-email {
    font-size: 13px;
    color: var(--color-text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.add-account-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px;
    padding: 10px 16px;
    border: 1px dashed var(--color-border);
    border-radius: 6px;
    background: transparent;
    transition: background 0.2s;
    width: calc(100% - 32px);
    box-sizing: border-box;
    color: var(--color-text-light);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.add-account-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-bg-hover);
}

.add-account-btn:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.account-switcher-btn {
    padding: 8px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.account-switcher-btn:hover {
    background: var(--color-bg-hover);
}

.account-switcher-btn:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.accounts-panel-footer {
    padding: 16px;
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

.panel-settings-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.panel-setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.panel-setting-item:hover {
    background: #f0f0f0;
}

.panel-setting-item:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.panel-setting-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #333;
}

.panel-theme-language {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f9f9f9;
    border-radius: 8px;
    margin-bottom: 8px;
}

.panel-theme-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    color: #666;
}

.panel-theme-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.panel-theme-btn:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.panel-language-select {
    flex: 1;
    min-width: 80px;
    padding: 6px 10px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
}

.panel-language-select:hover {
    border-color: #2563eb;
}

.panel-language-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.panel-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: #fee;
    color: #dc2626;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
    width: 100%;
    margin-top: 8px;
}

.panel-logout-btn:hover {
    background: #dc2626;
    color: white;
}

.panel-logout-btn:focus {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

.settings-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2001;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.settings-overlay.active {
    display: block;
    opacity: 1;
}

.mydrawer-settings-blur {
    filter: blur(6px);
    pointer-events: none;
    transition: filter 0.3s ease;
}

.mydrawer-settings-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 2002;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
}

.mydrawer-settings-modal.active {
    display: flex;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

.mydrawer-settings-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9f9f9;
}

.mydrawer-settings-title {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
}

.mydrawer-settings-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    color: #666;
}

.mydrawer-settings-close:hover {
    background: #e0e0e0;
}

.mydrawer-settings-close:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.mydrawer-settings-body {
    display: flex;
    height: calc(85vh - 140px);
    overflow: hidden;
}

.mydrawer-settings-sidebar {
    width: 200px;
    border-right: 1px solid #e0e0e0;
    padding: 16px;
    flex-shrink: 0;
    overflow-y: auto;
    background: #fafafa;
}

.mydrawer-settings-category {
    padding: 10px 12px;
    margin: 4px 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    color: #333;
}

.mydrawer-settings-category:hover {
    background: #f0f0f0;
}

.mydrawer-settings-category.active {
    background: #eff6ff;
    color: #2563eb;
    font-weight: 500;
}

.mydrawer-settings-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.mydrawer-settings-footer {
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: #f9f9f9;
}

.hamburger-menu-btn {
    position: static;
    top: auto;
    left: auto;
    z-index: auto;
    padding: 12px;
    border: 1px solid #e0e0e0;
    background: white;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    transition: all 0.2s;
    flex-shrink: 0;
}

.hamburger-menu-btn:hover {
    background: #f5f5f5;
}

.hamburger-menu-btn:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

@media (max-width: 992px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
        padding-top: 0;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-resizer {
        display: none;
    }
    .menu-btn {
        display: block;
    }
    .main-content {
        width: 100%;
    }
    .settings-view.active {
        flex-direction: column;
    }
    .settings-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
}

@media (min-width: 993px) {
    .email-address {
        display: inline;
    }
    .signatures-manager {
        flex-direction: row;
    }
    .signatures-list {
        width: 200px;
        border-bottom: none;
        border-right: 1px solid #e0e0e0;
        padding-right: 16px;
        padding-bottom: 0;
    }
}

@media (max-width: 600px) {
    .compose-modal-content {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        resize: none;
        min-width: unset;
        min-height: unset;
    }
    .compose-editor {
        padding: 8px;
    }
    .compose-fields {
        padding: 8px 12px;
    }
    .compose-actions {
        padding: 8px 12px;
        justify-content: space-around;
    }
    .show-cc-btn {
        margin-left: 0;
    }
    .filter-panel.active {
        display: grid;
        grid-template-columns: 1fr;
    }
    .email-item {
        padding: 12px 8px;
    }
    .email-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    .email-item.thread-item {
        margin-left: 24px;
    }
    .email-full-view {
        padding: 16px;
    }
    .accounts-panel {
        width: 100%;
        max-width: 100vw;
    }
    .mydrawer-settings-modal {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: 100vh;
        border-radius: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    .mydrawer-settings-modal.active {
        transform: translate(-50%, -50%) scale(1);
    }
    .mydrawer-settings-body {
        flex-direction: column;
        height: calc(100vh - 140px);
    }
    .mydrawer-settings-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        padding: 12px;
        max-height: 150px;
        overflow-x: auto;
        white-space: nowrap;
    }
    .mydrawer-settings-category {
        display: inline-block;
        margin-right: 8px;
    }
}

/* ============ AUTHENTICATION STYLES ============ */

.auth-container {
    width: 100%;
    max-width: 440px;
}

.auth-box {
    background: white;
    padding: 40px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header .icon {
    width: 48px;
    height: 48px;
    color: var(--color-primary);
    margin-bottom: 12px;
}

.auth-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: #1a1a1a;
}

.auth-header p {
    margin-top: 8px;
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.auth-box .form-group {
    margin-bottom: 20px;
    position: relative;
}

.auth-box .form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.auth-box .input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 0 12px;
    transition: border-color var(--transition-base),
        box-shadow var(--transition-base);
}

.auth-box .input-wrapper:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-box .input-wrapper.invalid {
    border-color: var(--color-danger);
}

.auth-box .input-wrapper.valid {
    border-color: var(--color-success);
}

.auth-box .input-wrapper .icon-sm {
    width: 16px;
    height: 16px;
    color: #999;
}

.auth-box .form-input {
    flex: 1;
    border: none;
    outline: none;
    background: none;
    padding: 12px 0;
    font-size: 14px;
    width: 100%;
}

.validation-message {
    font-size: 12px;
    color: var(--color-danger);
    margin-top: 4px;
    padding-left: 2px;
    display: none;
}

.password-strength {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.strength-item {
    font-size: 12px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.3s ease;
}

.strength-item .icon-sm {
    width: 14px;
    height: 14px;
    color: #aaa;
    transition: color 0.3s ease;
}

.strength-item.valid {
    color: var(--color-success);
}

.strength-item.valid .icon-sm {
    color: var(--color-success);
}

.otp-input-container {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.otp-input {
    width: 45px;
    height: 50px;
    font-size: 20px;
    text-align: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    outline: none;
    transition: border-color var(--transition-base),
        box-shadow var(--transition-base);
    caret-color: var(--color-primary);
}

.otp-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.otp-input.invalid {
    border-color: var(--color-danger);
}

/* Модификатор для auth страниц - добавляет полную ширину и отступ сверху */
.btn.btn-auth {
    width: 100%;
    margin-top: var(--space-xl);
    padding: 12px 20px;
    font-size: 15px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: #666;
}

.auth-footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.auth-footer .icon-sm {
    width: 16px;
    height: 16px;
}

/* Loading indicator for infinite scroll */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #666;
    font-size: 14px;
}

.loading-indicator i {
    animation: spin 1s linear infinite;
}

/* Pagination load button (unified style for thread and regular pagination) */
.pagination-load-btn {
    cursor: pointer;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.pagination-load-btn-content {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #666;
    font-size: 13px;
}

.pagination-load-btn:hover {
    background: #e9ecef;
}

.pagination-load-btn:active {
    background: #dee2e6;
}

/* Page indicator */
.page-indicator {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(37, 99, 235, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 500;
    pointer-events: none;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

/* Responsive auth styles */
@media (max-width: 480px) {
    .otp-input {
        width: 40px;
        height: 45px;
    }
}

/* ============ FORM MESSAGES ============ */
.form-message {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 12px;
}

.form-message.success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.form-message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.form-message.info {
    background: #e0f2fe;
    color: #0c4a6e;
    border: 1px solid #bae6fd;
}

.form-message.warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* Email status badges */
.email-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.email-status-badge:hover {
    opacity: 0.8;
}

.email-status-badge i {
    width: 14px;
    height: 14px;
}

.email-status-badge .status-text {
    white-space: nowrap;
}

.draft-badge {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.queued-badge {
    background: #e0f2fe;
    color: #0c4a6e;
    border: 1px solid #bae6fd;
}

.scheduled-badge {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.sending-badge {
    background: #ddd6fe;
    color: #5b21b6;
    border: 1px solid #c4b5fd;
}

.sending-badge i {
    animation: spin 1s linear infinite;
}

/* Универсальный класс для анимации вращения */
.spinning {
    animation: spin 1s linear infinite;
}

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

.failed-badge {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Email edit button */
.email-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: color 0.2s, background 0.2s;
    border-radius: 4px;
}

.email-edit-btn:hover {
    color: #2563eb;
}

.email-edit-btn i {
    width: 16px;
    height: 16px;
}

/* Draft save status indicator */
.draft-save-status {
    display: inline-block;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.draft-save-status.hidden {
    display: none;
}

.draft-save-status.saving {
    background: #e0f2fe;
    color: #0c4a6e;
    animation: pulse 1.5s ease-in-out infinite;
}

.draft-save-status.saved {
    background: #dcfce7;
    color: #166534;
}

.draft-save-status.error {
    background: #fee2e2;
    color: #991b1b;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* ============ LOADING INDICATORS ============ */

/* Initial page load spinner - large center spinner */
#initialLoadingSpinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease-out;
}

#initialLoadingSpinner.hidden {
    opacity: 0;
    pointer-events: none;
}

.initial-spinner-icon {
    /* Используем старый селектор, внутри будет SVG с классами initial-spinner-core/initial-spinner-branch/initial-spinner-particle */
    width: 200px;
    height: 200px;
    position: relative;
}

/* Spinner SVG styling (applies both to main spinner and instances) */
.initial-spinner-icon svg,
#initialLoadingSpinner .initial-spinner-icon svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 8px #00f5ff);
}

.initial-spinner-icon .initial-spinner-particle,
#initialLoadingSpinner .initial-spinner-icon .initial-spinner-particle {
    fill: #8be9fd;
    opacity: 0;
    transform-origin: center;
}

@keyframes fadeGlow {
    0%,
    100% {
        opacity: 0.2;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

.initial-spinner-icon .initial-spinner-core,
#initialLoadingSpinner .initial-spinner-icon .initial-spinner-core {
    fill: none;
    stroke: #8be9fd;
    stroke-width: 2;
    animation: fadeGlow 2s ease-in-out infinite alternate;
}

.initial-spinner-icon .initial-spinner-branch,
#initialLoadingSpinner .initial-spinner-icon .initial-spinner-branch {
    fill: none;
    stroke: #00f5ff;
    stroke-width: 1.2;
    stroke-linecap: round;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: drawBranch 4s ease-in-out infinite;
}

@keyframes drawBranch {
    0% {
        stroke-dashoffset: 100;
        opacity: 0;
    }
    25% {
        opacity: 1;
    }
    50% {
        stroke-dashoffset: 0;
    }
    75% {
        opacity: 1;
    }
    100% {
        stroke-dashoffset: 100;
        opacity: 0;
    }
}

/* Navigation/folder loading bar - top of page */
#navigationLoadingBar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(37, 99, 235, 0.1);
    z-index: 9999;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

#navigationLoadingBar.active {
    opacity: 1;
    visibility: visible;
}

#navigationLoadingBar::before {
    content: "";
    position: absolute;
    top: 0;
    left: -50%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        var(--color-primary) 40%,
        var(--color-primary) 60%,
        transparent
    );
    box-shadow: 0 0 10px var(--color-primary);
    animation: navigationLoadingSlide 1s ease-in-out infinite;
}

@keyframes navigationLoadingSlide {
    0% {
        left: -50%;
    }
    100% {
        left: 100%;
    }
}

/* AI/Translator loading spinner - use same SVG-based spinner but smaller */
.loader-spin {
    display: inline-block;
    width: 24px;
    height: 24px;
    margin: 12px auto;
}

/* Scale SVG inside the small loader */
.loader-spin svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 6px #00f5ff);
}

/* Particles/core/branch for small loader */
.loader-spin .initial-spinner-particle {
    fill: #8be9fd;
    opacity: 0;
    transform-origin: center;
}

.loader-spin .initial-spinner-core {
    fill: none;
    stroke: #8be9fd;
    stroke-width: 1.5;
    animation: fadeGlow 2s ease-in-out infinite alternate;
}

.loader-spin .initial-spinner-branch {
    fill: none;
    stroke: #00f5ff;
    stroke-width: 0.9;
    stroke-linecap: round;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: drawBranch 3.2s ease-in-out infinite;
}

/* Alternative larger version for assistant panels (use slightly bigger size) */
.assistant-response-box .loader-spin {
    width: 40px;
    height: 40px;
    display: inline-block;
}

/* ============ SEND DELAY TIMER ============ */
#sendDelayTimer {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 7px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 6px 20px;
    display: none;
    z-index: 10000;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 140px;
}

#sendDelayTimer.active {
    display: block;
}

#sendDelayTimer:hover {
    background: #f8f9fa;
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

:root[data-theme="dark"] #sendDelayTimer {
    background: #2a2a2a;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

:root[data-theme="dark"] #sendDelayTimer:hover {
    background: #333;
}

/* SVG border animation */
.timer-svg {
    position: absolute;
    top: -1px;
    left: -1px;
    width: calc(100% + 2px);
    height: calc(100% + 2px);
    pointer-events: none;
    overflow: visible;
}

.timer-path {
    fill: none;
    stroke-width: 4;
    stroke-linejoin: miter;
    stroke-linecap: butt;
    stroke-miterlimit: 10;
}

.timer-background {
    stroke: white;
}

:root[data-theme="dark"] .timer-background {
    stroke: #2a2a2a;
}

.timer-progress {
    stroke: var(--color-primary);
    stroke-dasharray: var(--path-length);
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.05s linear;
}

/* Timer content (icon + text) */
.timer-content {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
}

.timer-icon {
    width: 20px;
    height: 20px;
    color: var(--color-text);
    flex-shrink: 0;
}

.timer-label {
    font-size: 14px;
    color: var(--color-text);
    font-weight: 500;
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
}

/* ============ MINIMIZED EMAILS ============ */
.minimized-emails-container {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width, 256px);
    right: 0;
    display: flex;
    gap: 8px;
    padding: 8px;
    z-index: 999;
    pointer-events: none;
}

.minimized-email {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: var(--shadow-md);
    width: 250px;
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    cursor: pointer;
    pointer-events: auto;
    transition: all var(--transition-base);
}

.minimized-email:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.minimized-email-title {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.minimized-email-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.minimized-email-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-base);
}

.minimized-email-btn:hover {
    background-color: var(--color-bg-hover);
}

.minimized-email-btn i {
    width: 14px;
    height: 14px;
}

/* Adjust compose modal positioning when minimized */
.compose-modal-content.minimized {
    display: none !important;
}

/* Adjust compose fullscreen mode to respect sidebar and minimized emails */
.compose-modal-content.fullscreen {
    width: calc(100vw - var(--sidebar-width, 256px)) !important;
    height: calc(100vh - var(--minimized-emails-height, 0px)) !important;
    max-width: none;
    max-height: none;
    /*border-radius: 0;*/
    resize: none;
    position: fixed;
    left: var(--sidebar-width, 256px);
    top: 0;
    margin: 16px;
    width: calc(100vw - var(--sidebar-width, 256px) - 32px) !important;
    height: calc(100vh - var(--minimized-emails-height, 0px) - 32px) !important;
}

/* Dark theme support for minimized emails */
:root[data-theme="dark"] .minimized-email {
    background: #2a2a2a;
    border-color: #404040;
}

:root[data-theme="dark"] .minimized-email-title {
    color: var(--color-text);
}

/* ============ FILE UPLOAD COMPONENT STYLES ============ */

.file-upload-area {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    background-color: var(--color-primary-light);
    transition: all var(--transition-base) ease;
    margin-bottom: 12px;
}

.file-upload-area.drag-over {
    border-color: var(--color-primary);
    background-color: #dbeafe;
}

.file-upload-area.hidden {
    display: none;
}

.file-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: 0;
}

.file-item {
    display: inline-flex;
    align-items: center;
    padding: var(--space-sm);
    background-color: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: all var(--transition-base) ease;
    max-width: 300px;
}

.file-item:hover {
    box-shadow: var(--shadow-sm);
    background-color: #fafafa;
}

.file-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex: 1;
    min-width: 0;
}

.file-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--color-primary);
}

.file-name {
    font-weight: 500;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 12px;
    color: var(--color-text-lighter);
    margin-left: auto;
    white-space: nowrap;
}

.btn-remove {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background-color: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-danger);
    cursor: pointer;
    transition: all var(--transition-base) ease;
}

.btn-remove:hover {
    background-color: var(--color-danger-light);
    color: var(--color-danger);
}

/* Контейнер действий для файла */
.file-actions {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-left: var(--space-md);
}

/* Кнопка скачивания файла */
.btn-download {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background-color: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-primary);
    cursor: pointer;
    transition: all var(--transition-base) ease;
    text-decoration: none;
}

.btn-download:hover {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
}

.upload-error {
    padding: var(--space-md);
    margin-top: var(--space-md);
    background-color: #fee;
    border: 1px solid var(--color-danger);
    border-radius: var(--radius-sm);
    color: var(--color-danger);
    font-size: 13px;
    animation: slideIn 0.3s ease;
}

.upload-error.hidden {
    display: none;
}

.upload-progress {
    padding: var(--space-md);
    margin-top: var(--space-md);
    background-color: #f0f9ff;
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-sm);
}

.upload-progress.hidden {
    display: none;
}

.upload-status {
    display: block;
    font-size: 13px;
    color: var(--color-primary);
    margin-bottom: var(--space-sm);
    font-weight: 500;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: #e0e7ff;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--color-primary);
    transition: width 0.3s ease;
    width: 0%;
}

/* Dark theme support for file upload */
:root[data-theme="dark"] .file-upload-area {
    background-color: rgba(37, 99, 235, 0.1);
    border-color: #404040;
}

:root[data-theme="dark"] .file-upload-area.drag-over {
    border-color: var(--color-primary);
    background-color: rgba(37, 99, 235, 0.2);
}

:root[data-theme="dark"] .file-item {
    background-color: #2a2a2a;
    border-color: #404040;
}

:root[data-theme="dark"] .file-item:hover {
    background-color: #333;
}

:root[data-theme="dark"] .file-name {
    color: var(--color-text);
}

:root[data-theme="dark"] .upload-error {
    background-color: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.3);
}

:root[data-theme="dark"] .upload-progress {
    background-color: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.3);
}

:root[data-theme="dark"] .progress-bar {
    background-color: rgba(37, 99, 235, 0.1);
}

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

/* ============ CONTACTS MODULE ============ */

.contacts-container {
    display: flex;
    gap: var(--space-lg);
    height: 70vh;
    min-height: 500px;
}

.contacts-sidebar {
    width: 250px;
    flex-shrink: 0;
    border-right: 1px solid var(--color-border);
    padding-right: var(--space-lg);
    display: flex;
    flex-direction: column;
}

.contacts-sidebar h3 {
    margin: 0 0 var(--space-md) 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.contacts-folders-list {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--space-lg) 0;
    flex: 1;
    overflow-y: auto;
}

.contacts-folders-list .folder-item {
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: background 0.2s;
    position: relative;
    min-height: 32px;
}

.contacts-folders-list .folder-item .folder-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--folder-color, #3b82f6);
}

.contacts-folders-list .folder-item .folder-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contacts-folders-list .folder-item .folder-count {
    font-size: 12px;
    color: var(--color-text-light);
    margin-right: 4px;
}

.contacts-folders-list .folder-item .folder-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.contacts-folders-list .folder-item:hover .folder-actions {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.contacts-folders-list .folder-item:hover {
    background: var(--color-bg-hover);
}

.contacts-folders-list .folder-item.active {
    background: var(--color-bg-active);
    color: var(--color-primary);
}

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

.contacts-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.contacts-search {
    margin-bottom: var(--space-lg);
}

.contacts-search input {
    width: 100%;
}

.contacts-table-wrapper {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: white;
}

:root[data-theme="dark"] .contacts-table-wrapper {
    background: #1a1a1a;
}

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

.contacts-table thead {
    position: sticky;
    top: 0;
    background-color: var(--color-bg);
    z-index: 1;
}

.contacts-table th {
    padding: var(--space-md);
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-text-light);
    border-bottom: 2px solid var(--color-border);
}

.contacts-table th:last-child {
    width: 72px;
    text-align: center;
}

.contacts-table td:last-child {
    text-align: center;
}

.contacts-table td {
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-border);
}

.contacts-table tbody tr:hover {
    background-color: var(--color-bg-hover);
}

.contacts-actions {
    white-space: nowrap;
    text-align: center;
}

.contacts-actions .folder-action-btn {
    display: inline-block;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.contacts-table tbody tr:hover .folder-action-btn {
    opacity: 1;
    pointer-events: auto;
}

.contacts-table th.sortable {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.contacts-table th.sortable:hover {
    background: rgba(59, 130, 246, 0.05);
}

.contacts-table th.sortable.sorted-asc,
.contacts-table th.sortable.sorted-desc {
    color: var(--color-primary);
    font-weight: 600;
}

/* Contact Hoverable */
.contact-hoverable {
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.contact-hoverable:hover {
    opacity: 0.7;
}

/* Contact Popover - в стиле открытого письма */
.contact-popover {
    position: fixed;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 10003;
    min-width: 320px;
    max-width: 400px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    overflow: hidden;
}

.contact-popover.active {
    opacity: 1;
    pointer-events: auto;
}

:root[data-theme="dark"] .contact-popover {
    background: #1a1a1a;
    border-color: #333;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.contact-popover-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: #f9f9f9;
    border-bottom: 1px solid #e0e0e0;
}

:root[data-theme="dark"] .contact-popover-header {
    background: #252525;
    border-bottom-color: #333;
}

.contact-popover-name {
    font-size: 1em;
    font-weight: 600;
    flex: 1;
    color: #1a1a1a;
}

:root[data-theme="dark"] .contact-popover-name {
    color: #e0e0e0;
}

.contact-popover-folder-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 500;
    white-space: nowrap;
}

.contact-popover-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
}

.contact-popover-field {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.9em;
    color: #666;
}

:root[data-theme="dark"] .contact-popover-field {
    color: #999;
}

.contact-popover-field i {
    color: #999;
    margin-top: 2px;
    flex-shrink: 0;
}

:root[data-theme="dark"] .contact-popover-field i {
    color: #666;
}

.contact-popover-field-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.contact-popover-field-label {
    font-size: 0.75em;
    color: #999;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

:root[data-theme="dark"] .contact-popover-field-label {
    color: #666;
}

.contact-popover-field-value {
    word-break: break-word;
    color: #333;
}

:root[data-theme="dark"] .contact-popover-field-value {
    color: #ccc;
}

.contact-copyable {
    cursor: pointer;
}

.contact-copyable:hover {
    opacity: 0.75;
}

.contact-popover-field.highlighted-email {
    background: rgba(37, 99, 235, 0.12);
    padding: 6px 8px;
    border-radius: 10px;
}

:root[data-theme="dark"] .contact-popover-field.highlighted-email {
    background: rgba(37, 99, 235, 0.25);
}

.contact-popover-field-used {
    font-size: 0.7em;
    color: #2563eb;
    margin-left: 6px;
}

.unverified-badge {
    font-size: 0.7em;
    color: #f59e0b;
    margin-left: 6px;
}

:root[data-theme="dark"] .unverified-badge {
    color: #fbbf24;
}

.contact-popover-field-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
}

.contact-popover-field-actions .folder-action-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: #f3f4f6;
    border-radius: 8px;
    color: #1d4ed8;
}

.contact-popover-field-actions .folder-action-btn i {
    width: 16px;
    height: 16px;
}

:root[data-theme="dark"] .contact-popover-field-actions .folder-action-btn {
    background: rgba(255, 255, 255, 0.08);
    color: #93c5fd;
}

.contact-popover-organization {
    font-size: 0.9em;
    color: #666;
    margin-top: 2px;
}

:root[data-theme="dark"] .contact-popover-organization {
    color: #999;
}

.default-badge {
    display: inline-block;
    padding: 2px 6px;
    background-color: var(--color-primary);
    color: white;
    font-size: 0.7em;
    border-radius: 3px;
    margin-left: 4px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
}

.contact-popover-actions {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
}

:root[data-theme="dark"] .contact-popover-actions {
    background: #252525;
    border-top-color: #333;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--color-text-light);
}

.pagination-buttons {
    display: flex;
    gap: var(--space-sm);
}

.pagination-btn {
    min-width: 36px;
    padding: var(--space-sm) var(--space-md);
}

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

.contact-edit-form,
.folder-edit-form {
    padding: var(--space-lg) 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

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

.form-control {
    width: 100%;
    padding: var(--space-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    transition: border-color var(--transition-base);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.error-message {
    display: block;
    margin-top: var(--space-xs);
    font-size: 0.875rem;
    color: var(--color-danger);
}

.text-center {
    text-align: center;
}

/* Dark Theme для контактов */
:root[data-theme="dark"] .contacts-sidebar {
    border-right-color: #404040;
}

:root[data-theme="dark"] .folder-item:hover {
    background-color: #2a2a2a;
}

:root[data-theme="dark"] .folder-item.active {
    background-color: rgba(37, 99, 235, 0.2);
}

:root[data-theme="dark"] .folder-count {
    background-color: #2a2a2a;
}

:root[data-theme="dark"] .contacts-table-wrapper {
    background-color: #1a1a1a;
    border-color: #404040;
}

:root[data-theme="dark"] .contacts-table thead {
    background-color: #2a2a2a;
}

:root[data-theme="dark"] .contacts-table th,
:root[data-theme="dark"] .contacts-table td {
    border-color: #404040;
}

:root[data-theme="dark"] .contacts-table tbody tr:hover {
    background-color: #2a2a2a;
}

:root[data-theme="dark"] .form-control {
    background-color: #2a2a2a;
    border-color: #404040;
    color: var(--color-text);
}

:root[data-theme="dark"] .pagination {
    border-top-color: #404040;
}

/* Размеры модальных окон */
.modal-custom.modal-small {
    max-width: 400px;
}

.modal-custom.modal-medium {
    max-width: 600px;
}

.modal-custom.modal-large {
    max-width: 95vw;
    width: 1400px;
    max-height: 90vh;
}

.modal-custom-content {
    overflow-y: auto;
    max-height: calc(90vh - 160px);
    padding: var(--space-sm);
}

/* Формы редактирования контактов/папок */
.contact-edit-form .form-group,
.folder-edit-form .form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.contact-edit-form label,
.folder-edit-form label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--color-text);
}

.contact-edit-form .form-control,
.folder-edit-form .form-control {
    width: 100%;
    padding: var(--space-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.938rem;
    transition: border-color var(--transition-base);
}

.contact-edit-form .form-control:focus,
.folder-edit-form .form-control:focus {
    outline: none;
    border-color: var(--color-primary);
}

.contact-edit-form .error-message,
.folder-edit-form .error-message {
    color: var(--color-danger);
    font-size: 0.813rem;
    display: none;
}

.contact-edit-form .error-message:not(:empty),
.folder-edit-form .error-message:not(:empty) {
    display: block;
}

/* Dark theme для форм */
:root[data-theme="dark"] .contact-edit-form .form-control,
:root[data-theme="dark"] .folder-edit-form .form-control {
    background-color: #2a2a2a;
    border-color: #404040;
    color: var(--color-text);
}

:root[data-theme="dark"] .contact-edit-form .form-control:focus,
:root[data-theme="dark"] .folder-edit-form .form-control:focus {
    border-color: var(--color-primary);
}

/* Стили для множественных полей контактов */
.contact-edit-form h4 {
    margin-top: 20px;
    margin-bottom: 15px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 8px;
}

.contact-edit-form h4:first-of-type {
    margin-top: 0;
}

.contact-edit-form .form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.contact-edit-form .form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.detail-field-group {
    padding: 12px;
    background-color: var(--color-background-secondary);
    border-radius: 6px;
    margin-bottom: 10px;
}

:root[data-theme="dark"] .detail-field-group {
    background-color: #2a2a2a;
}

.detail-field-group .form-row {
    align-items: flex-end;
    margin-bottom: 0;
}

.detail-field-group .detail-default {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.detail-field-group button.btn-danger {
    padding: 4px 8px;
    font-size: 1.2rem;
    line-height: 1;
    min-width: auto;
}

.contact-edit-form .form-control.error {
    border-color: var(--color-danger);
}

/* Кастомные radio переключатели */
.custom-radio-toggle {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    color: var(--color-text-secondary);
}

.custom-radio-toggle:hover {
    background-color: var(--color-background-secondary);
}

.custom-radio-toggle.active {
    color: var(--color-primary);
}

.custom-radio-toggle.active:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

:root[data-theme="dark"] .custom-radio-toggle:hover {
    background-color: #2a2a2a;
}

:root[data-theme="dark"] .custom-radio-toggle.active:hover {
    background-color: rgba(59, 130, 246, 0.2);
}

.detail-default-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.btn-icon {
    padding: 6px 8px;
    min-width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: color 0.2s ease;
}

.btn-icon:hover {
    color: var(--color-danger);
    background: transparent;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-border);
}

:root[data-theme="dark"] .modal-title {
    border-bottom-color: #404040;
}

/* Alias Dropdown Styles */
.custom-dropdown {
    position: relative;
    cursor: pointer;
    font-size: 14px;
    -webkit-user-select: none;
    user-select: none;
    display: inline-block;
}

.alias-pill {
    background-color: #eef2ff;
    color: #4338ca;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: background-color 0.2s, border-color 0.2s;
}

.alias-pill:hover {
    background-color: #e0e7ff;
    border-color: #c7d2fe;
}

.alias-pill-name {
    font-weight: 600;
    color: #1e1b4b;
}

.alias-pill-email {
    font-size: 12px;
    color: #4b5563;
    opacity: 0.8;
}

/* Dropdown Options */
.custom-dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 250px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-top: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.custom-dropdown-options.active {
    display: block;
}

.custom-dropdown-option {
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background-color 0.1s;
}

.custom-dropdown-option:last-child {
    border-bottom: none;
}

.custom-dropdown-option:hover {
    background: #f8fafc;
}

.custom-dropdown-option.selected {
    background: #eff6ff;
}

.custom-dropdown-option .alias-name {
    font-weight: 500;
    color: #1e293b;
    font-size: 14px;
}

.custom-dropdown-option .alias-email {
    font-size: 12px;
    color: #64748b;
}
