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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.header {
    background: #2c3e50;
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 100;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header h1 i {
    margin-right: 0.5rem;
    color: #3498db;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box input {
    padding: 0.5rem 2.5rem 0.5rem 1rem;
    border: 1px solid #34495e;
    border-radius: 4px;
    background: rgba(255,255,255,0.1);
    color: white;
    width: 250px;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.search-box input::placeholder {
    color: rgba(255,255,255,0.7);
}

.search-box input:focus {
    outline: none;
    background: rgba(255,255,255,0.2);
    border-color: #3498db;
}

.search-box i {
    position: absolute;
    right: 0.75rem;
    color: rgba(255,255,255,0.7);
}

/* Buttons */
.btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
    text-decoration: none;
}

.btn:hover {
    background: #2980b9;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-icon {
    background: transparent;
    padding: 0.5rem;
    border-radius: 4px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.1);
}

.btn-small {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Email List Container */
.email-list-container {
    width: 350px;
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.email-list-header {
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.email-list-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
}

.email-count {
    font-size: 0.9rem;
    color: #666;
}

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

/* Email Items */
.email-item {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s;
}

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

.email-item.selected {
    background: #e3f2fd;
    border-left: 3px solid #3498db;
}

.email-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.email-from {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-date {
    font-size: 0.8rem;
    color: #666;
    white-space: nowrap;
    margin-left: 0.5rem;
}

.email-item-subject {
    font-weight: 500;
    color: #333;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-item-preview {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.email-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #888;
}

.email-attachments-count {
    color: #e74c3c;
}

/* Email Viewer */
.email-viewer {
    flex: 1;
    background: white;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.email-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.no-email-selected {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #999;
    text-align: center;
}

.no-email-selected i {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: #ddd;
}

.no-email-selected p {
    font-size: 1.1rem;
}

/* Email Detail */
.email-detail {
    padding: 2rem;
    max-width: none;
}

.email-header {
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
}

.email-subject h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 1rem;
    word-wrap: break-word;
}

.email-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.meta-item {
    display: flex;
    flex-direction: column;
}

.meta-item strong {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.meta-item span {
    font-size: 0.95rem;
    color: #333;
    word-wrap: break-word;
}

.email-body {
    line-height: 1.6;
    font-size: 0.95rem;
    color: #333;
    min-height: 200px;
}

.email-body img {
    max-width: 100%;
    height: auto;
    margin: 1rem 0;
}

.email-body pre {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
}

.email-body blockquote {
    border-left: 4px solid #ddd;
    margin: 1rem 0;
    padding-left: 1rem;
    color: #666;
}

/* Attachments */
.email-attachments {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e0e0e0;
}

.email-attachments h3 {
    font-size: 1.1rem;
    color: #2c3e50;
    margin-bottom: 1rem;
}

.attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.attachment-item {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 200px;
}

.attachment-item i.fa-file {
    color: #666;
    font-size: 1.2rem;
}

.attachment-item a {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.8rem;
    margin-left: auto;
    transition: background 0.3s;
}

.attachment-item a:hover {
    background: #2980b9;
}

.attachment-size {
    font-size: 0.8rem;
    color: #666;
}

/* Status Bar */
.status-bar {
    background: #34495e;
    color: white;
    padding: 0.5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    border-top: 1px solid #2c3e50;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-indicator.online {
    color: #2ecc71;
}

.status-indicator.offline {
    color: #e74c3c;
}

.status-indicator.loading {
    color: #f39c12;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.auto-refresh-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.8;
}

/* Loading and Empty States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    color: #666;
}

.no-emails {
    text-align: center;
    padding: 3rem 1rem;
    color: #999;
}

.no-emails i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #ddd;
}

.error-message {
    text-align: center;
    padding: 2rem;
    color: #e74c3c;
}

.error-message i {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #e74c3c;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .header-controls {
        width: 100%;
        justify-content: space-between;
    }

    .search-box input {
        width: 200px;
    }

    .main-content {
        flex-direction: column;
    }

    .email-list-container {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .email-viewer {
        flex: 1;
    }

    .email-detail {
        padding: 1rem;
    }

    .email-meta {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .status-bar {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .status-right {
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.2rem;
    }

    .search-box input {
        width: 150px;
    }

    .email-item-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .attachments-list {
        flex-direction: column;
    }

    .attachment-item {
        min-width: auto;
    }
}

/* Scrollbar Styling */
.email-list::-webkit-scrollbar,
.email-content::-webkit-scrollbar {
    width: 8px;
}

.email-list::-webkit-scrollbar-track,
.email-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

.email-list::-webkit-scrollbar-thumb:hover,
.email-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.email-item {
    animation: fadeIn 0.3s ease-out;
}

.email-detail {
    animation: fadeIn 0.5s ease-out;
}