/* ── Local Fonts (PWA offline-first) ─────────────────────────────────────── */
@font-face {
    font-family: 'Inter';
    src: url('assets/fonts/inter-variable.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: 'Material Icons Outlined';
    src: url('assets/fonts/material-icons-outlined.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: block;
}

.material-icons-outlined {
    font-family: 'Material Icons Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
}

:root {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-hover: #f1f3f4;
    --bg-active: #e8f0fe;

    --text-primary: #202124;
    --text-secondary: #5f6368;

    --border-color: #e0e0e0;
    --primary-color: #1a73e8;

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --list-width: 360px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: row;
    height: calc(100vh - 56px);
    margin-top: 56px;
    width: 100vw;
    padding: 12px;
    gap: 12px;
    box-sizing: border-box;
    background-color: #f3f4f6;
}

/* Top App Bar */
.top-app-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
}

.top-bar-left {
    display: flex;
    align-items: center;
    width: auto;
    flex-shrink: 0;
}

.top-bar-right, .top-bar-center {
    display: flex;
    align-items: center;
}

.top-bar-center {
    position: absolute;
    left: 16px;
    right: 80px;
    max-width: 600px;
    display: flex;
    align-items: center;
    pointer-events: none;
}

.logo-text {
    font-size: 18px;
    font-weight: 500;
    margin-left: 12px;
    color: var(--text-primary);
}

.settings-popover {
    position: absolute;
    top: 50px;
    right: 16px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 280px;
    z-index: 1000;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    background-color: transparent;
    transition: background-color 0.2s;
}

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

.menu-icon {
    margin-right: 16px;
    color: var(--text-secondary);
}

.menu-text {
    display: flex;
    flex-direction: column;
}

.menu-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.menu-subtext {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.hidden {
    display: none !important;
}

/* License Modal */
.license-info-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.license-info-container p {
    margin: 0;
}

.license-input-group {
    display: flex;
    gap: 8px;
    width: 100%;
}

.license-text-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
}

/* ====== Staging Summary Modal ====== */
.staging-metrics {
    display: flex;
    gap: 24px;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.staging-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.staging-metric-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.staging-metric-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.staging-folder-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s;
}

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

.staging-folder-row input[type="checkbox"] {
    flex-shrink: 0;
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

.staging-folder-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.staging-folder-meta {
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.staging-date-range {
    display: flex;
    align-items: center;
    gap: 6px;
}

.staging-date-input {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: inherit;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    padding: 2px 4px;
    cursor: pointer;
    outline: none;
    width: 130px;
}

.staging-date-input:focus {
    border-bottom-color: var(--primary-color);
}

.staging-date-sep {
    font-size: 14px;
    color: var(--text-secondary);
}

.settings-section-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.storage-bar-container {
    width: 100%;
    height: 8px;
    background-color: var(--bg-hover);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

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

.storage-text {
    font-size: 11px;
    color: var(--text-secondary);
}

.license-status-container {
    margin-bottom: 8px;
}

/* Content Area: Menu + Panes */
.content-area {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0;
}

.panes-container {
    display: flex;
    flex-grow: 1;
    min-height: 0;
    gap: 12px;
}

/* Resizers */
.resizer {
    width: 12px;
    background-color: transparent;
    cursor: col-resize;
    z-index: 10;
    margin-left: -12px;
    margin-right: -12px;
    flex-shrink: 0;
    position: relative;
    touch-action: none;
}

.resizer::after {
    content: '';
    position: absolute;
    left: 5px;
    right: 5px;
    top: 0;
    bottom: 0;
    background-color: transparent;
    transition: background-color 0.2s;
    border-radius: 2px;
}

.resizer:hover::after,
.resizer.resizing::after {
    background-color: var(--primary-color);
}

body.resizing {
    cursor: col-resize;
    user-select: none;
}

body.resizing .sidebar,
body.resizing .email-list-pane {
    transition: none !important;
}

/* Common Components */
.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background-color 0.2s;
}

.icon-button:hover {
    background-color: var(--bg-hover);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 14px;
    flex-shrink: 0;
}

.avatar.large {
    width: 48px;
    height: 48px;
    font-size: 18px;
}

.bg-purple {
    background-color: #9c27b0;
}

.bg-green {
    background-color: #0f9d58;
}

.bg-orange {
    background-color: #ff9800;
}

/* Left Navigation Bar */
.sidebar {
    flex: 0 0 var(--sidebar-width);
    background-color: var(--bg-secondary);
    border: none;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: 100%;
    padding-top: 10px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), flex-basis 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    margin: 0;
}

/* Scrollable nav section — fills available space */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Submenu Styles */
.nav-item.has-submenu {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    height: auto;
}

.nav-item-content {
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 48px;
    border-radius: 24px;
    cursor: pointer;
    width: 100%;
}

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

.expand-icon {
    margin-left: auto;
    font-size: 20px;
    transition: transform 0.2s;
}

.nav-item.expanded .expand-icon {
    transform: rotate(180deg);
}

.nav-submenu {
    list-style: none;
    padding: 2px 0 2px 32px;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.nav-submenu-item {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    position: relative;
}

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

.nav-submenu-item.active {
    background-color: var(--bg-active);
    color: var(--primary-color);
    font-weight: 500;
}

.nav-submenu-item .nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
}

.archive-options-btn {
    opacity: 0;
    padding: 2px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
}

.nav-submenu-item:hover .archive-options-btn {
    opacity: 1;
}

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

.options-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 2px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
    min-width: 120px;
    display: none;
}

.options-menu a {
    display: block;
    padding: 8px 12px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
}

.options-menu a:hover {
    background-color: var(--bg-hover);
}

.options-menu a.danger {
    color: #e53935;
}

.options-menu a.danger:hover {
    background-color: #ffebee;
}

.nav-list {
    list-style: none;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar.collapsed {
    flex: 0 0 var(--sidebar-collapsed-width);
}

.sidebar-header {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    flex-shrink: 0;
}

.logo-text {
    font-weight: 500;
    font-size: 20px;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
    color: var(--text-primary);
}

.sidebar.collapsed .logo-text {
    opacity: 0;
    pointer-events: none;
}

.nav-list {
    list-style: none;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 48px;
    border-radius: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-item .material-icons-outlined {
    margin-right: 18px;
}

.sidebar.collapsed .nav-item,
.sidebar.collapsed .nav-item-content {
    padding: 0;
    justify-content: center;
    border-radius: 50%;
    width: 48px;
    margin: 0 auto;
}

.sidebar.collapsed .nav-item .material-icons-outlined {
    margin-right: 0;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed #active-archive-subtext,
.sidebar.collapsed .expand-icon,
.sidebar.collapsed .folders-header {
    display: none !important;
}

.sidebar.collapsed .nav-submenu {
    display: none !important;
}

.nav-item:not(.has-submenu):hover {
    background-color: var(--bg-hover);
}

.sidebar.collapsed .nav-item.has-submenu {
    background: transparent;
    padding: 0;
    margin: 0 auto;
}

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

/* Email List Pane */
.email-list-pane {
    flex: 0 0 var(--list-width);
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    margin: 0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
}

.search-container {
    width: 100%;
    padding: 0;
    margin: 0;
    margin-left: calc(var(--sidebar-width) + 12px);
    pointer-events: auto;
}

.search-bar {
    background-color: var(--bg-primary);
    border-radius: 8px;
    height: 44px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border: 1px solid transparent;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.search-bar:focus-within {
    border-color: var(--primary-color);
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    margin-left: 12px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
}

.search-icon {
    color: var(--text-secondary);
}

.search-clear-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
}

.search-clear-btn .material-icons-outlined {
    font-size: 18px;
}

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

.search-bar.has-query {
    border-color: var(--primary-color);
    background-color: #e8f0fe;
}

.search-no-results {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.search-no-results .material-icons-outlined {
    font-size: 48px;
    display: block;
    margin-bottom: 8px;
    opacity: 0.4;
}

.email-list {
    overflow-y: auto;
    flex-grow: 1;
    position: relative;
}

.scroll-indicator-top,
.scroll-indicator-bottom {
    position: absolute;
    left: 0;
    right: 0;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: opacity 0.3s;
    color: var(--text-secondary);
    z-index: 10;
}

.scroll-indicator-top {
    top: 0;
    background: linear-gradient(to bottom, var(--bg-secondary) 0%, transparent 100%);
}

.scroll-indicator-bottom {
    bottom: 0;
    background: linear-gradient(to top, var(--bg-secondary) 0%, transparent 100%);
}

/* Custom Scrollbar for list */
.email-list::-webkit-scrollbar {
    width: 8px;
}

.email-list::-webkit-scrollbar-track {
    background: transparent;
}

.email-list::-webkit-scrollbar-thumb {
    background: #dcdcdc;
    border-radius: 4px;
}

.email-list::-webkit-scrollbar-thumb:hover {
    background: #c0c0c0;
}

.email-item {
    padding: 16px;
    display: flex;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.email-item:hover {
    background-color: rgb(249, 250, 251);
    box-shadow: inset 4px 0 0 var(--border-color);
}

.email-item.active {
    background-color: var(--bg-active);
    box-shadow: inset 4px 0 0 var(--primary-color);
}

.email-item-content {
    flex-grow: 1;
    overflow: hidden;
}

.email-item-header {
    margin-bottom: 2px;
}

.email-item-subheader {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
    gap: 8px;
}

.sender {
    font-weight: 500;
    font-size: 15px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.time {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

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

.unread .sender,
.unread .subject {
    font-weight: 600;
}

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

/* Email View Pane */
.email-view-pane {
    flex: 1;
    min-width: 0;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.empty-state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    padding: 32px;
    text-align: center;
    font-size: 14px;
}

/* Mobile-only back button — hidden on desktop */
#mobile-back-btn {
    display: none;
}

.email-view-header {
    height: 64px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    z-index: 10;
}

.actions {
    display: flex;
    gap: 4px;
}

.email-content {
    padding: 32px 48px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.email-subject {
    font-size: 26px;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 32px;
}

.email-meta {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
}

.meta-details {
    flex-grow: 1;
}

.sender-info {
    margin-bottom: 4px;
}

.sender-name {
    font-weight: 600;
    font-size: 15px;
    margin-right: 8px;
}

.sender-email {
    font-size: 13px;
    color: var(--text-secondary);
}

.receiver-info {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

.receiver-info .arrow {
    font-size: 16px;
}

.email-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.attachments {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.attachment-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.attachment-pill:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.email-body {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
}

.email-body p {
    margin-bottom: 16px;
}

/* ====== Upload Archive Modal ====== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    display: flex;
    background-color: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background-color: var(--bg-secondary);
    border-radius: 16px;
    width: 520px;
    max-width: 90vw;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.25s ease;
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 12px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.modal-body {
    padding: 8px 24px 16px;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: border-color 0.2s, background-color 0.2s;
    cursor: pointer;
}

.drop-zone.drag-over {
    border-color: var(--primary-color);
    background-color: rgba(26, 115, 232, 0.06);
}

.drop-zone-icon {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 12px;
    opacity: 0.8;
}

.drop-zone-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.drop-zone-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.drop-zone-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    margin: 20px 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.drop-zone-divider::before,
.drop-zone-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background-color: var(--border-color);
}

.browse-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: 1px solid var(--primary-color);
    background-color: transparent;
    color: var(--primary-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

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

.browse-btn .material-icons-outlined {
    font-size: 20px;
}

/* File Selected Indicator */
.file-selected {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-top: 16px;
    background-color: var(--bg-active);
    border-radius: 10px;
    border: 1px solid rgba(26, 115, 232, 0.2);
}

.file-selected-icon {
    font-size: 28px;
    color: var(--primary-color);
}

.file-selected-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

.file-selected-size {
    font-size: 12px;
    color: var(--text-secondary);
}

.file-remove-btn {
    flex-shrink: 0;
}

/* Modal Footer */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 24px 20px;
}

.modal-btn {
    padding: 8px 24px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background-color 0.15s, opacity 0.15s;
}

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

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

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

.modal-btn-primary:hover:not(:disabled) {
    background-color: #1765cc;
}

.modal-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal Loading State */
.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.loading-status {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* ====== Mobile Breakpoint ====== */
@media (max-width: 768px) {
    /* Hide sidebar and resizers on mobile */
    .sidebar,
    .resizer {
        display: none !important;
    }

    /* Stack panes and fill viewport */
    .app-container {
        flex-direction: column;
    }

    .content-area {
        width: 100%;
    }

    .panes-container {
        flex-direction: column;
        flex-grow: 1;
    }

    /* Default: show list pane, hide view pane */
    .email-list-pane {
        width: 100% !important;
        margin: 0;
        border-radius: 0;
        flex-shrink: 0;
    }

    .email-view-pane {
        display: none;
        width: 100%;
        margin: 0;
        border-radius: 0;
    }

    /* When .view-mode is active: show view pane, hide list pane */
    .app-container.view-mode .email-list-pane {
        display: none;
    }

    .app-container.view-mode .email-view-pane {
        display: flex;
        width: 100%;
        margin: 8px;
    }

    /* Show mobile-only back button */
    #mobile-back-btn {
        display: flex;
    }

    /* Adjust view header for mobile */
    .email-view-header {
        justify-content: space-between;
    }
}

/* ====== License Gate Modal ====== */
.license-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.license-modal {
    background-color: var(--bg-secondary);
    border-radius: 16px;
    width: 440px;
    max-width: 92vw;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.license-modal-header {
    padding: 28px 28px 8px;
    text-align: center;
}

.license-modal-header .license-icon {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.license-modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.license-modal-header p {
    font-size: 13px;
    color: var(--text-secondary);
}

.license-modal-body {
    padding: 20px 28px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Key input field */
.license-key-input {
    width: 100%;
    padding: 12px 16px;
    font-family: 'Inter', monospace;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 1.5px;
    text-align: center;
    text-transform: uppercase;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    outline: none;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.license-key-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.license-key-input.input-error {
    border-color: #e53935;
    box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.12);
}

.license-key-input.input-success {
    border-color: #0f9d58;
    box-shadow: 0 0 0 3px rgba(15, 157, 88, 0.12);
}

/* Status / feedback area */
.license-status {
    min-height: 20px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    transition: color 0.2s;
}

.license-status.status-error {
    color: #e53935;
}

.license-status.status-success {
    color: #0f9d58;
}

.license-status.status-info {
    color: var(--text-secondary);
}

/* Expired alert banner */
.license-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
}

.license-alert.alert-warning {
    background-color: #fff3e0;
    color: #e65100;
    border: 1px solid #ffe0b2;
}

.license-alert.alert-warning .material-icons-outlined {
    font-size: 20px;
    flex-shrink: 0;
}

/* Verify button */
.license-verify-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background-color: var(--primary-color);
    color: white;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.15s, opacity 0.15s;
}

.license-verify-btn:hover:not(:disabled) {
    background-color: #1765cc;
}

.license-verify-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Inline spinner for verify button loading state */
.license-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ── Viewing Mode (dismissible sidebar shortcut) ── */
.license-modal-overlay.viewing-mode {
    background-color: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
}

.license-modal-overlay.viewing-mode .license-modal {
    cursor: default;
}

/* License detail grid */
.license-detail-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.license-detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.license-detail-row:last-child {
    border-bottom: none;
}

.license-detail-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.license-detail-value {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
}

.license-key-masked {
    font-family: 'Inter', monospace;
    letter-spacing: 1px;
}

/* Status badge */
.license-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.license-badge .material-icons-outlined {
    font-size: 15px;
}

.badge-valid {
    background-color: #e8f5e9;
    color: #2e7d32;
}

/* Close button in viewing mode */
.license-close-btn {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.license-close-btn:hover:not(:disabled) {
    background-color: var(--border-color);
}

/* ====== Folder Navigation ====== */
.folders-container {
    padding: 0 12px;
}

.folders-separator {
    height: 1px;
    background-color: var(--border-color);
    margin: 8px 0;
}

.folders-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.folders-header .material-icons-outlined {
    font-size: 18px;
}

.folders-list {
    list-style: none;
    padding: 4px 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.tree-node {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.tree-sub-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.tree-sub-list.collapsed {
    display: none;
}

.folder-caret {
    font-size: 16px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background-color 0.15s;
    margin-right: 4px;
    flex-shrink: 0;
}

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

.folder-caret-spacer {
    width: 24px;
    flex-shrink: 0;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color 0.15s, color 0.15s;
}

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

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

.folder-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.folder-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.folders-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    color: var(--text-secondary);
    font-size: 12px;
    font-style: italic;
}

.folders-empty .material-icons-outlined {
    font-size: 18px;
    opacity: 0.5;
}

.folders-container {
    flex: 1;
    overflow-y: auto;
}

.sidebar.collapsed .folders-container {
    display: none;
}

/* ====== License Sidebar Subtext ====== */
.license-label-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#sidebar-license-subtext {
    font-size: 11px;
    font-weight: normal;
    margin-top: 2px;
}

#sidebar-license-subtext.status-active {
    color: #0f9d58;
}

#sidebar-license-subtext.status-inactive {
    color: #ff9800;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed #sidebar-license-subtext {
    display: none;
}

/* ====== License Modal Cancel & Purchase ====== */
.license-modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.license-modal-actions .license-verify-btn {
    flex: 1;
}

.modal-btn-secondary {
    flex: 1;
    padding: 12px 24px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-hover);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

.purchase-plan-link {
    display: block;
    text-align: center;
    margin-top: 12px;
    font-size: 13px;
    color: var(--primary-color);
    text-decoration: none;
}

.purchase-plan-link:hover {
    text-decoration: underline;
}