@font-face {
    font-family: 'FrameworkSans';
    src: url('../components/fonts/FrameworkSans-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'FrameworkSans';
    src: url('../components/fonts/FrameworkSans-Light.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: 'FrameworkSans';
    src: url('../components/fonts/FrameworkSans-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'FrameworkSans';
    src: url('../components/fonts/FrameworkSans-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'FrameworkSans-Caps-Bold';
    src: url('../components/fonts/FrameworkSans-Caps-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    /* text-transform: uppercase; */
    letter-spacing: 0.05em;
}

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

:root {
    --primary-color: #1a73e8;
    --primary-color-rgb: 26, 115, 232;
    --primary-hover: #1765cc;
    --secondary-color: #ea4335;
    --background: #f6f8fc;
    --surface: #ffffff;
    --surface-hover: #f1f3f4;
    --border: #F4F4F4;
    --text-primary: #100F0A;
    --text-secondary: #5f6368;
    --text-muted: #80868b;
    --success: #34a853;
    --error: #ea4335;
    --warning: #fbbc04;
    --sidebar-width: 220px;
}

body {
    font-family: 'FrameworkSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
}

button {
    font-family: 'FrameworkSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    color: var(--text-primary);
    text-decoration: none;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    border-radius: 8px;
    padding: 48px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
    animation: modalSlideIn 0.3s ease;
}

.modal-large {
    max-width: 600px;
    padding: 40px;
}

.modal-header {
    margin-bottom: 32px;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.modal-header p {
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 300;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

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

/* Form */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 13px 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 16px;
    transition: all 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.form-group textarea {
    resize: vertical;
    min-height: 200px;
    font-family: 'Roboto', sans-serif;
}

.login-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    text-align: center;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.login-divider span {
    padding: 0 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Buttons */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.1s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    text-transform: none;
    letter-spacing: 0;
}

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

.btn-primary:hover {
    box-shadow: 0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
    background: var(--primary-hover);
}

.btn-primary:active {
    box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 2px 0 rgba(60, 64, 67, 0.15);
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-hover);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.1s;
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.btn-icon:hover {
    background: rgba(60, 64, 67, 0.08);
}

.btn-action {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 12px;
    transition: all 0.1s;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: inherit;
    font-weight: 500;
}

.btn-action:hover {
    background: rgba(60, 64, 67, 0.08);
    color: var(--text-primary);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-icon-back {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 12px;
    transition: all 0.1s;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-weight: 500;
}

.btn-icon-back:hover {
    background: rgba(60, 64, 67, 0.08);
    color: var(--text-primary);
}

.btn-icon-back svg {
    width: 20px;
    height: 20px;
}

.btn-action svg {
    width: 18px;
    height: 18px;
}

.btn-loader {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 0.6s linear infinite;
}

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

.error-message {
    color: var(--error);
    font-size: 14px;
    margin-top: 16px;
    text-align: center;
    min-height: 20px;
}

.error-message:empty {
    display: none;
}

/* App Layout */
#app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 16px 16px 0 16px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    margin-left: 10px;
}

.sidebar-logo {
    width: 42px;
    height: 42px;
    /* border-radius: 13px; */
    /* box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); */
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.5px;
    font-family: 'FrameworkSans-Caps-Bold', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
}

.btn-compose {
    width: 100%;
    padding: 16px 24px;
    font-size: 14px;
    font-weight: 500;
    margin-top: 8px;
    margin-bottom: 16px;
    justify-content: center;
    border-radius: 20px;
    font-family: 'FrameworkSans-Caps-Bold', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
}

.btn-compose svg {
    margin-right: 8px;
    width: 20px;
    height: 20px;
}

.sidebar-section {
    flex: 1;
    /* padding: 16px; */
}

.folder-list {
    list-style: none;
    /* padding: 0 8px; */
}

.folder-item {
    padding: 11px 22px;
    border-radius: 0 20px 20px 0;
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 2px;
    color: var(--text-primary);
    font-weight: 500;
}

.folder-item:hover {
    background: #f4f4f4;
}

.folder-item.active {
    background: #DCECFF;
    color: #005ECC;
}

.folder-icon {
    font-size: 20px;
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.folder-info {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.folder-name {
    font-size: 14px;
    letter-spacing: 0.2px;
}

.folder-count {
    background: transparent;
    padding: 0 8px;
    border-radius: 10px;
    font-size: 14px;
    min-width: 20px;
    text-align: center;
    color: var(--text-secondary);
}

.folder-item.active .folder-count {
    color: #005ECC;
}

.sidebar-footer {
    margin-top: auto;
    padding: 8px;
    margin-bottom: 8px;
}

.user-info {
    padding: 8px 12px;
    background: transparent;
    border-radius: 28px;
    margin-bottom: 4px;
    font-size: 13px;
}

.user-email {
    color: var(--text-primary);
    font-weight: 500;
}

.logout-btn {
    width: 100%;
    background: white;
    color: var(--error);
    border: 1px solid var(--border);
    font-weight: 500;
}

.logout-btn:hover {
    background: #fef0f0;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
}

.toolbar {
    padding: 16px 36px 16px 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: 'FrameworkSans-Caps-Bold', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-menu-btn {
    display: none;
}

.folder-title {
    font-size: 20px;
    font-weight: 400;
    color: var(--text-primary);
}

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

#refreshBtn {
    display: none;
}

/* User Menu */
.user-menu-wrapper {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.user-menu-btn:hover {
    opacity: 0.8;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    min-width: 240px;
    z-index: 1000;
    overflow: hidden;
}

.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

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

.user-dropdown-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-dropdown-info {
    flex: 1;
    min-width: 0;
}

.user-dropdown-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.user-dropdown-item {
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 0.2s;
}

.user-dropdown-item:hover {
    background: var(--surface-hover);
}

.user-dropdown-logout {
    color: var(--error);
    border-top: 1px solid var(--border);
}

/* Email List */
.email-list-container {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding: 0 24px 24px 24px;
}

.email-list {
    list-style: none;
}

.email-item {
    padding: 12px 16px 12px 16px;
    /* border-bottom: 0.5px solid var(--border); */
    cursor: pointer;
    transition: background-color 0.1s;
    display: flex;
    align-items: center;
    gap: 16px;
    border-radius: 20px;
}

.email-item:hover {
    background-color: rgba(60, 64, 67, 0.03);
}

.email-item.unread {
    background: transparent;
}

.email-item.unread:hover {
    background-color: rgba(60, 64, 67, 0.03);
}

.email-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
}

.email-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.email-divider {
    height: 1px;
    background: var(--border);
    margin: 0;
    margin-left: 60px; /* Align with email content (avatar width + gap) */
    margin-right: 15px;
}

.email-item .email-check {
    width: 20px;
    height: 20px;
    display: none;
}

.email-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.email-from {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 180px;
}

.email-item.unread .email-from {
    color: var(--text-primary);
}

.email-subject-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.email-subject {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-item:not(.unread) .email-subject {
    font-weight: 400;
}

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

.email-preview-text {
    color: var(--text-secondary);
}

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

.email-date {
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
    text-align: right;
}

/* Email Viewer */
.email-viewer {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    background: var(--surface);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.email-viewer-header {
    padding: 16px 36px;
    /* border-bottom: 1px solid var(--border); */
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    flex-shrink: 0;
}

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

.email-viewer-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    min-height: 0;
    height: 100%;
}

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

#emailDetails,
#emailBody,
#emailAttachments {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

#emailDetails > .email-content-wrapper,
#emailBody > .email-content-wrapper,
#emailAttachments > .email-content-wrapper {
    overflow: visible;
}

.email-details {
    background: var(--surface);
    padding: 16px 0;
    margin-bottom: 0;
}

.email-sender-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.email-sender-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
}

.email-sender-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.email-sender-info {
    flex: 1;
    min-width: 0;
}

.email-sender-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    word-wrap: break-word;
}

.email-sender-email {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    word-wrap: break-word;
}

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

.email-detail-row {
    display: flex;
    padding: 8px 0;
    font-size: 14px;
}

.email-detail-label {
    color: var(--text-secondary);
    width: 70px;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
}

.email-detail-value {
    color: var(--text-primary);
    flex: 1;
    font-size: 14px;
}

.email-body {
    background: var(--surface);
    padding: 24px 0;
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Email Viewer Loading */
.email-viewer-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.email-viewer-loading .spinner {
    margin-bottom: 0;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    padding: 40px;
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.3;
    color: var(--text-secondary);
}

.empty-state h3 {
    font-size: 22px;
    font-weight: 400;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 14px;
    color: var(--text-muted);
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
}

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

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

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Gmail specific adjustments */
.form-actions {
    margin-top: 0;
}

.btn-compose:hover {
    box-shadow: 0 2px 3px 0 rgba(60, 64, 67, 0.3), 0 6px 10px 4px rgba(60, 64, 67, 0.15);
}

/* Floating Compose Button */
.floating-compose-btn {
    display: none;
}

.error-message {
    color: var(--error);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 16px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 4px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
    background-clip: padding-box;
}

/* Responsive */
@media (max-width: 1024px) {
    /* Tablet adjustments */
    .sidebar {
        width: 200px;
    }
    
    .email-viewer {
        left: 200px;
    }
    
    .toolbar {
        padding: 16px 24px 16px 24px;
    }
    
    .email-list-container {
        padding: 0 16px 16px 16px;
    }
    
    .email-sender-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .email-sender-avatar {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
    
    .email-sender-info {
        width: 100%;
    }
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {
    /* Mobile landscape and small tablets */
    .mobile-menu-btn {
        display: flex;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.sidebar-open {
        transform: translateX(0);
    }
    
    .email-viewer {
        left: 0;
        right: 0;
    }
    
    .toolbar {
        padding: 16px;
        position: relative;
    }
    
    .folder-title {
        font-size: 18px;
    }
    
    .email-list-container {
        padding: 0 12px 12px 12px;
    }
    
    .email-item {
        position: relative;
        flex-direction: row;
        align-items: flex-start;
        gap: 12px;
        padding: 12px 12px;
    }
    
    .email-info {
        flex: 1;
        flex-direction: column;
        gap: 4px;
        min-width: 0;
        align-items: flex-start;
        text-align: left;
    }
    
    .email-from {
        min-width: auto;
        font-size: 13px;
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: calc(100% - 60px); /* Leave space for date */
        font-weight: 600;
        text-align: left;
    }
    
    .email-subject-container {
        margin-top: 2px;
        width: 100%;
        text-align: left;
    }
    
    .email-subject {
        font-size: 13px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        line-height: 1.4;
        text-align: left;
    }
    
    .email-preview {
        display: none;
    }
    
    .email-date {
        font-size: 11px;
        position: absolute;
        top: 12px;
        right: 12px;
        white-space: nowrap;
    }
    
    .email-avatar {
        width: 40px;
        height: 40px;
        font-size: 14px;
        flex-shrink: 0;
    }
    
    .email-divider {
        margin-left: 52px;
        margin-right: 12px;
    }
    
    .modal-content {
        padding: 32px 24px;
        max-width: 95%;
        max-height: 90vh;
    }
    
    .modal-large {
        max-width: 95%;
    }
    
    /* Override modal centering for compose on mobile */
    #composeModal.modal {
        align-items: flex-end;
        justify-content: center;
        padding: 0;
    }
    
    .modal-compose {
        width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        max-width: 100vw !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        right: 0 !important;
        transform: translateY(100%) !important;
        animation: slideUpMobileFull 0.3s ease-out !important;
        position: fixed !important;
    }
    
    #composeModal.modal .modal-compose {
        transform: translateY(0) !important;
    }
    
    @keyframes slideUpMobileFull {
        from {
            transform: translateY(100%) !important;
        }
        to {
            transform: translateY(0) !important;
        }
    }
    
    .email-viewer-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .email-viewer-content {
        padding: 16px;
    }
    
    .btn-icon-back {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .btn-action {
        font-size: 13px;
        padding: 6px 12px;
    }
    
    .btn-action span {
        display: none;
    }
    
    .email-actions {
        flex-wrap: wrap;
    }
    
    .sidebar-brand {
        margin-left: 0;
    }
    
    .btn-compose {
        display: none;
    }
    
    .floating-compose-btn {
        display: flex;
        position: fixed;
        bottom: 24px;
        right: 24px;
        width: 56px;
        height: 56px;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.12);
        align-items: center;
        justify-content: center;
        z-index: 999;
        transition: all 0.2s ease;
    }
    
    .floating-compose-btn:hover {
        background: var(--primary-hover);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), 0 6px 20px rgba(0, 0, 0, 0.15);
        transform: translateY(-2px);
    }
    
    .floating-compose-btn:active {
        transform: translateY(0);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    }
    
    .floating-compose-btn svg {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 480px) {
    /* Mobile portrait */
    body {
        overflow-x: hidden;
    }
    
    #app {
        position: relative;
    }
    
    .sidebar {
        width: 85vw;
        max-width: 320px;
    }
    
    .sidebar-brand {
        gap: 10px;
        padding: 12px 16px 0 16px;
    }
    
    .sidebar-logo {
        width: 36px;
        height: 36px;
    }
    
    .sidebar-logo-text {
        font-size: 18px;
    }
    
    .btn-compose {
        display: none;
    }
    
    .floating-compose-btn {
        bottom: 20px;
        right: 20px;
        width: 52px;
        height: 52px;
    }
    
    .floating-compose-btn svg {
        width: 22px;
        height: 22px;
    }
    
    .folder-item {
        padding: 10px 16px;
        font-size: 13px;
        gap: 14px;
    }
    
    .folder-icon {
        font-size: 18px;
        width: 18px;
    }
    
    .folder-name {
        font-size: 13px;
    }
    
    .folder-count {
        font-size: 12px;
    }
    
    .sidebar-footer {
        padding: 8px;
        margin-bottom: 8px;
    }
    
    .user-info {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .logout-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .toolbar {
        padding: 12px 16px;
    }
    
    .folder-title {
        font-size: 16px;
    }
    
    .email-list-container {
        padding: 0 8px 8px 8px;
    }
    
    .email-item {
        position: relative;
        padding: 14px 12px;
        border-radius: 12px;
    }
    
    .email-info {
        flex: 1;
        flex-direction: column;
        gap: 4px;
        min-width: 0;
        align-items: flex-start;
        text-align: left;
    }
    
    .email-avatar {
        width: 44px;
        height: 44px;
        font-size: 15px;
    }
    
    .email-divider {
        margin-left: 56px;
        margin-right: 12px;
    }
    
    .email-from {
        font-size: 14px;
        min-width: auto;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: calc(100% - 70px); /* Leave space for date */
        text-align: left;
    }
    
    .email-subject-container {
        width: 100%;
        text-align: left;
    }
    
    .email-subject {
        font-size: 13px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.4;
        text-align: left;
    }
    
    .email-preview {
        display: none;
    }
    
    .email-date {
        font-size: 11px;
        top: 14px;
        right: 12px;
    }
    
    .email-viewer-header {
        padding: 12px;
    }
    
    .email-viewer-content {
        padding: 12px;
    }
    
    .email-content-wrapper {
        padding: 0;
    }
    
    .email-sender-header {
        padding-bottom: 16px;
        margin-bottom: 16px;
    }
    
    .email-sender-avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .email-sender-name {
        font-size: 14px;
    }
    
    .email-sender-email {
        font-size: 12px;
    }
    
    .email-sender-date {
        font-size: 11px;
    }
    
    .email-body {
        padding: 16px 0;
        font-size: 13px;
    }
    
    .modal-content {
        padding: 24px 16px;
        border-radius: 12px;
    }
    
    .modal-header h2 {
        font-size: 20px;
    }
    
    .modal-header p {
        font-size: 14px;
    }
    
    .form-group input,
    .form-group textarea {
        padding: 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .form-group textarea {
        min-height: 150px;
    }
    
    .modal-compose {
        width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        max-width: 100vw !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        right: 0 !important;
        transform: translateY(100%) !important;
        animation: slideUpMobileFull 0.3s ease-out !important;
        position: fixed !important;
    }
    
    #composeModal.modal .modal-compose {
        transform: translateY(0) !important;
    }
    
    #composeModal.modal {
        align-items: flex-end;
        justify-content: center;
        padding: 0;
    }
    
    @keyframes slideUpMobileFull {
        from {
            transform: translateY(100%) !important;
        }
        to {
            transform: translateY(0) !important;
        }
    }
    
    .compose-header {
        padding: 12px 16px;
    }
    
    .compose-title {
        font-size: 13px;
    }
    
    .compose-field {
        min-height: 44px;
    }
    
    .compose-label {
        min-width: 60px;
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .compose-input {
        padding: 10px 0;
        font-size: 14px;
    }
    
    .compose-textarea {
        padding: 12px;
        font-size: 14px;
    }
    
    .compose-actions {
        padding: 4px 12px;
    }
    
    .compose-footer {
        padding: 10px 12px;
    }
    
    .btn-send {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .confirm-dialog-content {
        max-width: 85vw;
        padding: 20px;
    }
    
    .confirm-dialog-content h3 {
        font-size: 18px;
    }
    
    .confirm-dialog-content p {
        font-size: 13px;
    }
    
    .email-attachment-chip,
    .compose-attachment-chip {
        max-width: 100%;
        width: 100%;
    }
    
    .email-attachment-chip-name,
    .compose-attachment-chip-name {
        max-width: 100%;
    }
    
    .btn-primary {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .btn-secondary {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    /* Hide labels in mobile view for better space usage */
    .email-detail-label {
        display: none;
    }
    
    .email-detail-row {
        flex-direction: column;
        gap: 4px;
    }
    
    .email-detail-value {
        font-size: 13px;
    }
    
    .toast {
        bottom: 16px;
        left: 16px;
        right: 16px;
        transform: none;
        max-width: 100%;
        min-width: auto;
        width: auto;
    }
    
    @keyframes slideUpToast {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* Preloader */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.preloader-content {
    text-align: center;
}

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

.preloader-logo {
    width: 120px;
    height: 120px;
    border-radius: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.preloader-progress {
    width: 200px;
    height: 10px;
    background: var(--border);
    border-radius: 10px;
    margin: 20px auto 0;
    overflow: hidden;
}

.preloader-progress-bar {
    height: 100%;
    background: var(--primary-color);
    border-radius: 10px;
    animation: progressAnimation 2s ease-out forwards;
}

@keyframes progressAnimation {
    from {
        width: 0%;
    }
    to {
        width: 100%;
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    animation: slideUpToast 0.3s ease-out;
    min-width: 250px;
    max-width: 500px;
}

@keyframes slideUpToast {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-size: 14px;
}

.toast-icon {
    color: var(--success);
    flex-shrink: 0;
}

.toast-message {
    font-weight: 500;
}

/* Confirmation Dialog */
.confirm-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.confirm-dialog-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.2s ease-out;
}

.confirm-dialog-content h3 {
    margin: 0 0 12px 0;
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
}

.confirm-dialog-content p {
    margin: 0 0 24px 0;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.confirm-dialog-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.confirm-dialog-actions .btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
}

/* Compose Modal - Gmail Style */
.modal-compose {
    padding: 0;
    width: 600px;
    max-width: 90vw;
    height: 90vh;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 24px 24px 0 0;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
    }
    to {
        transform: translate(-50%, 0);
    }
}

.compose-drag-handle {
    display: none;
}

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

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

.compose-header-actions {
    display: flex;
    gap: 4px;
}

.btn-icon-small {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 12px;
    transition: all 0.1s;
    font-size: 16px;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-small:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.compose-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.compose-field {
    display: flex;
    border-bottom: 1px solid var(--border);
    min-height: 48px;
    align-items: center;
    transition: opacity 0.2s ease;
}

.compose-field.compose-field-hidden {
    display: none !important;
}

.compose-label {
    min-width: 80px;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.compose-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 0;
    font-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
}

.compose-input::placeholder {
    color: var(--text-muted);
}

.compose-field-actions {
    padding: 0 16px;
    height: 32px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.compose-link {
    color: var(--primary-color);
    text-decoration: none;
    cursor: pointer;
    padding: 2px 4px;
}

.compose-link:hover {
    text-decoration: underline;
}

.compose-separator {
    color: var(--text-muted);
}

.compose-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

.compose-textarea {
    flex: 1;
    border: none;
    outline: none;
    padding: 16px;
    font-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
    resize: none;
    min-height: 0;
}

.compose-textarea::placeholder {
    color: var(--text-muted);
}

.compose-actions {
    padding: 4px 16px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--surface);
}

.compose-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
}

.compose-footer-left {
    flex: 1;
}

.compose-footer-right {
    display: flex;
    gap: 4px;
}

.compose-action-btn {
    font-size: 18px;
    color: var(--text-secondary);
}

.btn-send {
    border-radius: 20px;
    padding: 10px 24px;
    font-weight: 500;
}

#composeErrorMessage.error-message {
    padding: 0 16px 12px;
    margin-top: 0;
    margin-bottom: 0;
}

#composeErrorMessage.error-message:empty {
    display: none;
    min-height: 0;
    padding: 0;
}

/* Attachments */
.compose-attachments {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.compose-attachments-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.compose-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    transition: all 0.2s;
    max-width: 100%;
}

.compose-attachment-chip-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.compose-attachment-chip-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.compose-attachment-chip-size {
    font-size: 11px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.compose-attachment-chip-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0 4px;
    margin-left: 4px;
    border-radius: 4px;
    transition: all 0.1s;
    font-size: 14px;
    line-height: 1;
}

.compose-attachment-chip-remove:hover {
    color: var(--error);
}

/* Email Viewer Attachments - Chip Style */
.email-attachments-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 0;
}

.email-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    max-width: 100%;
}

.email-attachment-chip:hover {
    background: rgba(var(--primary-color-rgb), 0.1);
    border-color: var(--primary-color);
    /* transform: translateY(-1px); */
}

.email-attachment-chip-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.email-attachment-chip-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.email-attachment-chip-size {
    font-size: 11px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

