:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #6366f1;
    --accent-hover: #4f46e5;
    --border-color: #334155;
    --danger-color: #f43f5e;
    --success-color: #10b981;
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.06);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* Authentication Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.overlay.active {
    display: flex;
}

.auth-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-premium);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    width: 100%;
    max-width: 400px;
}

.auth-card-wide {
    max-width: 560px;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.mailbox-picker {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    text-align: left;
}

.mailbox-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: var(--bg-primary);
}

.mailbox-card:hover {
    border-color: var(--accent-color);
    background: rgba(56, 189, 248, 0.05);
}

.mailbox-card h4 {
    font-size: 15px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mailbox-card .role {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.mailbox-card .task-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.task-tag {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.task-tag.send { background: rgba(16, 185, 129, 0.12); color: #10b981; border-color: rgba(16, 185, 129, 0.25); }
.task-tag.read { background: rgba(168, 85, 247, 0.12); color: #a855f7; border-color: rgba(168, 85, 247, 0.25); }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--text-secondary);
    font-size: 12px;
}

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

.compose-from {
    font-size: 13px;
    color: var(--text-secondary);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.send-only-banner {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #10b981;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin: 12px 16px 0;
}

.compose-sending {
    opacity: 0.6;
    pointer-events: none;
}

.auth-card h2 {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.auth-card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.auth-card input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 16px;
    outline: none;
}

.auth-card input:focus {
    border-color: var(--accent-color);
}

.auth-card button {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: var(--accent-color);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.auth-card button:hover {
    background: var(--accent-hover);
}

/* App Container Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
}

/* Sidebar styling */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 32px;
}

.logo i {
    color: var(--accent-color);
}

.btn-compose {
    background: linear-gradient(135deg, var(--accent-color), #818cf8);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 24px;
}

.btn-compose:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.icon-paperclip {
    width: 13px;
    height: 18px;
    border: 2px solid currentColor;
    border-left: 0;
    border-radius: 0 9px 9px 0;
    display: inline-block;
    position: relative;
    transform: rotate(42deg);
    margin-right: 3px;
    flex: 0 0 auto;
}

.icon-paperclip::before {
    content: "";
    width: 7px;
    height: 12px;
    border: 2px solid currentColor;
    border-left: 0;
    border-radius: 0 7px 7px 0;
    position: absolute;
    left: 1px;
    top: 1px;
}

.nav-folders {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.nav-item:hover, .nav-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--text-primary);
}

.nav-item.active i {
    color: var(--accent-color);
}

.nav-item .badge {
    margin-left: auto;
    background: var(--accent-color);
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

/* Header */
.app-header {
    height: 70px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: var(--bg-secondary);
}

.search-bar {
    position: relative;
    width: 400px;
}

.search-bar i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-bar input {
    width: 100%;
    padding: 10px 16px 10px 48px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    font-size: 14px;
}

.search-bar input:focus {
    border-color: var(--accent-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* Workspace Panels */
.workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.email-list-panel {
    width: 400px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

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

.panel-header h2 {
    font-size: 18px;
    font-weight: 600;
}

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

.loading-state, .empty-state {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.loading-state i {
    margin-right: 8px;
}

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

.email-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.email-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-left: 4px solid var(--accent-color);
    padding-left: 20px;
}

.email-item.unread .sender {
    font-weight: 700;
    color: var(--text-primary);
}

.email-item.unread .subject {
    font-weight: 600;
}

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

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

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

.email-item .subject {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* Reading Panel */
.reading-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.no-email-selected {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
    gap: 16px;
}

.no-email-selected i {
    font-size: 48px;
}

.email-detail {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 32px;
    overflow-y: auto;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.detail-header h3 {
    font-size: 22px;
    font-weight: 600;
}

.detail-actions {
    display: flex;
    gap: 12px;
}

.btn-action {
    background: var(--bg-tertiary);
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

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

.sender-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

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

.sender-name {
    font-size: 15px;
    font-weight: 500;
}

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

.email-body {
    flex: 1;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    margin-bottom: 40px;
}

/* Reply Box */
.reply-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}

.reply-container h4 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.reply-container textarea {
    width: 100%;
    height: 120px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    resize: none;
}

.reply-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

/* Modal styling */
.modal {
    display: none;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-premium);
    border-radius: 16px;
    width: 600px;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

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

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

.modal-body input {
    border: none;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    padding: 10px 0;
    font-size: 15px;
    outline: none;
}

.modal-body input:focus {
    border-color: var(--accent-color);
}

.modal-body textarea {
    height: 250px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    resize: none;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.hidden {
    display: none !important;
}
