:root {
    --sidebar-width: 240px;
    --navbar-height: 56px;
}

/* === LAYOUT === */

.mail-navbar {
    height: var(--navbar-height);
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--bs-body-bg);
}

.mail-layout {
    height: calc(100vh - var(--navbar-height));
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    overflow-y: auto;
    height: 100%;
    background: var(--bs-body-bg);
    transition: transform 0.3s ease;
}

.mail-content {
    overflow-y: auto;
    height: 100%;
}

/* === SIDEBAR === */

.folder-item {
    color: var(--bs-body-color);
    transition: background-color 0.15s;
}

.folder-item:hover {
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

.folder-item.active {
    background-color: var(--bs-primary);
    color: #fff;
}

.folder-item.active .badge {
    background-color: rgba(255, 255, 255, 0.25) !important;
}

/* === MESSAGE LIST === */

.message-row {
    cursor: pointer;
    transition: background-color 0.1s;
}

.message-row:hover {
    background-color: var(--bs-tertiary-bg);
}

.message-row.unread .msg-from,
.message-row.unread .msg-subject {
    font-weight: 600;
}

.message-link {
    color: var(--bs-body-color);
}

.msg-from {
    font-size: 0.9rem;
}

.msg-subject {
    font-size: 0.9rem;
}

.msg-date {
    font-size: 0.8rem;
}

/* === MESSAGE VIEW === */

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bs-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.email-html-content {
    max-width: 100%;
    overflow-x: auto;
    word-wrap: break-word;
}

.email-html-content img {
    max-width: 100%;
    height: auto;
}

.email-text-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    font-size: 0.95rem;
    margin: 0;
}

/* === COMPOSE === */

.drop-zone {
    border-color: var(--bs-primary) !important;
    color: var(--bs-primary);
}

.drop-zone.active {
    background-color: var(--bs-primary-bg-subtle);
}

.autocomplete-results {
    position: absolute;
    z-index: 1050;
    width: calc(100% - 80px);
    margin-left: 80px;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.autocomplete-results .ac-item {
    padding: 0.4rem 0.75rem;
    cursor: pointer;
}

.autocomplete-results .ac-item:hover {
    background-color: var(--bs-tertiary-bg);
}

/* === FAB (mobile compose button) === */

.fab-compose {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bs-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1040;
    transition: transform 0.2s;
}

.fab-compose:hover {
    transform: scale(1.1);
    color: #fff;
}

/* === LOGIN === */

.login-page {
    background: linear-gradient(135deg, var(--bs-primary-bg-subtle), var(--bs-body-bg));
}

/* === SEARCH === */

.search-form {
    max-width: 500px;
    width: 100%;
}

/* === MOBILE RESPONSIVE === */

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: var(--navbar-height);
        left: 0;
        bottom: 0;
        z-index: 1040;
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: var(--navbar-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 1035;
    }

    .sidebar-backdrop.show {
        display: block;
    }
}

@media (max-width: 767.98px) {
    .msg-from {
        min-width: 100px !important;
        max-width: 120px !important;
        font-size: 0.85rem;
    }

    .msg-subject {
        font-size: 0.85rem;
    }

    .msg-date {
        display: none !important;
    }

    .message-row {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .toolbar {
        font-size: 0.9rem;
    }

    .mail-navbar .navbar-brand {
        font-size: 1rem;
    }
}

@media (max-width: 575.98px) {
    .msg-from {
        display: none !important;
    }

    .message-link {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .message-row .msg-subject {
        width: 100%;
    }

    .compose-fields .input-group-text {
        min-width: 60px !important;
        font-size: 0.85rem;
    }
}

/* === TOOLBAR === */

.toolbar {
    background: var(--bs-body-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* === MISC === */

.border-dashed {
    border-style: dashed !important;
}

.min-w-0 {
    min-width: 0;
}

/* Theme transition */
[data-bs-theme] {
    transition: background-color 0.2s, color 0.2s;
}
