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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f5f5f5;
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 10px;
    color: #667eea;
    font-size: 32px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #666;
    font-size: 20px;
    font-weight: normal;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-block {
    width: 100%;
    padding: 12px;
    font-size: 16px;
}

.alert {
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-error {
    background: #fee;
    color: #c00;
    border: 1px solid #fcc;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: #999;
    font-size: 12px;
}

/* Main app */
.container {
    max-width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: #667eea;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 20px;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 250px;
    background: white;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    padding: 15px;
}

.sidebar h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.folder-item {
    padding: 10px;
    cursor: pointer;
    border-radius: 5px;
    margin-bottom: 2px;
    transition: background 0.2s;
}

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

.folder-item.active {
    background: #667eea;
    color: white;
}

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.toolbar {
    padding: 15px;
    border-bottom: 1px solid #ddd;
    background: #fafafa;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.search-bar input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filters select,
.filters input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 13px;
}

.email-count {
    padding: 10px 15px;
    background: #f9f9f9;
    border-bottom: 1px solid #ddd;
    font-size: 13px;
    color: #666;
}

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

.email-item {
    display: grid;
    grid-template-columns: 250px 1fr 150px 80px;
    gap: 10px;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
}

.email-item:hover {
    background: #f9f9f9;
}

.email-item.unread {
    background: #f0f4ff;
    font-weight: 500;
}

.email-item.unread:hover {
    background: #e6edff;
}

.email-from {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
}

.email-subject {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #666;
}

.email-date {
    text-align: right;
    color: #999;
    font-size: 12px;
}

.email-size {
    text-align: right;
    color: #999;
    font-size: 12px;
}

.loading, .empty, .error {
    padding: 40px;
    text-align: center;
    color: #999;
}

.error {
    color: #c00;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 0;
    width: 90%;
    max-width: 900px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    padding: 10px 20px;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #000;
}

#email-preview {
    overflow-y: auto;
    padding: 20px;
}

.email-header {
    border-bottom: 2px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.email-header h2 {
    margin-bottom: 15px;
    color: #333;
}

.email-meta {
    font-size: 13px;
    color: #666;
}

.email-meta div {
    margin-bottom: 5px;
}

.email-body {
    line-height: 1.6;
}

.email-body pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    margin: 0;
}

/* HTML email iframe */
.email-html-frame {
    width: 100%;
    height: 600px;
    min-height: 400px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
}

.email-body.html-email {
    background: #f9f9f9;
    padding: 10px;
    border-radius: 5px;
}

.email-format-badge {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    margin-top: 5px;
}

/* Attachments */
.email-attachments {
    margin: 15px 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

.email-attachments h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #555;
}

.attachments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attachment-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s;
    gap: 10px;
}

.attachment-item:hover {
    background: #f0f4ff;
    border-color: #667eea;
}

.attachment-icon {
    font-size: 20px;
}

.attachment-name {
    flex: 1;
    font-weight: 500;
}

.attachment-size {
    color: #999;
    font-size: 12px;
}
