/* =========================================================
   MSMail AI Studio Phase 5
   ========================================================= */

.ai-usage-filter {
    margin-bottom: 18px;
}

.ai-usage-chart {
    display: flex;
    min-height: 260px;
    align-items: flex-end;
    gap: 7px;
    padding: 12px 6px 2px;
    overflow-x: auto;
}

.ai-usage-bar-wrap {
    display: grid;
    min-width: 28px;
    height: 230px;
    flex: 1;
    grid-template-rows: 1fr auto;
    align-items: end;
    gap: 8px;
}

.ai-usage-bar {
    width: 100%;
    min-height: 3px;
    height: var(--bar-height);
    border-radius: 8px 8px 3px 3px;
    background: linear-gradient(180deg, var(--purple), var(--primary));
}

.ai-usage-bar-wrap small {
    overflow: hidden;
    color: var(--muted);
    font-size: 8px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-log-toolbar .ai-toolbar-left {
    flex-wrap: wrap;
}

.ai-log-toolbar .ai-search {
    min-width: 320px;
}

.ai-log-error {
    display: block;
    max-width: 280px;
    margin-top: 4px;
    overflow: hidden;
    color: var(--red);
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 10px;
}

.ai-pagination > div {
    display: flex;
    gap: 8px;
}

.ai-log-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3200;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(4, 9, 19, .72);
    backdrop-filter: blur(5px);
}

.ai-log-modal {
    width: min(860px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.ai-log-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.ai-log-detail-grid > div {
    display: grid;
    gap: 5px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
}

.ai-log-detail-grid small {
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.ai-log-detail-grid strong {
    overflow-wrap: anywhere;
    font-size: 11px;
}

.ai-log-error-box {
    margin-top: 14px;
    padding: 14px;
    border: 1px solid rgba(227, 76, 76, .24);
    border-radius: 12px;
    background: rgba(227, 76, 76, .08);
    color: var(--red);
}

.ai-log-error-box p {
    margin: 8px 0 0;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

@media (max-width: 900px) {
    .ai-log-detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ai-log-toolbar .ai-search {
        min-width: 240px;
    }
}

@media (max-width: 720px) {
    .ai-usage-chart {
        min-height: 210px;
    }

    .ai-usage-bar-wrap {
        min-width: 24px;
        height: 180px;
    }

    .ai-log-toolbar .ai-search {
        width: 100%;
        min-width: 0;
    }

    .ai-log-detail-grid {
        grid-template-columns: 1fr;
    }

    .ai-pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .ai-pagination > div,
    .ai-pagination .ai-button {
        flex: 1;
    }
}
