/* ========================================
   MESSAGEHUB OSM
   MESSAGE HISTORY
======================================== */

.history-card {
    background: var(--bg-card, #111827);
    border: 1px solid var(--border-color, rgba(255,255,255,.08));
    border-radius: 14px;
    overflow: hidden;
}


/* ========================================
   HISTORY TOOLBAR
======================================== */

.history-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,.08));
}

.history-search {
    flex: 1 1 auto;
    min-width: 260px;
}

.history-search input,
.history-filters select {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border-color, rgba(255,255,255,.1));
    border-radius: 8px;
    background: var(--bg-secondary, #0b1220);
    color: var(--text-primary, #fff);
    outline: none;
    box-sizing: border-box;
}

.history-search input::placeholder {
    color: var(--text-secondary, #8d98aa);
}

.history-search input:focus,
.history-filters select:focus {
    border-color: var(--blue-light, #5b8cff);
}


/* ========================================
   FILTERS
======================================== */

.history-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.history-filters select {
    width: 150px;
    min-width: 150px;
    cursor: pointer;
}


/* ========================================
   REFRESH BUTTON
======================================== */

.history-refresh {
    flex: 0 0 auto;
    height: 42px;
    padding: 0 14px;
    border: 1px solid var(--border-color, rgba(255,255,255,.1));
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary, #fff);
    cursor: pointer;
    white-space: nowrap;
}

.history-refresh:hover {
    background: rgba(30, 94, 255, .1);
    border-color: var(--blue-light, #5b8cff);
}


/* ========================================
   TABLE
======================================== */

.history-table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    padding: 15px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,.07));
    white-space: nowrap;
}

.history-table th {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary, #8d98aa);
}

.history-table td {
    color: var(--text-primary, #e9eef7);
    font-size: 14px;
}

.history-message {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-target-type {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    color: var(--text-secondary, #8d98aa);
}


/* ========================================
   STATUS
======================================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.status-success {
    color: #65d68b;
    background: rgba(45,190,100,.12);
}

.status-pending {
    color: #f2c45c;
    background: rgba(242,196,92,.12);
}

.status-failed {
    color: #ff7272;
    background: rgba(255,82,82,.12);
}


/* ========================================
   DETAIL BUTTON
======================================== */

.history-detail-button {
    border: 0;
    background: transparent;
    color: var(--blue-light, #5b8cff);
    cursor: pointer;
}

.history-detail-button:hover {
    text-decoration: underline;
}


/* ========================================
   FOOTER
======================================== */

.history-footer {
    padding: 15px 18px;
    color: var(--text-secondary, #8d98aa);
    font-size: 12px;
}

.history-empty {
    padding: 45px 20px;
    text-align: center;
    color: var(--text-secondary, #8d98aa);
}

.hidden {
    display: none !important;
}


/* ========================================
   DETAIL MODAL
======================================== */

.history-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0,0,0,.65);
}

.history-modal-box {
    width: min(560px, 100%);
    max-height: 90vh;
    overflow: auto;
    border: 1px solid var(--border-color, rgba(255,255,255,.1));
    border-radius: 14px;
    background: var(--bg-card, #111827);
}

.history-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,.08));
}

.history-modal-header h3 {
    margin: 0;
}

.history-modal-header button {
    border: 0;
    background: transparent;
    color: var(--text-secondary, #8d98aa);
    font-size: 25px;
    cursor: pointer;
}

.history-modal-body {
    display: grid;
    gap: 14px;
    padding: 20px;
}

.history-detail-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 15px;
}

.history-detail-label {
    color: var(--text-secondary, #8d98aa);
    font-size: 13px;
}

.history-detail-value {
    color: var(--text-primary, #fff);
    word-break: break-word;
}


/* ========================================
   RESPONSIVE
======================================== */

@media (max-width: 1100px) {

    .history-toolbar {
        flex-wrap: wrap;
    }

    .history-search {
        flex: 1 1 100%;
    }

    .history-filters {
        flex: 1 1 auto;
    }

}


@media (max-width: 900px) {

    .history-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .history-search {
        width: 100%;
    }

    .history-filters {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .history-filters select,
    .history-refresh {
        width: 100%;
    }

}


@media (max-width: 560px) {

    .history-filters {
        grid-template-columns: 1fr;
    }

    .history-detail-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }

}