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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    height: 100vh;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Панель поиска */
.search-panel {
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    padding: 16px 24px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-container {
    display: flex;
    gap: 12px;
    max-width: 1200px;
    margin: 0 auto;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 10px 16px;
    font-size: 14px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.1);
}

.score-threshold-input {
    width: 80px;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.2s;
    text-align: center;
}

.score-threshold-input:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.1);
}

.search-button {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    background-color: #1a73e8;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-button:hover:not(:disabled) {
    background-color: #1557b0;
}

.search-button:disabled {
    background-color: #9aa0a6;
    cursor: not-allowed;
}

.clear-search-button {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #5f6368;
    background-color: #f1f3f4;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.clear-search-button:hover {
    background-color: #e8eaed;
}

.search-stats {
    margin-top: 12px;
    padding: 8px 16px;
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 13px;
    color: #5f6368;
    text-align: center;
}

.mail-container {
    display: flex;
    height: calc(100vh - 73px); /* Вычитаем высоту панели поиска */
    background-color: #ffffff;
}

/* Левая панель: Список писем */
.mail-list-panel {
    width: 40%;
    min-width: 350px;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
}

.mail-list-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #fafafa;
}

.mail-list-header h2 {
    font-size: 20px;
    font-weight: 500;
    color: #202124;
}

.mail-list {
    flex: 1;
    overflow-y: auto;
    background-color: #ffffff;
    min-height: 0; /* Позволяет flex-элементу сжиматься */
    overflow-x: hidden;
}

.mail-item {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.15s ease;
    position: relative;
}

.mail-item:hover {
    background-color: #f8f9fa;
}

.mail-item.active {
    background-color: #e8f0fe;
    border-left: 3px solid #1a73e8;
}

.mail-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: #1a73e8;
}

.mail-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.mail-from {
    font-weight: 600;
    font-size: 14px;
    color: #202124;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-date {
    font-size: 12px;
    color: #5f6368;
    margin-left: 12px;
    white-space: nowrap;
}

.mail-subject {
    font-weight: 500;
    font-size: 14px;
    color: #202124;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-score-container {
    margin-bottom: 6px;
}

.mail-score {
    font-size: 11px;
    color: #1a73e8;
    font-weight: 600;
    background-color: #e8f0fe;
    padding: 4px 10px;
    border-radius: 16px;
    display: inline-block;
    border: 1px solid #1a73e8;
}

.mail-preview {
    font-size: 13px;
    color: #5f6368;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Правая панель: Содержимое письма */
.mail-content-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    overflow: hidden;
}

.mail-content-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #fafafa;
}

.mail-content-header h3 {
    font-size: 18px;
    font-weight: 500;
    color: #202124;
}

.mail-content-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background-color: #ffffff;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #5f6368;
    font-size: 14px;
}

.loading {
    padding: 40px 20px;
    text-align: center;
    color: #5f6368;
    font-size: 14px;
}

.error {
    padding: 20px;
    color: #d93025;
    background-color: #fce8e6;
    border-radius: 4px;
    margin: 20px;
    font-size: 14px;
}

/* Стили для содержимого письма */
.email-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.email-relevance-banner {
    background-color: #e8f0fe;
    border: 1px solid #1a73e8;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #1a73e8;
    font-weight: 500;
    text-align: center;
}

.email-field {
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.6;
    color: #202124;
}

.email-field strong {
    color: #5f6368;
    margin-right: 8px;
    font-weight: 500;
}

.email-body {
    font-size: 14px;
    line-height: 1.8;
    color: #202124;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.highlighted-chunk {
    background-color: #fff9c4;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Скроллбар */
.mail-list::-webkit-scrollbar,
.mail-content-body::-webkit-scrollbar {
    width: 8px;
}

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

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

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

/* Блок логов поиска */
.search-logs {
    border-top: 1px solid #e0e0e0;
    background-color: #f8f9fa;
    padding: 6px 12px;
    max-height: 120px;
    overflow-y: auto;
    font-size: 10px;
    flex-shrink: 0;
}

.search-logs-header {
    font-weight: 600;
    color: #202124;
    margin-bottom: 4px;
    font-size: 11px;
}

.search-logs-content {
    color: #5f6368;
    line-height: 1.4;
}

.search-logs-content .log-entry {
    margin-bottom: 2px;
    padding: 1px 0;
    word-break: break-word;
}

.search-logs::-webkit-scrollbar {
    width: 4px;
}

.search-logs::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.search-logs::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.search-logs::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Адаптивность для маленьких экранов */
@media (max-width: 768px) {
    .mail-container {
        flex-direction: column;
    }
    
    .mail-list-panel {
        width: 100%;
        height: 40%;
        min-width: unset;
    }
    
    .mail-content-panel {
        height: 60%;
    }
}

