:root {
    --bg-dark: #121212;
    --bg-darker: #363636;
    --bg-card: #121212;
    --bg-hover: #3A3A3A;
    --text-primary: #FFFFFF;
    --text-secondary: #B0B0B0;
    --accent: #4A4A4A;
    --border: #333;
    --container: #1B2024;
    --font-stack: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Light Mode */
[data-theme="light"] {
    --bg-dark: #F5F5F5;
    --bg-darker: #E8E8E8;
    --bg-card: #FFFFFF;
    --bg-hover: #E0E0E0;
    --text-primary: #000000;
    --text-secondary: #666666;
    --accent: #CCCCCC;
    --border: #DDDDDD;
    --container: #FFFFFF;
}

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

body {
    background-color: var(--bg-darker);
    color: var(--text-primary);
    font-family: var(--font-stack);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: grid;
    grid-template-columns: 250px 400px 1fr;
    height: 100vh;
    gap: 20px;
    background-color: var(--bg-darker);
    padding: 20px;
}

/* Sidebar */
.sidebar {
    background-color: var(--container);
    display: flex;
    flex-direction: column;
    padding: 20px;
    border-radius: 20px;
    flex: 1;
}

.sidebar-header {
    margin-bottom: 2rem;
}

.sidebar-column {
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 15px 20px;
    text-align: center;
}

.sidebar-logo img {
    max-width: 100%;
    height: auto;
}

.sidebar h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    padding: 10px 0;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 500;
}

.email-toggle-item {
    padding: 10px 0;
    color: var(--text-primary);
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.sidebar-nav li .arrow,
.email-toggle-item .arrow {
    font-size: 1rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
    display: inline-block;
}

.sidebar-nav li.open .arrow,
.email-toggle-item.open .arrow {
    transform: rotate(90deg);
}

.folder-list {
    list-style: none;
    margin-top: 5px;
    margin-bottom: 10px;
    padding-left: 0;
    /* Aligned left */
    display: none;
    /* Hidden by default */
}

.folder-list.open {
    display: block;
    animation: slideDown 0.2s ease-out;
}

.folder-item {
    color: var(--text-secondary);
    padding: 8px 10px;
    font-size: 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    transition: background 0.2s, color 0.2s;
}

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

.folder-item.active {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 500;
}

.folder-item svg {
    flex-shrink: 0;
    order: -1;
}

.folder-item span {
    flex: 1;
    text-align: right;
}

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

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

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

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

#refresh-btn.loading svg {
    animation: spin 1s linear infinite;
}

.sidebar-footer {
    margin-top: auto;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.settings-header h3 {
    margin: 0;
}

/* Theme Toggle */
.theme-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.theme-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-hover);
    border-radius: 24px;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
}

.toggle-slider .sun-icon,
.toggle-slider .moon-icon {
    color: var(--text-secondary);
    transition: opacity 0.3s, color 0.3s;
}

.toggle-slider .sun-icon {
    opacity: 0;
}

.toggle-slider .moon-icon {
    opacity: 1;
}

.theme-toggle input:checked+.toggle-slider {
    background-color: #4A90D9;
}

.theme-toggle input:checked+.toggle-slider .sun-icon {
    opacity: 1;
    color: #FFD700;
}

.theme-toggle input:checked+.toggle-slider .moon-icon {
    opacity: 0;
}

.sidebar-footer h3 {
    font-size: 1rem;
    color: var(--text-primary);
}

.account-buttons {
    display: flex;
    gap: 10px;
}

.account-btn {
    flex: 1;
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.account-btn:hover {
    background-color: #444;
    border-color: #555;
}

.google-btn svg,
.imap-btn svg {
    flex-shrink: 0;
}


/* Mail List */
.mail-list-section {
    background-color: var(--container);
    display: flex;
    flex-direction: column;
    /* border-right: 1px solid var(--border); removed for card style */
    overflow: hidden;
    border-radius: 20px;
    position: relative;
    /* For resizer positioning */
}

#resizer {
    position: absolute;
    right: -10px;
    /* Center over the 20px gap */
    top: 0;
    bottom: 0;
    width: 20px;
    cursor: col-resize;
    z-index: 100;
    /* Optional: hover effect to see the handle
    background: rgba(255, 255, 255, 0.05); */
}

.mail-list-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.mail-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.mail-list-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.header-tools {
    display: flex;
    gap: 10px;
}

.filter-btn {
    background: #3a3a3a;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

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

.search-bar input {
    background: #333;
    border: none;
    border-radius: 20px;
    padding: 8px 35px 8px 15px;
    color: white;
    width: 100%;
    font-size: 0.9rem;
}

[data-theme="light"] .search-bar input {
    background-color: #E8E8E8;
}

.search-bar .search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    font-size: 0.8rem;
}

.refresh-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    width: 100%;
    margin-top: 5px;
}

.refresh-btn:hover {
    background-color: #45a049;
}

.mail-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.mail-item {
    background-color: transparent;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
    border: 1px solid transparent;
}

.mail-item:hover,
.mail-item.active {
    background-color: #383838;
    border-color: #444;
}

/* Light mode mail item hover */
[data-theme="light"] .mail-item:hover,
[data-theme="light"] .mail-item.active {
    background-color: #E8E8E8;
    border-color: #CCCCCC;
}

.mail-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.mail-item-sender {
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Blue dot for unread emails */
.unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #4A90D9;
    flex-shrink: 0;
}

.mail-item.unread .mail-item-sender {
    font-weight: 800;
}

.mail-item.unread .mail-item-subject {
    font-weight: 700;
}

.mail-item-actions {
    display: flex;
    gap: 5px;
}

.action-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #444;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #aaa;
}

.mail-item-subject {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-theme="light"] .mail-item-subject {
    color: #000000;
}

.mail-item-snippet {
    font-size: 0.8rem;
    color: #999;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Mail Content Panel */
.mail-content-section {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    /* Prevent global scroll */
    height: 100%;
}

.mail-content-header {
    padding-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.mail-content-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

#selected-mail-view {
    padding: 20px;
    flex: 1;
    /* Take remaining space */
    display: flex;
    flex-direction: column;
    background-color: var(--container);
    border-radius: 20px;
    overflow-y: auto;
    /* Scrollable content */
    min-height: 0;
    /* Important for firefox/flex scroll */
}

.mail-meta h3 {
    font-size: 1.3rem;
    margin-bottom: 5px;
}

.mail-meta-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.mail-subject {
    font-weight: 600;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.mail-details p {
    font-size: 0.9rem;
    color: #ccc;
    margin-bottom: 5px;
}

[data-theme="light"] .mail-details strong {
    color: #000000;
}

[data-theme="light"] .mail-details p {
    color: #666;
}

.mail-details span {
    color: #fff;
    font-weight: 500;
}

[data-theme="light"] .mail-details span {
    color: var(--text-secondary);
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.mail-body-container {
    margin-bottom: 20px;
    line-height: 1.6;
    font-size: 0.95rem;
    color: #ddd;
}

/* Attachments */
.mail-attachments-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
    margin-top: -10px;
}

.attachment-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.attachment-pill:hover {
    background-color: var(--border);
    transform: translateY(-1px);
}

.attachment-pill .filename {
    font-weight: 500;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-pill .filesize {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

[data-theme="light"] .attachment-pill {
    background-color: #f5f5f5;
    border-color: #e0e0e0;
}

[data-theme="light"] .attachment-pill:hover {
    background-color: #e8e8e8;
}

/* Vertical Resizer (between mail and action) */
.vertical-resizer {
    height: 10px;
    cursor: row-resize;
    background: transparent;
    margin: 5px 0;
    position: relative;
}

.vertical-resizer::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
}

.vertical-resizer:hover::after {
    background: var(--text-secondary);
}

/* Action Section / Reply */
.action-section-container {
    position: relative;
    background-color: var(--container);
    border-radius: 20px;
    padding: 20px;
    padding-bottom: 70px;
    /* Space for fixed send button */
    flex-shrink: 0;
    min-height: 200px;
    height: 350px;
    /* Default height, will be overwritten by JS */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.reply-editor {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    /* Critical for nested flex to work */
    overflow: hidden;
}

.action-section {
    background-color: transparent;
    border-radius: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    /* Important for flex children to shrink/grow */
}

.action-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.action-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    position: relative;
    top: -5px;
    /* Adjusted */
}

/* Toggle / Tabs */
.action-tabs {
    background: #3A3A3A;
    border-radius: 20px;
    width: 225px;
    padding: 2px;
    display: flex;
    position: relative;
    /* Context for sliding pill */
    isolation: isolate;
    /* Create stacking context */
}

[data-theme="light"] .action-tabs {
    background: #E8E8E8;
}

/* The sliding background pill */
.sliding-pill {
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 2px;
    width: calc(50% - 2px);
    /* Assuming 2 buttons equal width */
    background: #757575;
    border-radius: 18px;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: -1;
}

[data-theme="light"] .sliding-pill {
    background: #FFFFFF;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* State: Reply (Right) */
.action-tabs[data-mode="reply"] .sliding-pill {
    transform: translateX(100%);
}

/* State: New (Left) */
.action-tabs[data-mode="new"] .sliding-pill {
    transform: translateX(0);
}

.tab {
    flex: 1;
    /* Equal width for slider to work */
    background: transparent;
    border: none;
    color: #b0b0b0;
    padding: 6px 0;
    border-radius: 18px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    transition: color 0.2s;
    z-index: 2;
}

[data-theme="light"] .tab {
    color: #666666;
}

.tab.active {
    background: transparent;
    /* Handled by pill */
    color: white;
}

[data-theme="light"] .tab.active {
    color: #000000;
}

/* Meta Inputs */
.reply-meta {
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    /* Don't shrink, let textarea take the space */
    gap: 5px;
}

.meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: #ccc;
}

[data-theme="light"] .meta-row {
    color: var(--text-secondary);
}

.meta-row strong {
    color: white;
}

[data-theme="light"] .meta-row strong {
    color: #000000;
}

.meta-input {
    background: transparent;
    border: none;
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    flex: 1;
    padding: 2px 0;
    outline: none;
}

[data-theme="light"] .meta-input {
    color: var(--text-secondary);
}

.meta-input:disabled {
    color: var(--text-secondary);
    cursor: default;
}

.meta-input:not(:disabled) {
    border-bottom: 1px solid var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 5px;
    border-radius: 4px;
}

.compose-select {
    background: var(--bg-hover) !important;
    border: 1px solid var(--border) !important;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    color: inherit;
    appearance: auto;
    /* Ensure system dropdown arrow is visible */
    -webkit-appearance: auto;
    z-index: 10;
    pointer-events: auto;
}

.ai-controls {
    margin: 5px 0;
    /* Reduced margin */
    display: none;
}

/* Styled Textarea */
.reply-textarea {
    width: 100%;
    min-height: 0;
    /* Allow shrinking */
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    line-height: 1.5;
    margin-bottom: 0;
}

[data-theme="light"] .reply-textarea {
    color: #000000;
}

.reply-textarea:focus {
    outline: none;
}

/* Quoted Text */
.reply-quoted-text {
    position: absolute;
    bottom: 65px;
    /* Above send button (20px + button height ~36px + spacing) */
    left: 20px;
    right: 20px;
    color: #666;
    font-size: 0.85rem;
    border-left: 2px solid #444;
    padding-left: 8px;
    max-height: 33px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Send Button - Centered Pill */
.reply-footer {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
}

.send-btn {
    background: #555;
    color: white;
    border: none;
    width: 60px;
    height: 36px;
    border-radius: 18px;
    /* Capsule shape */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    background: #666;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    background-color: var(--container);
    border-radius: 20px;
    flex: 1;
}

/* AI Assistant */
.ai-assistant-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 10px auto;
    /* Center horizontally */
    border-radius: 10px;
    background-color: #4A4A4A;
    border: none;
    cursor: pointer;
    color: white;
    transition: all 0.2s;
    z-index: 1;
}

.ai-assistant-btn img {
    vertical-align: middle;
}

.ai-assistant-btn:hover {
    background-color: #5A5A5A;
    transform: scale(1.05);
}

.mail-body-container {
    position: relative;
}

.ai-assistant-panel {
    background-color: #3A3A3A;
    border-radius: 20px;
    padding: 20px;
    margin-top: -25px;
    margin-bottom: 20px;
    text-align: center;
    animation: slideDown 0.3s ease-out;
}

@keyframes panelSlideDown {
    from {
        opacity: 0;
        max-height: 0;
        padding-top: 22px;
    }

    to {
        opacity: 1;
        max-height: 500px;
        padding-top: 50px;
    }
}

.ai-panel-header {
    display: none;
}

.ai-panel-header svg,
.ai-panel-header img {
    color: white;
}

.ai-questions-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ai-question {
    background-color: transparent;
}

.ai-question-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin-bottom: 15px;
}

.ai-options {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.ai-option-btn {
    background-color: #6A6A6A;
    color: white;
    border: none;
    padding: 12px 40px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
}

.ai-option-btn:hover {
    background-color: #7A7A7A;
}

.ai-option-btn.selected {
    background-color: #4CAF50;
}

.ai-loading {
    color: var(--text-secondary);
    font-style: italic;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--container);
    border-radius: 16px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-group input:focus {
    outline: none;
    border-color: #4A90D9;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    text-align: right;
}

.btn-save {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.btn-save:hover {
    background: #45a049;
}

/* IMAP Modal Specific Styles */
.imap-modal-content {
    width: 520px;
    max-width: 95vw;
    border-radius: 24px;
    overflow: hidden;
}

.imap-modal-content .modal-header {
    padding: 24px 28px 20px;
    border-bottom: 1px solid var(--border);
}

.imap-modal-content .modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

.imap-modal-content .modal-body {
    padding: 24px 28px;
}

.imap-presets {
    margin-bottom: 24px;
}

.imap-presets p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.preset-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--bg-hover);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn svg {
    width: 24px;
    height: 24px;
}

.preset-btn:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

.preset-btn.active {
    border-color: var(--color-primary);
    background: rgba(99, 102, 241, 0.12);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

[data-theme="light"] .preset-btn:hover {
    background: rgba(99, 102, 241, 0.08);
}

[data-theme="light"] .preset-btn.active {
    background: rgba(99, 102, 241, 0.1);
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

.form-row .form-group:first-child {
    flex: 0 0 100px;
}

.form-hint {
    display: block;
    margin-top: 5px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.form-hint a {
    color: #4A90D9;
    text-decoration: none;
}

.form-hint a:hover {
    text-decoration: underline;
}

.imap-error {
    padding: 12px 16px;
    background: rgba(231, 76, 60, 0.12);
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-radius: 10px;
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: 16px;
}

.imap-success {
    padding: 12px 16px;
    background: rgba(46, 204, 113, 0.12);
    border: 1px solid rgba(46, 204, 113, 0.3);
    border-radius: 10px;
    color: #2ecc71;
    font-size: 0.85rem;
    margin-top: 16px;
}

.imap-modal-content .modal-footer {
    padding: 20px 28px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-test {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}

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

.imap-modal-content .btn-save {
    padding: 12px 28px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-test:disabled,
.btn-save:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* IMAP Account Item in Sidebar */
.imap-account-item {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: color 0.2s;
    position: relative;
}

.imap-account-item:hover {
    color: var(--text-primary);
}

.imap-account-item.active {
    color: var(--text-primary);
    font-weight: 500;
}

.imap-account-item .folder-list {
    margin-top: 5px;
    padding-left: 0;
    width: 100%;
}

.imap-account-item .folder-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 8px 10px;
}

.imap-account-item .folder-item svg {
    flex-shrink: 0;
    width: 18px;
}

.imap-account-item .folder-item span {
    flex: 1;
    text-align: right;
    padding-right: 20px;
}

.imap-account-item .delete-btn {
    background: none;
    border: none;
    color: #e74c3c;
    opacity: 0;
    cursor: pointer;
    padding: 2px;
    transition: opacity 0.2s;
    position: absolute;
    right: 0;
    top: 8px;
}

.imap-account-item:hover .delete-btn {
    opacity: 1;
}

/* ========================================
   UNIFIED SETTINGS MODAL
   ======================================== */

.settings-main-btn {
    width: 100%;
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.settings-main-btn:hover {
    background-color: #444;
    border-color: #555;
    transform: translateY(-1px);
}

[data-theme="light"] .settings-main-btn:hover {
    background-color: #d0d0d0;
    border-color: #bbb;
}

/* Settings Modal Overlay */
.settings-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Settings Modal Containerd */
.settings-modal {
    display: flex;
    position: relative;
    background: var(--bg-darker);
    border-radius: 35px;
    width: 90%;
    max-width: 750px;
    height: 70vh;
    max-height: 550px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
    padding: 20px; /* Equal padding around everything */
    gap: 0;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Settings Sidebar - Inside with padding */
.settings-modal-sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--container);
    padding: 24px 16px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.settings-modal-sidebar h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 24px;
    padding-left: 8px;
}

.settings-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.settings-nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.settings-nav-item.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.settings-nav-item svg {
    flex-shrink: 0;
}

/* Settings Content */
.settings-modal-content {
    flex: 1;
    padding: 24px 32px;
    overflow-y: auto;
    position: relative;
    border-radius: 20px;
}

.settings-close-btn {
    position: absolute;
    top: 0px;
    right: 0px;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

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

/* Settings Sections */
.settings-section {
    display: none;
    animation: fadeIn 0.2s ease-out;
}

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

.settings-section h4 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.settings-section-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* Settings Option Row */
.settings-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

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

.settings-option-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-option-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.settings-option-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Theme Switcher Buttons */
.theme-switcher {
    display: flex;
    gap: 8px;
    background: var(--bg-dark);
    padding: 4px;
    border-radius: 12px;
}

.theme-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-btn:hover {
    color: var(--text-primary);
}

.theme-btn.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Account Cards */
.account-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.account-card {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.account-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
}

.account-card-header svg {
    flex-shrink: 0;
}

.account-card-header h5 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.account-card-header p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Connected Accounts List */
.connected-accounts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    min-height: 60px;
}

.no-accounts-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    color: var(--text-secondary);
    text-align: center;
    gap: 12px;
}

.no-accounts-message svg {
    opacity: 0.4;
}

.no-accounts-message p {
    margin: 0;
    font-size: 0.9rem;
}

/* Connected Account Item */
.connected-account-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-hover);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.connected-account-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.connected-account-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--container);
}

.connected-account-icon.google {
    background: white;
}

.connected-account-details h5 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 2px 0;
}

.connected-account-details span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.disconnect-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

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

/* Add Account Section */
.add-account-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.add-account-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    border: 2px dashed var(--border);
    border-radius: 12px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-account-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(99, 102, 241, 0.05);
}

/* Account Type Selection */
.account-type-selection {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.2s ease;
}

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

.account-type-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-hover);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.account-type-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.account-type-btn.google:hover {
    border-color: #4285F4;
    background: rgba(66, 133, 244, 0.1);
}

.account-type-btn.imap:hover {
    border-color: var(--color-primary);
    background: rgba(99, 102, 241, 0.1);
}

/* Settings Form */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-form-group label {
    font-weight: 600;
    font-size: 0.9rem;
}

.settings-form-group input {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.settings-form-group input:focus {
    outline: none;
    border-color: #4A90D9;
}

.settings-form-group small {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.settings-save-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    align-self: flex-start;
}

.settings-save-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
}

/* Responsive */
@media (max-width: 600px) {
    .settings-modal {
        flex-direction: column;
        height: 90vh;
        max-height: none;
        padding: 16px;
    }
    
    .settings-modal-sidebar {
        width: 100%;
        border-radius: 16px;
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .settings-modal-content {
        margin-left: 0;
        border-radius: 16px;
    }
    
    .settings-nav {
        flex-direction: row;
        overflow-x: auto;
    }
    
    .settings-nav-item {
        white-space: nowrap;
    }
}

/* ====================================
   Custom Popup System
   ==================================== */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.popup-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.popup-container {
    background: var(--container);
    border-radius: 20px;
    padding: 32px 28px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transform: scale(0.95) translateY(15px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.popup-overlay.visible .popup-container {
    transform: scale(1) translateY(0);
}

.popup-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.popup-icon svg {
    width: 24px;
    height: 24px;
}

.popup-icon.success {
    background: rgba(76, 175, 80, 0.15);
    color: #4CAF50;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.2);
}

.popup-icon.error {
    background: rgba(244, 67, 54, 0.15);
    color: #F44336;
    box-shadow: 0 0 15px rgba(244, 67, 54, 0.2);
}

.popup-icon.warning {
    background: rgba(255, 152, 0, 0.15);
    color: #FF9800;
    box-shadow: 0 0 15px rgba(255, 152, 0, 0.2);
}

.popup-icon.confirm {
    background: rgba(74, 144, 226, 0.15);
    color: #4A90E2;
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.2);
}

.popup-title {
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.popup-message {
    font-size: 0.95rem;
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 28px;
    line-height: 1.6;
}

.popup-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.popup-btn {
    flex: 1;
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.popup-btn:active {
    transform: scale(0.96);
}

.popup-btn.primary {
    background: #4A90E2;
    color: white;
}

.popup-btn.primary:hover {
    background: #3A7BC8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.popup-btn.secondary {
    background: rgba(128, 128, 128, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

[data-theme="light"] .popup-btn.secondary {
    background: rgba(0, 0, 0, 0.05);
}

.popup-btn.secondary:hover {
    background: rgba(128, 128, 128, 0.15);
    border-color: rgba(128, 128, 128, 0.3);
}

.popup-btn.success {
    background: #4CAF50;
    color: white;
}

.popup-btn.success:hover {
    background: #43A047;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.popup-btn.danger {
    background: #F44336;
    color: white;
}

.popup-btn.danger:hover {
    background: #E53935;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}