/* Header */
.header {
    height: 5em;
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
    position: relative;
}

.headerLeft {
    display: flex;
    align-items: center;
}

.headerCenter {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 5em;
}

.headerRight {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
    position: absolute;
    top: 0;
    right: 0;
}

.welcome-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    align-self: center;
    font-size: 1.1rem;
}

.headerLogo_mini {
    font-family: "Linux Libertine Initials O";
    font-size: 4em;
    line-height: 1em;
    color: var(--logo-color);
    text-decoration: none;
}

img.headerLogo_mini {
    height: 56px;
    width: auto;
}

.headerLogo_mini:hover {
    text-decoration: none;
}

/* Gadget-UI menu overrides */
div.gadget-ui-menu {
    display: inline-block !important;
}

.gadget-ui-menu-menuItem {
    display: none !important;
    background: var(--menu-background-color);
    border-radius: 1em;
    padding: 1em;
    z-index: 1000;
}

.gadget-ui-menu-hovering {
    display: block !important;
    position: absolute !important;
}

.gadget-ui-menu-menuItem > div {
    padding-top: 0.5em;
    display: block !important;
}

.gadget-ui-menu-item:hover {
    background: var(--menu-hover-background-color);
}

div.gadget-ui-menu,
div.gadget-ui-menu-menuItem {
    right: 10px;
    padding: 5px 10px 0 0;
}

img.gadget-ui-menu-icon {
    margin-right: 0;
    width: 44px !important;
    height: 44px !important;
    border-radius: 50%;
    object-fit: cover;
}

/* Mail layout */
.mail-layout {
    display: flex;
    height: calc(100vh - 60px);
}

.folder-panel {
    width: 220px;
    min-width: 220px;
    border-right: 1px solid var(--border-color-primary);
    overflow-y: auto;
    background: var(--secondary-back-color, #f8f9fa);
    padding: 8px 0;
}

.mail-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Vertical split (side by side) - default */
.mail-content.split-vertical {
    flex-direction: row;
}

.mail-content.split-vertical .message-panel {
    flex: 1;
    overflow-y: auto;
}

.mail-content.split-vertical .message-view-panel {
    flex: 1;
    overflow-y: auto;
    border-left: none;
    border-top: none;
}

.mail-content.split-vertical .split-resizer {
    width: 4px;
    cursor: col-resize;
    background: var(--border-color-primary);
    flex-shrink: 0;
}

.mail-content.split-vertical .split-resizer:hover {
    background: var(--button-primary-back-color, #3498db);
}

/* Horizontal split (stacked) */
.mail-content.split-horizontal {
    flex-direction: column;
}

.mail-content.split-horizontal .message-panel {
    flex: 1;
    overflow-y: auto;
}

.mail-content.split-horizontal .message-view-panel {
    flex: 1;
    overflow-y: auto;
    border-left: none;
    border-top: none;
}

.mail-content.split-horizontal .split-resizer {
    height: 4px;
    cursor: row-resize;
    background: var(--border-color-primary);
    flex-shrink: 0;
}

.mail-content.split-horizontal .split-resizer:hover {
    background: var(--button-primary-back-color, #3498db);
}

/* Fallback when no split class yet */
.message-panel {
    flex: 1;
    overflow-y: auto;
}

.message-view-panel {
    flex: 1;
    overflow-y: auto;
}

/* Folder list */
.folder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--fore-color);
    transition: background 0.15s;
}

.folder-item:hover {
    background: var(--selected-background-color, rgba(0,0,0,0.05));
}

.folder-item.active {
    background: var(--selected-background-color, rgba(0,0,0,0.08));
    font-weight: 600;
}

.folder-item.drag-over {
    background: var(--button-primary-back-color, #3498db);
    color: var(--button-primary-fore-color, #fff);
}

.message-row[draggable="true"] {
    cursor: grab;
}

.message-row[draggable="true"]:active {
    cursor: grabbing;
}

.folder-item[draggable="true"] {
    cursor: grab;
}

.folder-item[draggable="true"]:active {
    cursor: grabbing;
}

.folder-item {
    position: relative;
}

.folder-delete-btn {
    display: none;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: var(--fore-color-secondary);
    line-height: 1;
}

.folder-delete-btn .feather {
    width: 14px;
    height: 14px;
}

.folder-item:hover .folder-delete-btn {
    display: block;
}

.folder-delete-btn:hover {
    color: var(--warning-color, #c33);
}

.folder-actions {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color-primary);
    margin-top: 8px;
}

.folder-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--fore-color-secondary);
    font-size: 13px;
    padding: 6px 0;
}

.folder-action-btn .feather {
    width: 16px;
    height: 16px;
}

.folder-action-btn:hover {
    color: var(--fore-color);
}

.folder-item .feather {
    width: 18px;
    height: 18px;
}

.folder-item .unread-count {
    margin-left: auto;
    font-weight: bold;
    font-size: 12px;
    color: var(--button-primary-back-color, #3498db);
}

/* Message list */
.message-list-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color-primary);
}

.message-list-toolbar button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    background: var(--button-primary-back-color, #3498db);
    color: var(--button-primary-fore-color, white);
    cursor: pointer;
    font-size: 13px;
}

.message-list-toolbar button:hover {
    opacity: 0.9;
}

.message-list-toolbar button .feather {
    width: 16px;
    height: 16px;
}

.message-list-toolbar .toolbar-folder-name {
    margin-left: auto;
    font-weight: 600;
    font-size: 14px;
}

.message-list-toolbar .toolbar-btn-right {
    margin-left: auto;
    background: var(--secondary-back-color, #eee);
    color: var(--fore-color);
}

.message-list-toolbar .toolbar-btn-right:hover {
    background: var(--selected-background-color, #ddd);
}

.message-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color-primary);
    cursor: pointer;
    transition: background 0.1s;
}

.message-row:hover {
    background: var(--selected-background-color, rgba(0,0,0,0.03));
}

.message-row.unread {
    font-weight: 600;
}

.message-row.unread .message-from {
    font-weight: 700;
}

.message-from {
    width: 200px;
    min-width: 200px;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-subject {
    flex: 1;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-date {
    font-size: 12px;
    color: var(--fore-color-secondary, #888);
    white-space: nowrap;
}

.message-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    border-top: 1px solid var(--border-color-primary);
    font-size: 13px;
}

.message-pagination button {
    padding: 6px 12px;
    border: 1px solid var(--border-color-primary);
    border-radius: 4px;
    background: var(--back-color, white);
    cursor: pointer;
    font-size: 13px;
}

.message-pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

.no-messages {
    padding: 40px;
    text-align: center;
    color: var(--fore-color-secondary, #888);
    font-size: 14px;
}

/* Message view */
.message-view-header {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color-primary);
}

.message-view-header button {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid var(--border-color-primary);
    border-radius: 4px;
    background: var(--back-color, white);
    cursor: pointer;
    font-size: 13px;
    color: var(--fore-color);
}

.message-view-header button:hover {
    background: var(--selected-background-color, #f0f0f0);
}

.message-view-header button .feather {
    width: 14px;
    height: 14px;
}

.message-view-header button.delete-btn {
    margin-left: auto;
    color: #e74c3c;
    border-color: #e74c3c;
}

.plain-text-quote {
    border-left: 3px solid var(--button-primary-back-color, #3498db);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--fore-color-secondary);
}

.message-meta {
    padding: 16px;
    border-bottom: 1px solid var(--border-color-primary);
    font-size: 14px;
    line-height: 1.8;
}

.message-meta .label {
    font-weight: 600;
    color: var(--fore-color-secondary, #666);
    margin-right: 8px;
}

.message-meta .subject-line {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.message-body {
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: break-word;
}

.message-body img {
    max-width: 100%;
    height: auto;
}

/* Compose modal */
.compose-modal {
    position: fixed;
    bottom: 0;
    right: 20px;
    width: 550px;
    max-height: 70vh;
    background: var(--back-color, white);
    border: 1px solid var(--border-color-primary);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.compose-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--button-primary-back-color, #3498db);
    color: white;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
}

.compose-header .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.compose-fields {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color-primary);
}

.compose-fields input {
    width: 100%;
    padding: 6px 0;
    border: none;
    border-bottom: 1px solid var(--border-color-primary);
    background: transparent;
    font-size: 14px;
    color: var(--fore-color);
    outline: none;
}

.compose-fields input:focus {
    border-bottom-color: var(--button-primary-back-color, #3498db);
}

/* Contact chips in To/CC fields */
.compose-field .gadgetui-lookuplist-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    border-bottom: 1px solid var(--border-color-primary);
    padding: 4px 0;
}

.compose-field .gadgetui-lookuplist-input input {
    flex: 1;
    min-width: 120px;
    border-bottom: none !important;
    padding: 4px 0;
}

.compose-field label {
    font-size: 13px;
    color: var(--fore-color-secondary);
    margin-bottom: 2px;
}

.contact-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--button-primary-back-color, #3498db);
    color: var(--button-primary-fore-color, #fff);
    border-radius: 14px;
    padding: 2px 10px 2px 2px;
    font-size: 12px;
    white-space: nowrap;
}

.contact-chip-pic {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.contact-menu-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
}

.contact-menu-pic {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.contact-menu-info {
    display: flex;
    flex-direction: column;
}

.contact-menu-item:hover {
    background: var(--menu-hover-background-color, #eee);
}

.contact-menu-name {
    font-weight: 600;
    font-size: 13px;
}

.contact-menu-email {
    font-size: 11px;
    color: var(--fore-color-secondary);
}

.gadgetui-lookuplist-menu {
    position: absolute;
    z-index: 1000;
    background: var(--menu-background-color, #fff);
    border: 1px solid var(--border-color-primary);
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Attachment display in message view */
.message-attachments {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color-primary);
    background: var(--secondary-back-color, #f8f9fa);
}

.attachments-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--fore-color-secondary);
    margin-bottom: 6px;
}

.attachments-label .feather {
    width: 14px;
    height: 14px;
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--back-color, #fff);
    border: 1px solid var(--border-color-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

.attachment-item:hover {
    background: var(--selected-background-color, #eee);
}

.attachment-item .feather {
    width: 14px;
    height: 14px;
}

.attachment-name {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-size {
    color: var(--fore-color-secondary);
    font-size: 11px;
}

/* Compose attachments */
.compose-attachments {
    padding: 4px 16px;
}

.compose-attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.compose-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--secondary-back-color, #eee);
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 12px;
}

.compose-attachment-remove {
    cursor: pointer;
    font-weight: bold;
    color: var(--fore-color-secondary);
    margin-left: 2px;
}

.compose-attachment-remove:hover {
    color: var(--warning-color, #c33);
}

.compose-attach-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    background: var(--secondary-back-color, #eee);
    color: var(--fore-color);
    font-size: 13px;
}

.compose-attach-btn .feather {
    width: 14px;
    height: 14px;
}

.compose-attach-btn:hover {
    background: var(--selected-background-color, #ddd);
}

.compose-editor {
    flex: 1;
    padding: 16px;
    min-height: 200px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.6;
    outline: none;
}

.compose-footer {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border-color-primary);
}

.compose-footer .send-btn {
    padding: 8px 24px;
    background: var(--button-primary-back-color, #3498db);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.compose-footer .cancel-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-color-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: var(--fore-color);
}

/* Password prompt */
.password-prompt {
    max-width: 400px;
    margin: 100px auto;
    padding: 40px;
    background: var(--back-color, white);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    text-align: center;
}

.password-prompt h2 {
    margin-top: 0;
    margin-bottom: 8px;
}

.password-prompt p {
    color: var(--fore-color-secondary, #666);
    margin-bottom: 20px;
}

.password-prompt input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color-primary);
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 16px;
    background: var(--back-color, white);
    color: var(--fore-color);
}

.password-prompt button {
    width: 100%;
    padding: 12px;
    background: var(--button-primary-back-color, #3498db);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
}

.password-prompt .error {
    color: #e74c3c;
    font-size: 13px;
    margin-top: 10px;
}

/* Quoted message (reply/forward) */
.quoted-message {
    border-left: 3px solid var(--border-color-primary, #ccc);
    padding-left: 12px;
    margin-left: 4px;
    color: var(--fore-color-secondary, #666);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .mail-layout {
        flex-direction: column;
    }
    .folder-panel {
        width: 100%;
        min-width: auto;
        max-height: 50px;
        overflow-x: auto;
        overflow-y: hidden;
        display: flex;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--border-color-primary);
        padding: 0;
    }
    .folder-item {
        white-space: nowrap;
        padding: 8px 12px;
    }
    .mail-content {
        flex-direction: column;
    }
    .message-view-panel {
        border-left: none;
        border-top: 1px solid var(--border-color-primary);
    }
    .message-from {
        width: 120px;
        min-width: 120px;
    }
    .compose-modal {
        width: 100%;
        right: 0;
        max-height: 80vh;
    }
}
