/* Marked (flagged) message row background - yellow backgrounds removed for cleaner look */

/**
 * Webmailer Custom Styles - Apple iCloud inspiriert
 * Hier können Sie das Aussehen des Webmailers komplett anpassen
 */

/* ========================================
   GRUNDLEGENDES LAYOUT & FARBEN
   ======================================== */

:root {
    /* Farbschema - Passen Sie diese Werte nach Belieben an */
    --primary-color: #007aff;
    --primary-hover: #0051d5;
    --background-color: #f5f5f7;
    --surface-color: #ffffff;
    --border-color: #d1d1d6;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-muted: #86868b;
    --unread-bg: #e8f4fd;
    --hover-bg: #f5f5f5;
    --selected-bg: #e3f2fd;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --group-background-color: #f8f9fb;

    /* Layout-Dimensionen */
    --header-height: 60px;
    --sidebar-width: 260px;
    --maillist-width: 380px;
}

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

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

/* ========================================
   HAUPTCONTAINER
   ======================================== */

.webmailer-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   HEADER
   ======================================== */

.webmailer-header {
    height: var(--header-height);
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: var(--shadow);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    font-size: 18px;
    color: var(--text-primary);
}

.header-logo {
    height: 32px;
    width: auto;
    margin-right: 10px;
    object-fit: contain;
}

.header-center {
    flex: 1;
    max-width: 600px;
    margin: 0 40px;
}


/* Fix for Bootstrap input-group search box */
.search-box {
    /* Let Bootstrap input-group handle layout */
    display: flex;
    align-items: stretch;
    width: 100%;
}

.search-box .input-group-text {
    background-color: var(--background-color);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: 8px 0 0 8px;
    display: flex;
    align-items: center;
    padding-left: 14px;
    padding-right: 10px;
}


.search-box input.form-control {
    border: 1px solid var(--border-color);
    border-left: none;
    border-right: none;
    border-radius: 0;
    background-color: var(--background-color);
    transition: all 0.2s;
    box-shadow: none;
    /* Remove right border only if clear button is present */
}

.search-box input.form-control:not(:last-child) {
    border-right: none;
}

.search-box .search-clear-btn {
    border: 1px solid var(--border-color);
    border-left: none;
    border-radius: 0 8px 8px 0;
    background: var(--background-color);
    color: var(--text-muted);
    transition: background 0.2s, color 0.2s, opacity 0.2s;
    display: flex;
    align-items: center;
    padding-left: 10px;
    padding-right: 14px;
    border-right: 1px solid var(--border-color);
    opacity: 1;
    pointer-events: auto;
}

/* Hide clear button visually but keep layout when input is empty */

.search-box .search-clear-btn[aria-hidden="true"] {
    color: transparent;
    background: var(--background-color);
    cursor: default;
}

.search-box .search-clear-btn[aria-hidden="true"] i {
    opacity: 0;
}

.search-box input.form-control:focus {
    background-color: var(--surface-color);
    border-color: var(--border-color);
    outline: none;
    box-shadow: none;
}

.search-box .search-clear-btn {
    border: 1px solid var(--border-color);
    border-left: none;
    border-radius: 0 8px 8px 0;
    background: var(--background-color);
    color: var(--text-muted);
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    padding-left: 10px;
    padding-right: 14px;
}

.search-box .search-clear-btn:hover {
    background: var(--hover-bg);
    color: var(--primary-color);
}

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

.header-right .btn {
    font-size: 20px;
    padding: 8px;
    border-radius: 8px;
    transition: background-color 0.2s;
}

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

/* Sync Status Badge - hidden by default, shown via JS */
.sync-status-badge {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background-color: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 20px;
    font-size: 13px;
    color: #1976d2;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.3s;
}

.sync-status-badge.visible {
    display: flex;
}

.sync-status-badge:hover {
    background-color: #bbdefb;
    transform: scale(1.02);
}

.sync-status-badge i {
    animation: spin 2s linear infinite;
}

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

    to {
        transform: rotate(360deg);
    }
}

.sync-status-badge.completed i {
    animation: none;
    color: #4caf50;
}

[data-theme="dark"] .sync-status-badge {
    background-color: #1a237e;
    border-color: #3949ab;
    color: #90caf9;
}

[data-theme="eva"] .sync-status-badge {
    background-color: #2a2a3e;
    border-color: #4a4a6e;
    color: #8e9aff;
}

/* Header compose button visibility: hidden by default, visible when sidebar is collapsed */
#composeBtnHeader {
    display: none;
}

.sidebar-collapsed #composeBtnHeader {
    display: inline-flex;
}

/* ========================================
   HAUPTBEREICH
   ======================================== */

.webmailer-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* ========================================
   SIDEBAR
   ======================================== */

.webmailer-sidebar {
    width: var(--sidebar-width);
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Collapsed sidebar state */
.sidebar-collapsed .webmailer-sidebar {
    width: 0 !important;
    min-width: 0 !important;
    border-right: none !important;
    overflow: hidden !important;
}

.sidebar-collapsed .webmailer-maillist {
    border-left: none;
}

.sidebar-header {
    padding: 17.5px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header .btn-primary {
    border-radius: 8px;
    padding: 10px;
    font-weight: 500;
    border: none;
    background-color: var(--primary-color);
    transition: background-color 0.2s;
}

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

/* Smaller variant refinement */
.sidebar-header .btn-sm.btn-primary {
    padding: 6px 10px;
    font-size: 0.875rem;
}

.sidebar-header .btn-sm.btn-primary i {
    font-size: 0.95em;
}

/* Even smaller compact variant */
.sidebar-header .btn-compact {
    padding: 4px 8px !important;
    font-size: 0.82rem !important;
    line-height: 1.1 !important;
}

.sidebar-header .btn-compact i {
    margin-right: 0.35rem !important;
    /* tighter spacing */
    font-size: 0.9em !important;
}

.sidebar-nav {
    padding: 20px 12px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 12px 8px;
    letter-spacing: 0.5px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    margin: 1px 0;
    color: var(--text-primary);
    border-radius: 6px;
    text-decoration: none;
    transition: background-color 0.2s;
    font-size: 14px;
}

.sidebar-nav .nav-link:hover {
    background-color: var(--hover-bg);
}

.sidebar-nav .nav-link.active {
    background-color: var(--selected-bg);
    color: var(--text-primary);
    font-weight: 500;
}

.sidebar-nav .nav-link i {
    font-size: 16px;
    width: 20px;
}

.sidebar-nav .nav-link .badge {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

/* Context menu for folders */
#folderContextMenu.dropdown-menu {
    background-color: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

#folderContextMenu .dropdown-item {
    color: var(--text-primary);
}

#folderContextMenu .dropdown-item:hover {
    background-color: var(--hover-bg);
}

/* Context menu for mails */
#mailContextMenu.dropdown-menu {
    background-color: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

#mailContextMenu .dropdown-item {
    color: var(--text-primary);
}

#mailContextMenu .dropdown-item:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

/* Unterordner-Styling */
.folder-children {
    margin-left: 0;
    padding-left: 0;
}

.folder-children .nav-item {
    list-style: none;
}

.folder-children .nav-link {
    padding-left: 36px;
    font-size: 13px;
}

.folder-children .nav-link i {
    font-size: 14px;
    width: 18px;
}

/* ========================================
   MAILLISTE
   ======================================== */

.webmailer-maillist {
    width: var(--maillist-width);
    background-color: var(--background-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.maillist-header {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.maillist-title h5 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.maillist-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.maillist-controls .btn {
    border-radius: 6px;
    padding: 4px 8px;
    border-color: var(--border-color);
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 13px;
}

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

.maillist-controls .btn[aria-pressed="true"] {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.maillist-actions .btn-group {
    gap: 4px;
}

.maillist-actions .btn {
    border-radius: 6px;
    padding: 6px 12px;
    border-color: var(--border-color);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.maillist-actions .btn:hover {
    background-color: var(--hover-bg);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.maillist-body {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.maillist-body::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari/Opera */
}

/* Group headers in mail list (Today / Yesterday) */
.mail-group-header {
    padding: 16px 20px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: transparent;
    border: none;
}

/* Mail-Item */
.mail-item {
    display: flex;
    padding: 16px;
    margin: 6px 12px;
    background-color: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    user-select: none;
}

.mail-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    z-index: 10;
}

.mail-item.active {
    background-color: var(--surface-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color), 0 4px 12px rgba(0, 122, 255, 0.15);
}

.mail-item.selected {
    background-color: var(--selected-bg);
}

.mail-item.unread {
    background-color: var(--unread-bg);
    border-left: 1px solid transparent;
}

.mail-item.unread .mail-from,
.mail-item.unread .mail-subject,
.mail-item.unread .mail-from.fw-bold,
.mail-item.unread .mail-subject.fw-bold {
    font-weight: 700 !important;
}

.mail-item.unread::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 18px;
    width: 8px;
    height: 8px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: none;
    /* Hide dot as we use border-left */
}

/* Legacy: checkbox column removed */
.mail-checkbox {
    display: none;
}

.mail-checkbox input[type="checkbox"] {
    display: none;
}

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

/* Avatar replacing checkbox in mail list */
.mail-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    margin-right: 12px;
    gap: 6px;
    flex-shrink: 0;
    min-width: 48px;
}

.mail-avatar {
    margin-right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--hover-bg);
    flex-shrink: 0;
    overflow: hidden;
}

.mail-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.mail-avatar .avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--hover-bg);
    border-radius: 50%;
    letter-spacing: 0.5px;
}

.mail-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.mail-from {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.mail-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 12px;
    white-space: nowrap;
}

.mail-subject {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Small badges inside the subject line */
.mail-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 11px;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 10px;
    font-weight: 600;
    vertical-align: baseline;
}

.mail-badge-flag {
    background: rgba(255, 165, 0, 0.15);
    color: #b36b00;
    border: 1px solid rgba(255, 165, 0, 0.35);
}

.mail-badge-attach {
    background: rgba(0, 122, 255, 0.12);
    color: var(--primary-color);
    border: 1px solid rgba(0, 122, 255, 0.25);
}

[data-theme="dark"] .mail-badge-flag,
[data-theme="eva"] .mail-badge-flag,
[data-theme="auto"] .mail-badge-flag {
    background: rgba(255, 200, 120, 0.15);
    color: #f5c16b;
    border-color: rgba(255, 200, 120, 0.35);
}

[data-theme="dark"] .mail-badge-attach,
[data-theme="eva"] .mail-badge-attach,
[data-theme="auto"] .mail-badge-attach {
    background: rgba(122, 162, 247, 0.18);
    color: var(--primary-color);
    border-color: rgba(122, 162, 247, 0.35);
}

/* Badge under avatar */
.mail-badges {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mail-side-badge {
    display: inline-block;
}

.mail-preview {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
    margin-top: 4px;
    max-height: 2.8em;
}

/* Better contrast and visibility in dark themes */
[data-theme="dark"] .mail-item .mail-subject,
[data-theme="dark"] .mail-item .mail-preview,
[data-theme="dark"] .mail-item .mail-from,
[data-theme="eva"] .mail-item .mail-subject,
[data-theme="eva"] .mail-item .mail-preview,
[data-theme="eva"] .mail-item .mail-from,
[data-theme="auto"] .mail-item .mail-subject,
[data-theme="auto"] .mail-item .mail-preview,
[data-theme="auto"] .mail-item .mail-from {
    color: var(--text-primary) !important;
}

/* Drag & Drop Zielzustände für Ordnerlinks */
.sidebar-nav .nav-link.drop-target {
    outline: 2px dashed var(--primary-color);
}

.sidebar-nav .nav-link.drop-over {
    background-color: rgba(0, 122, 255, 0.12);
}

/* Keep strong contrast when item is active/selected or unread */
[data-theme="dark"] .mail-item.active .mail-subject,
[data-theme="dark"] .mail-item.active .mail-preview,
[data-theme="eva"] .mail-item.active .mail-subject,
[data-theme="eva"] .mail-item.active .mail-preview,
[data-theme="auto"] .mail-item.active .mail-subject,
[data-theme="auto"] .mail-item.active .mail-preview {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .mail-item.unread .mail-subject,
[data-theme="dark"] .mail-item.unread .mail-preview,
[data-theme="eva"] .mail-item.unread .mail-subject,
[data-theme="eva"] .mail-item.unread .mail-preview,
[data-theme="auto"] .mail-item.unread .mail-subject,
[data-theme="auto"] .mail-item.unread .mail-preview {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .mail-item.unread .mail-from,
[data-theme="dark"] .mail-item.unread .mail-subject,
[data-theme="eva"] .mail-item.unread .mail-from,
[data-theme="eva"] .mail-item.unread .mail-subject,
[data-theme="auto"] .mail-item.unread .mail-from,
[data-theme="auto"] .mail-item.unread .mail-subject,
[data-theme="dark"] .mail-item.unread .mail-from.fw-bold,
[data-theme="dark"] .mail-item.unread .mail-subject.fw-bold,
[data-theme="eva"] .mail-item.unread .mail-from.fw-bold,
[data-theme="eva"] .mail-item.unread .mail-subject.fw-bold,
[data-theme="auto"] .mail-item.unread .mail-from.fw-bold,
[data-theme="auto"] .mail-item.unread .mail-subject.fw-bold {
    font-weight: 700 !important;
}

/* ========================================
   MAIL-DETAILANSICHT
   ======================================== */

.webmailer-detail {
    flex: 1;
    background-color: var(--surface-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    margin: 12px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.webmailer-detail::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari/Opera */
}

/* =============================
   COLUMN RESIZERS (draggable)
   ============================= */
.col-resizer {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    margin-left: -3px;
    /* center the 6px handle on the boundary */
    cursor: col-resize;
    z-index: 150;
    /* above content, below modal */
    background: transparent;
    /* invisible by default */
}

.col-resizer::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 2px;
    width: 2px;
    background: transparent;
    /* subtle line on hover only */
    transition: background-color 0.15s ease;
}

.col-resizer:hover::before,
body.is-resizing .col-resizer::before {
    background: var(--border-color);
}

/* Position handles using CSS variables */
#resizeSidebar {
    left: var(--sidebar-width);
}

#resizeList {
    left: calc(var(--sidebar-width) + var(--maillist-width));
}

/* Hide sidebar resizer when collapsed */
.sidebar-collapsed #resizeSidebar {
    display: none;
}

/* Disable selection during resize */
body.is-resizing {
    user-select: none;
    cursor: col-resize;
}

/* On small screens (stacked layout), hide resizers */
@media (max-width: 992px) {
    .col-resizer {
        display: none !important;
    }
}

.mail-detail-header {
    padding: 18.5px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
    gap: 16px;
}

/* Large avatar in detail header */
.mail-detail-avatar-large {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--avatar-bg, #667085);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mail-detail-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.mail-detail-avatar-large .avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    color: #fff;
    background: var(--avatar-bg, #667085);
}

.mail-detail-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
    /* push actions to the right */
}

.mail-detail-actions .btn {
    font-size: 14px;
    /* smaller icon size */
    padding: 4px 8px;
    /* tighter */
    border-radius: 6px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.mail-detail-actions .btn:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.mail-detail-content {
    flex: 1;
    padding: 32px 40px;
}

.mail-detail-subject {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.mail-detail-meta {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.mail-detail-from {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.from-info {
    flex: 1;
}

.mail-detail-date {
    color: var(--text-muted);
    font-size: 14px;
}

.mail-detail-body {
    line-height: 1.6;
    color: var(--text-primary);
    font-size: 15px;
    min-height: 200px;
    background: var(--surface-color);
}

/* iframe für Mail-Content */
.mail-detail-body iframe {
    width: 100%;
    min-height: 200px;
    border: none;
    background: transparent;
    display: block;
    overflow: hidden;
}

/* Legacy: Falls kein iframe verwendet wird */
.mail-detail-body:not(:has(iframe)) {
    /* CSS-Isolation für HTML-Mails */
    isolation: isolate;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Reset für HTML-Mail-Content (Legacy) */
.mail-detail-body:not(:has(iframe)) * {
    max-width: 100%;
}

.mail-detail-body:not(:has(iframe)) img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 16px 0;
    display: block;
}

/* Anhänge */
.mail-attachments {
    margin: 24px 0;
    padding: 16px;
    background-color: var(--background-color);
    border-radius: 12px;
}

.attachments-title {
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

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

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: var(--surface-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: background-color 0.2s;
    cursor: pointer;
}

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

.attachment-item i {
    font-size: 20px;
    color: var(--primary-color);
}

/* ========================================
   ZUSTÄNDE (Laden, Leer, Fehler)
   ======================================== */

.loading-state,
.empty-state,
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
}

.empty-state i {
    font-size: 64px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 16px;
}

.error-state i {
    font-size: 64px;
    margin-bottom: 16px;
}

/* ========================================
   FORTSCHRITTSANZEIGE
   ======================================== */

.loading-state .progress {
    margin: 0 auto;
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.loading-state .progress-bar {
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

#syncProgressText {
    font-size: 13px;
    margin-top: 8px;
}

/* ========================================
   SCROLLBARS (WebKit)
   ======================================== */

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========================================
   RESPONSIVE ANPASSUNGEN
   ======================================== */

@media (max-width: 1200px) {
    :root {
        --maillist-width: 320px;
        --sidebar-width: 220px;
    }
}

@media (max-width: 992px) {
    .webmailer-main {
        flex-direction: column;
    }

    .webmailer-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .webmailer-maillist {
        width: 100%;
        border-right: none;
    }

    .webmailer-detail {
        display: none;
        /* Auf mobil ausblenden */
    }

    .webmailer-detail.active {
        display: flex;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 200;
    }
}

@media (max-width: 768px) {
    .header-center {
        display: none;
    }

    .mail-from,
    .mail-subject {
        font-size: 13px;
    }

    .mail-detail-subject {
        font-size: 22px;
    }

    .mail-detail-content {
        padding: 20px;
    }
}

/* ========================================
   ANIMATIONEN
   ======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.mail-item {
    animation: fadeIn 0.3s ease;
}

.mail-detail-content {
    animation: fadeIn 0.4s ease;
}

/* ========================================
   DUNKELMODUS (Optional)
   Entfernen Sie den Kommentar, um Dunkelmodus zu aktivieren
   ======================================== */

/* Tokyo Dark Theme - Inspiriert von Tokyo Night */
[data-theme="dark"] {
    --primary-color: #7aa2f7;
    --primary-hover: #89b4fa;
    --background-color: #1a1b26;
    --surface-color: #24283b;
    --border-color: #414868;
    --text-primary: #c0caf5;
    --text-secondary: #a9b1d6;
    --text-muted: #7a829e;
    --unread-bg: #2d3748;
    --hover-bg: #2f3549;
    --selected-bg: #2d3f5f;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.7);
}

/* Eva Dark Theme - Inspiriert von Eva Dark VS Code Theme */
[data-theme="eva"] {
    /* Eva Dark inspired palette */
    --primary-color: #6b6d72;
    /* Accent blue */
    --primary-hover: #516188;
    --background-color: #181a1f;
    --group-background-color: #3d4e69;
    /* Editor background */
    --surface-color: #21252B;
    /* Panels, list surfaces */
    --border-color: #3a4459;
    /* Subtle borders */
    --text-primary: #8E99B1;
    /* Main foreground */
    --text-secondary: #a9b2c3;
    /* Secondary text */
    --text-muted: #9aa0ac;
    /* Muted text */
    --unread-bg: #2d4054;
    /* Subtle blue-tinted bg for unread */
    --hover-bg: #2c3648;
    /* Row hover */
    --selected-bg: #283142;
    /* Row selected */
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.8);
}

/* Auto-Modus basierend auf System-Präferenz */
@media (prefers-color-scheme: dark) {
    [data-theme="auto"] {
        --primary-color: #7aa2f7;
        --primary-hover: #89b4fa;
        --background-color: #1a1b26;
        --surface-color: #24283b;
        --border-color: #414868;
        --text-primary: #c0caf5;
        --text-secondary: #a9b1d6;
        --text-muted: #7a829e;
        --unread-bg: #2d3748;
        --hover-bg: #2f3549;
        --selected-bg: #2d3f5f;
        --shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.7);
    }
}

/* ========================================
   EINSTELLUNGEN MODAL
   ======================================== */

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

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-title {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 16px;
    letter-spacing: 0.5px;
}

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

.setting-label {
    display: flex;
    align-items: center;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.theme-selector {
    display: flex;
    gap: 16px;
}

.theme-option {
    flex: 1;
    text-align: center;
    cursor: pointer;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    transition: all 0.2s;
    background-color: var(--surface-color);
}

.theme-option:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.theme-option.active {
    border-color: var(--primary-color);
    background-color: var(--selected-bg);
}

.theme-preview {
    width: 60px;
    height: 60px;
    margin: 0 auto 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: background-color 0.2s;
}

.theme-preview-light {
    background: linear-gradient(135deg, #f5f5f7 0%, #e8e8ed 100%);
    color: #007aff;
}

.theme-preview-dark {
    background: linear-gradient(135deg, #1a1b26 0%, #24283b 100%);
    color: #7aa2f7;
}

.theme-preview-eva {
    background: linear-gradient(135deg, #1e2430 0%, #2a313f 100%);
    color: #82aaff;
}

.theme-preview-auto {
    background: linear-gradient(135deg, #f5f5f7 0%, #f5f5f7 50%, #1a1b26 50%, #1a1b26 100%);
    color: #565f89;
}

.theme-option-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Modal Anpassungen für Dark Mode */
[data-theme="dark"] .modal-content,
[data-theme="eva"] .modal-content,
[data-theme="auto"] .modal-content {
    background-color: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .modal-header,
[data-theme="eva"] .modal-header,
[data-theme="auto"] .modal-header {
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .btn-close,
[data-theme="eva"] .btn-close,
[data-theme="auto"] .btn-close {
    filter: invert(1);
}

@media (prefers-color-scheme: dark) {
    [data-theme="auto"] .modal-content {
        background-color: var(--surface-color);
        color: var(--text-primary);
        border: 1px solid var(--border-color);
    }

    [data-theme="auto"] .modal-header {
        border-bottom-color: var(--border-color);
    }

    [data-theme="auto"] .btn-close {
        filter: invert(1);
    }
}

/* ========================================
   FORMULARELEMENTE (global & Modals)
   Theme-aware Styling für Inputs, Selects, Textareas
   ======================================== */

.form-control,
.form-select {
    background-color: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--surface-color);
    color: var(--text-primary);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.input-group .input-group-text {
    background-color: var(--background-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* Checkboxen/Switches */
.form-check-input {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Safari/Chrome Autofill in dunklen Themes lesbar halten */
input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px var(--surface-color) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    caret-color: var(--text-primary);
}

/* ========================================
   ANIMATIONEN
   ======================================== */

/* Spinner-Animation für Refresh-Button */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
}

/* ========================================
   SYNC STATUS MODAL
   ======================================== */

.sync-status-details {
    font-size: 14px;
}

.sync-status-details .badge {
    font-size: 13px;
    padding: 6px 12px;
}

#syncStatusModal .modal-body {
    min-height: 200px;
}

/* ========================================
   EINSTELLUNGEN SEITE (Karten)
   ======================================== */

.settings-card.card {
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    box-shadow: var(--shadow);
    border-radius: 12px;
    overflow: hidden;
}

.settings-card .card-header {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0));
    border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .settings-card .card-header,
[data-theme="eva"] .settings-card .card-header,
[data-theme="auto"] .settings-card .card-header {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0));
}

.settings-card .card-body .form-text {
    color: var(--text-muted);
}

.settings-card .form-control,
.settings-card .form-select {
    background-color: var(--surface-color);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.settings-card .form-control:focus,
.settings-card .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.settings-card .btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.settings-card .btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: #fff;
}

/* ========================================
   KONTAKTE
   ======================================== */

#contactList {
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#contactList::-webkit-scrollbar {
    display: none;
}

#contactList .nav-item .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
}

#contactList .contact-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    color: white;
    font-size: 12px;
    font-weight: 600;
}

#contactList .contact-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#contactList .contact-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

#contactList .contact-name {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#contactList .contact-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#contactList .contact-favorite {
    color: var(--text-muted);
    font-size: 12px;
}

#contactList .contact-favorite.active {
    color: #ffc107;
}

/* Contact Modal Avatar */
.contact-avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: var(--background-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    overflow: hidden;
    border: 3px solid var(--border-color);
}

.contact-avatar-preview i {
    font-size: 48px;
    color: var(--text-muted);
}

.contact-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* All Contacts Modal */
.contacts-list {
    max-height: 400px;
    overflow-y: auto;
}

.contacts-list .contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s;
}

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

.contacts-list .contact-item .contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    color: white;
    font-size: 16px;
    font-weight: 600;
}

.contacts-list .contact-item .contact-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.contacts-list .contact-item .contact-info {
    flex: 1;
    min-width: 0;
}

.contacts-list .contact-item .contact-name {
    font-weight: 600;
    font-size: 14px;
}

.contacts-list .contact-item .contact-email {
    font-size: 13px;
    color: var(--text-muted);
}

.contacts-list .contact-item .contact-actions {
    display: flex;
    gap: 8px;
}

.contacts-list .contact-item .contact-actions .btn {
    padding: 4px 8px;
    font-size: 14px;
}

.contacts-list .empty-contacts {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.contacts-list .empty-contacts i {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
}

/* Contact Autocomplete in Compose Modal */
.contact-autocomplete {
    position: absolute;
    top: calc(100% - 1.5em);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1050;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.contact-autocomplete.show {
    display: block;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
    gap: 10px;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: var(--primary-color);
}

.autocomplete-item .autocomplete-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--avatar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    color: #fff;
    flex-shrink: 0;
}

.autocomplete-item .autocomplete-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

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

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

.autocomplete-item .autocomplete-email {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Input wrapper for autocomplete positioning */
.input-with-autocomplete {
    position: relative;
}