/* ═══════════════════════════════════════════════════════════════
   WEBHOOKS PAGE - NEUMORPHISM STYLES
   Uses CSS variables from global.css
   ═══════════════════════════════════════════════════════════════ */

body {
    font-family: var(--font-family);
    background: var(--bg-base);
    color: var(--text-primary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

h1 {
    color: var(--text-primary);
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    font-size: 1.75rem;
    font-weight: 800;
}

/* ═══════════════════════════════════════════════════════════════
   STATS GRID (Neumorphic)
   ═══════════════════════════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-base);
    padding: 1.5rem;
    border-radius: var(--border-radius-lg);
    text-align: center;
    box-shadow: var(--neu-convex);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-coral), var(--accent-warm));
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 10px 10px 20px var(--shadow-dark), -10px -10px 20px var(--shadow-light);
}

.stat-card h3 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent-coral);
}

.stat-card:nth-child(2) .value { color: var(--accent-teal); }
.stat-card:nth-child(3) .value { color: var(--accent-warm); }
.stat-card:nth-child(4) .value { color: var(--color-success); }

/* ═══════════════════════════════════════════════════════════════
   ADD WEBHOOK FORM (Neumorphic)
   ═══════════════════════════════════════════════════════════════ */
.add-webhook-form {
    background: var(--bg-base);
    padding: 1.5rem;
    border-radius: var(--border-radius-lg);
    margin-bottom: 2rem;
    box-shadow: var(--neu-convex);
}

.add-webhook-form h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-base);
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    color: var(--text-primary);
    box-shadow: var(--neu-pressed);
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    box-shadow: var(--neu-pressed), 0 0 0 3px rgba(226, 125, 96, 0.2);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 2fr 100px;
    gap: 1rem;
    align-items: end;
}

/* ═══════════════════════════════════════════════════════════════
   BUTTONS (Neumorphic)
   ═══════════════════════════════════════════════════════════════ */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius-pill);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-base);
    color: var(--text-primary);
    box-shadow: var(--neu-convex-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    box-shadow: var(--neu-convex);
}

.btn:active {
    box-shadow: var(--neu-pressed);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-coral), var(#c96a50));
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(226, 125, 96, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, var(--color-success), #5a9a3f);
    color: white;
}

.btn-success:hover {
    box-shadow: 0 4px 12px rgba(106, 176, 76, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--color-danger), #c0392b);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 4px 12px rgba(235, 77, 75, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, var(--color-warning), #d68910);
    color: white;
}

.btn-warning:hover {
    box-shadow: 0 4px 12px rgba(240, 147, 43, 0.4);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

/* ═══════════════════════════════════════════════════════════════
   WEBHOOKS TABLE (Neumorphic)
   ═══════════════════════════════════════════════════════════════ */
.webhooks-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 1.5rem;
    background: var(--bg-base);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--neu-convex);
}

.webhooks-table th,
.webhooks-table td {
    padding: 1rem 1.25rem;
    text-align: left;
}

.webhooks-table th {
    background: var(--bg-base);
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.webhooks-table tr {
    transition: all 0.2s;
}

.webhooks-table tbody tr:hover {
    box-shadow: var(--neu-pressed);
}

.webhooks-table td {
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Status Badge (Neumorphic) */
.status-badge {
    display: inline-block;
    padding: 0.375rem 0.875rem;
    border-radius: var(--border-radius-pill);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: var(--neu-convex-sm);
    background: var(--bg-base);
}

.status-active {
    color: var(--color-success);
}

.status-inactive {
    color: var(--color-danger);
}

.actions {
    display: flex;
    gap: 0.5rem;
}

.stats-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.success-rate {
    font-weight: 700;
}

.success-rate.high {
    color: var(--color-success);
}

.success-rate.medium {
    color: var(--color-warning);
}

.success-rate.low {
    color: var(--color-danger);
}

/* ═══════════════════════════════════════════════════════════════
   MODAL (Neumorphic)
   ═══════════════════════════════════════════════════════════════ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--bg-base);
    margin: 10% auto;
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    max-width: 600px;
    position: relative;
    box-shadow: 20px 20px 40px var(--shadow-dark), -20px -20px 40px var(--shadow-light);
}

.close {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    box-shadow: var(--neu-convex-sm);
    transition: all 0.2s;
    border: none;
}

.close:hover {
    box-shadow: var(--neu-pressed);
    color: var(--accent-coral);
}

.webhook-details {
    margin-top: 1.5rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.875rem 0;
    border-bottom: 1px dashed var(--shadow-dark);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ═══════════════════════════════════════════════════════════════
   ROTATION INFO (Neumorphic)
   ═══════════════════════════════════════════════════════════════ */
.rotation-info {
    background: var(--bg-base);
    padding: 1.25rem;
    border-radius: var(--border-radius-lg);
    margin-bottom: 1.5rem;
    box-shadow: var(--neu-pressed);
    position: relative;
}

.rotation-info::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--accent-teal), var(--accent-coral));
    border-radius: var(--border-radius-lg) 0 0 var(--border-radius-lg);
}

.rotation-info h3 {
    color: var(--accent-teal);
    margin-bottom: 0.75rem;
    font-size: 1rem;
    font-weight: 700;
}

.rotation-info p {
    color: var(--text-secondary);
    font-size: 0.925rem;
    margin: 0.5rem 0;
    line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════════
   LOADING & MESSAGES
   ═══════════════════════════════════════════════════════════════ */
.loading {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--bg-base);
    border-top-color: var(--accent-coral);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    box-shadow: var(--neu-convex-sm);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    background: var(--bg-base);
    color: var(--color-danger);
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    display: none;
    box-shadow: var(--neu-pressed);
    font-weight: 600;
}

.success-message {
    background: var(--bg-base);
    color: var(--color-success);
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    display: none;
    box-shadow: var(--neu-pressed);
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    /* Stats Grid - 2 columns on mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-card h3 {
        font-size: 0.65rem;
    }

    .stat-card .value {
        font-size: 1.5rem;
    }

    /* Form - Stack vertically on mobile */
    .form-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .add-webhook-form {
        padding: 1.25rem;
    }

    /* Hide table header on mobile */
    .webhooks-table thead {
        display: none;
    }

    .webhooks-table {
        display: block;
        box-shadow: none;
        background: transparent;
    }

    /* Webhook Cards for Mobile */
    #webhooksTableBody {
        display: block !important;
    }

    #webhooksTableBody tr {
        display: block;
        background: var(--bg-base);
        border-radius: var(--border-radius-lg);
        padding: 1.25rem;
        margin-bottom: 1rem;
        box-shadow: var(--neu-convex);
    }

    #webhooksTableBody tr:hover {
        box-shadow: var(--neu-pressed);
    }

    #webhooksTableBody td {
        display: flex;
        align-items: flex-start;
        padding: 0.75rem 0;
        border: none;
        text-align: left;
        line-height: 1.5;
    }

    #webhooksTableBody td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--accent-coral);
        display: inline-block;
        min-width: 100px;
        margin-right: 1rem;
        flex-shrink: 0;
        font-size: 0.75rem;
        text-transform: uppercase;
    }

    /* First td (name) - make it stand out */
    #webhooksTableBody td:first-child {
        font-size: 1rem;
        font-weight: 700;
        color: var(--text-primary);
        padding-top: 0;
        padding-bottom: 0.75rem;
        margin-bottom: 0.5rem;
    }

    /* URL field - better wrapping */
    #webhooksTableBody td:nth-child(2) {
        word-break: break-all;
        font-size: 0.8rem;
    }

    /* Last td (actions) - full width buttons */
    #webhooksTableBody td:last-child {
        display: block;
        padding-top: 1rem;
        margin-top: 0.75rem;
    }

    #webhooksTableBody td:last-child::before {
        display: none;
    }

    /* Actions on mobile */
    .actions {
        display: flex;
        flex-direction: column;
        gap: 0.75rem !important;
        width: 100%;
    }

    .actions button {
        width: 100%;
        padding: 0.875rem 1rem !important;
        font-size: 0.875rem !important;
        justify-content: center;
    }

    /* Modal responsive */
    .modal-content {
        margin: 5% auto;
        padding: 1.5rem;
        max-width: 95%;
    }

    /* Rotation info */
    .rotation-info {
        padding: 1rem;
        font-size: 0.875rem;
    }

    .rotation-info h3 {
        font-size: 0.9rem;
    }

    .rotation-info p {
        font-size: 0.8rem;
    }

    /* Action buttons container */
    div[style*="text-align: right"] {
        text-align: center !important;
    }

    div[style*="text-align: right"] button {
        width: 100%;
        padding: 0.875rem 1.25rem !important;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card .value {
        font-size: 1.75rem;
    }
}
