:root {
    --bg-dark: #121212;
    --bg-darker: #222222;
    --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;
}

* {
    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-right: 1px solid var(--border); removed for card style */
    border-radius: 20px;
}

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

.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 {
    font-size: 0.7rem;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.sidebar-nav li.open .arrow {
    transform: rotate(180deg);
}

.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 0;
    font-size: 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
    text-align: left;
}

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

@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;
}

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

.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;
}

.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;
}

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

.mail-item-sender {
    font-weight: 700;
    font-size: 0.95rem;
}

.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;
}

.mail-item-snippet {
    font-size: 0.8rem;
    color: #999;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -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-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: 1rem;
    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;
}

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

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

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

/* Action Section / Reply */
.action-section-container {
    background-color: var(--container);
    border-radius: 20px;
    padding: 15px;
    margin-top: 15px;
    flex-shrink: 0;
    height: 350px;
    /* Fixed height to prevent jumps */
    display: flex;
    flex-direction: column;
}

.reply-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
}

.action-section {
    background-color: transparent;
    border-radius: 0;
    padding: 0;
}

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

.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 */
}

/* 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;
}

/* 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;
}

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

/* Meta Inputs */
.reply-meta {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

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

.meta-row strong {
    color: white;
    min-width: 50px;
}

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

.meta-input:disabled {
    color: #bbb;
    cursor: default;
}

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

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

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

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

/* Quoted Text */
.reply-quoted-text {
    color: #666;
    font-size: 0.85rem;
    margin-top: 10px;
    /* Reduced margin */
    border-left: 2px solid #444;
    padding-left: 8px;
    margin-bottom: 15px;
    /* Reduced margin */
    max-height: 60px;
    /* Limit height of quoted text */
    overflow: hidden;
    /* Hide overflow */
    text-overflow: ellipsis;
}

/* Send Button - Centered Pill */
.reply-footer {
    display: flex;
    justify-content: center;
    margin-top: auto;
    padding-bottom: 10px;
}

.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: block;
    margin: 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background-color: #4A4A4A;
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s;
    position: relative;
    z-index: 10;
}

.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: 50px 30px 30px 30px;
    margin-top: -22px;
    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;
}