/**
 * ImmigraSuite Admin - Webhook Logs
 * Webhook logs page, stats, tables, and payload display
 */

/* ==========================================================================
   Webhook Logs Container
   ========================================================================== */

.is-webhook-logs {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ==========================================================================
   Stats Cards
   ========================================================================== */

.is-webhook-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

@media (max-width: 768px) {
    .is-webhook-stats {
        grid-template-columns: 1fr;
    }
}

.is-webhook-stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid rgb(229 231 235);
}

.dark .is-webhook-stat-card {
    background: rgb(17 24 39);
    border-color: rgb(55 65 81);
}

.is-webhook-stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgb(243 244 246);
    color: rgb(107 114 128);
}

.dark .is-webhook-stat-icon {
    background: rgb(55 65 81);
    color: rgb(156 163 175);
}

.is-webhook-stat-all .is-webhook-stat-icon {
    background: rgb(219 234 254);
    color: rgb(59 130 246);
}

.dark .is-webhook-stat-all .is-webhook-stat-icon {
    background: rgba(59, 130, 246, 0.2);
}

.is-webhook-stat-today .is-webhook-stat-icon {
    background: rgb(220 252 231);
    color: rgb(34 197 94);
}

.dark .is-webhook-stat-today .is-webhook-stat-icon {
    background: rgba(34, 197, 94, 0.2);
}

.is-failed-icon {
    background: rgb(254 226 226) !important;
    color: rgb(239 68 68) !important;
}

.dark .is-failed-icon {
    background: rgba(239, 68, 68, 0.2) !important;
}

.is-webhook-stat-failed.is-has-failed {
    border-color: rgb(254 202 202);
    background: rgb(254 242 242);
}

.dark .is-webhook-stat-failed.is-has-failed {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.1);
}

.is-webhook-stat-content {
    flex: 1;
}

.is-webhook-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: rgb(17 24 39);
    line-height: 1;
}

.dark .is-webhook-stat-value {
    color: rgb(243 244 246);
}

.is-failed-value {
    color: rgb(239 68 68) !important;
}

.is-webhook-stat-label {
    font-size: 14px;
    color: rgb(107 114 128);
    margin-top: 4px;
}

.dark .is-webhook-stat-label {
    color: rgb(156 163 175);
}

/* ==========================================================================
   Tabs Container
   ========================================================================== */

.is-webhook-tabs-container {
    overflow: hidden;
}

.is-webhook-tabs-nav {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    border-bottom: 1px solid rgb(229 231 235);
    overflow-x: auto;
    flex-wrap: wrap;
}

.dark .is-webhook-tabs-nav {
    border-color: rgb(55 65 81);
}

.is-webhook-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: rgb(107 114 128);
    background: transparent;
    border: 1px solid rgb(229 231 235);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.is-webhook-tab:hover {
    color: rgb(234 88 12);
    border-color: rgb(234 88 12);
    background: rgb(255 247 237);
}

.is-webhook-tab-active {
    color: white !important;
    background: rgb(234 88 12) !important;
    border-color: rgb(234 88 12) !important;
}

.is-webhook-tab-danger {
    color: rgb(239 68 68);
    border-color: rgb(254 202 202);
}

.is-webhook-tab-danger:hover {
    color: rgb(185 28 28);
    border-color: rgb(239 68 68);
    background: rgb(254 242 242);
}

.dark .is-webhook-tab {
    color: rgb(156 163 175);
    border-color: rgb(55 65 81);
}

.dark .is-webhook-tab:hover {
    background: rgba(234, 88, 12, 0.1);
}

.dark .is-webhook-tab-danger {
    color: rgb(252 165 165);
    border-color: rgba(239, 68, 68, 0.3);
}

.is-webhook-tab-count {
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    background: rgb(243 244 246);
    border-radius: 9999px;
    color: rgb(107 114 128);
}

.is-webhook-tab-active .is-webhook-tab-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.is-webhook-tab-count-danger {
    background: rgb(254 226 226);
    color: rgb(185 28 28);
}

.is-webhook-tab-active .is-webhook-tab-count-danger {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.dark .is-webhook-tab-count {
    background: rgb(55 65 81);
    color: rgb(156 163 175);
}

/* ==========================================================================
   Table
   ========================================================================== */

.is-webhook-table-wrap {
    overflow-x: auto;
}

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

.is-webhook-th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: rgb(107 114 128);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgb(249 250 251);
    border-bottom: 1px solid rgb(229 231 235);
}

.dark .is-webhook-th {
    background: rgb(31 41 55);
    color: rgb(156 163 175);
    border-color: rgb(55 65 81);
}

.is-webhook-td {
    padding: 12px 16px;
    font-size: 14px;
    color: rgb(55 65 81);
    border-bottom: 1px solid rgb(243 244 246);
    vertical-align: middle;
}

.dark .is-webhook-td {
    color: rgb(209 213 219);
    border-color: rgb(55 65 81);
}

.is-webhook-tr:hover .is-webhook-td {
    background: rgb(249 250 251);
}

.dark .is-webhook-tr:hover .is-webhook-td {
    background: rgb(31 41 55);
}

.is-webhook-tr-failed {
    background: rgb(254 242 242);
}

.is-webhook-tr-failed:hover .is-webhook-td {
    background: rgb(254 226 226) !important;
}

.dark .is-webhook-tr-failed {
    background: rgba(239, 68, 68, 0.1);
}

.dark .is-webhook-tr-failed:hover .is-webhook-td {
    background: rgba(239, 68, 68, 0.15) !important;
}

.is-webhook-td-time {
    white-space: nowrap;
    color: rgb(107 114 128);
    font-size: 13px;
}

.dark .is-webhook-td-time {
    color: rgb(156 163 175);
}

.is-webhook-td-identifier {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
}

.is-webhook-td-error {
    max-width: 200px;
}

.is-webhook-error-text {
    color: rgb(185 28 28);
    font-size: 13px;
}

.dark .is-webhook-error-text {
    color: rgb(252 165 165);
}

.is-webhook-no-error {
    color: rgb(156 163 175);
}

/* ==========================================================================
   Source Badge
   ========================================================================== */

.is-webhook-source {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
}

.is-webhook-source-whatsapp {
    background: rgb(220 252 231);
    color: rgb(22 101 52);
}

.dark .is-webhook-source-whatsapp {
    background: rgba(34, 197, 94, 0.2);
    color: rgb(134 239 172);
}

.is-webhook-source-calendly {
    background: rgb(219 234 254);
    color: rgb(30 64 175);
}

.dark .is-webhook-source-calendly {
    background: rgba(59, 130, 246, 0.2);
    color: rgb(147 197 253);
}

.is-webhook-source-stripe {
    background: rgb(243 232 255);
    color: rgb(107 33 168);
}

.dark .is-webhook-source-stripe {
    background: rgba(168, 85, 247, 0.2);
    color: rgb(216 180 254);
}

.is-webhook-source-website_form {
    background: rgb(255 237 213);
    color: rgb(154 52 18);
}

.dark .is-webhook-source-website_form {
    background: rgba(249, 115, 22, 0.2);
    color: rgb(253 186 116);
}

/* ==========================================================================
   Event Type
   ========================================================================== */

.is-webhook-event-type {
    padding: 4px 8px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    background: rgb(243 244 246);
    border-radius: 4px;
    color: rgb(55 65 81);
}

.dark .is-webhook-event-type {
    background: rgb(55 65 81);
    color: rgb(209 213 219);
}

/* ==========================================================================
   Status Badge
   ========================================================================== */

.is-webhook-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 9999px;
}

.is-webhook-status-received {
    background: rgb(254 249 195);
    color: rgb(133 77 14);
}

.dark .is-webhook-status-received {
    background: rgba(234, 179, 8, 0.2);
    color: rgb(250 204 21);
}

.is-webhook-status-processed {
    background: rgb(220 252 231);
    color: rgb(22 101 52);
}

.dark .is-webhook-status-processed {
    background: rgba(34, 197, 94, 0.2);
    color: rgb(134 239 172);
}

.is-webhook-status-failed {
    background: rgb(254 226 226);
    color: rgb(153 27 27);
}

.dark .is-webhook-status-failed {
    background: rgba(239, 68, 68, 0.2);
    color: rgb(252 165 165);
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.is-webhook-empty {
    padding: 32px 16px !important;
    text-align: center;
}

.is-webhook-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: rgb(156 163 175);
}

.is-webhook-empty-state svg {
    width: 32px !important;
    height: 32px !important;
    color: rgb(209 213 219);
}

.dark .is-webhook-empty-state svg {
    color: rgb(75 85 99);
}

/* ==========================================================================
   Payload Modal
   ========================================================================== */

.is-webhook-payload-container {
    max-height: 500px;
    overflow: auto;
}

.is-webhook-payload-code {
    margin: 0;
    padding: 16px;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    background: rgb(17 24 39);
    color: rgb(229 231 235);
    border-radius: 8px;
    overflow-x: auto;
    white-space: pre;
    line-height: 1.5;
}

.is-webhook-no-payload {
    text-align: center;
    color: rgb(156 163 175);
    padding: 32px;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.is-webhook-pagination {
    padding: 12px 20px;
    border-top: 1px solid rgb(229 231 235);
}

.dark .is-webhook-pagination {
    border-color: rgb(55 65 81);
}

/* Hide mobile prev/next view, show desktop view */
.is-webhook-pagination nav > div:first-child {
    display: none !important;
}

.is-webhook-pagination nav > div:last-child {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

/* Layout: text on left, buttons on right */
.is-webhook-pagination nav {
    display: block;
}

/* Align the "Showing X to Y" text */
.is-webhook-pagination nav p {
    margin: 0;
    font-size: 13px;
    color: rgb(107 114 128);
    line-height: 32px;
}

.dark .is-webhook-pagination nav p {
    color: rgb(156 163 175);
}

/* Page buttons container */
.is-webhook-pagination nav > div:last-child > div:last-child {
    display: flex;
    align-items: center;
    gap: 2px;
}

.is-webhook-pagination nav > div:last-child > div:last-child > span {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

/* Simple pagination - just style links and buttons */
.is-webhook-pagination a,
.is-webhook-pagination button {
    padding: 0 10px;
    height: 32px;
    font-size: 13px;
    border-radius: 6px;
    border: 1px solid rgb(229 231 235);
    background: white;
    color: rgb(55 65 81);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.is-webhook-pagination a:hover,
.is-webhook-pagination button:hover:not(:disabled) {
    border-color: rgb(234 88 12);
    color: rgb(234 88 12);
    background: rgb(255 247 237);
}

/* Active page */
.is-webhook-pagination span[aria-current="page"] {
    padding: 0 10px;
    height: 32px;
    font-size: 13px;
    border-radius: 6px;
    background: rgb(234 88 12);
    border: 1px solid rgb(234 88 12);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Disabled state */
.is-webhook-pagination span[aria-disabled="true"] {
    padding: 0 10px;
    height: 32px;
    font-size: 13px;
    color: rgb(156 163 175);
    cursor: not-allowed;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* SVG icons */
.is-webhook-pagination svg {
    width: 16px;
    height: 16px;
}

/* Dark mode */
.dark .is-webhook-pagination a,
.dark .is-webhook-pagination button {
    border-color: rgb(55 65 81);
    background: rgb(31 41 55);
    color: rgb(209 213 219);
}

.dark .is-webhook-pagination a:hover,
.dark .is-webhook-pagination button:hover:not(:disabled) {
    border-color: rgb(234 88 12);
    color: rgb(234 88 12);
    background: rgba(234, 88, 12, 0.1);
}

.dark .is-webhook-pagination span[aria-current="page"] {
    background: rgb(234 88 12);
    border-color: rgb(234 88 12);
    color: white;
}

.dark .is-webhook-pagination span[aria-disabled="true"] {
    color: rgb(107 114 128);
}

@media (max-width: 640px) {
    .is-webhook-pagination {
        text-align: center;
    }
}

/* ==========================================================================
   Actions Column
   ========================================================================== */

.is-webhook-td-actions {
    white-space: nowrap;
}

.is-webhook-actions-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Primary button style for Reprocess */
.is-btn-primary {
    background: rgb(234 88 12);
    border-color: rgb(234 88 12);
    color: white !important;
}

.is-btn-primary:hover {
    background: rgb(194 65 12);
    border-color: rgb(194 65 12);
}

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

.dark .is-btn-primary {
    background: rgb(234 88 12);
    border-color: rgb(234 88 12);
}

.dark .is-btn-primary:hover {
    background: rgb(249 115 22);
    border-color: rgb(249 115 22);
}
