/**
 * Frontend Styles for Message Processing Plugin
 *
 * Table of Contents:
 * 1. Base Styles
 * 2. Channels Hub
 * 3. Channel Inbox
 * 4. Message Details
 * 5. Loading States
 * 6. Animations
 * 7. Responsive Design
 * 8. Print Styles
 *
 * @package Message_Processing_Plugin
 */

/* ==========================================================================
   1. Base Styles
   ========================================================================== */

/* Message Processing Plugin Base Styles */
.mpp-container {
    max-width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
}

.mpp-container * {
    box-sizing: border-box;
}

/* ==========================================================================
   2. Channels Hub Styles
   ========================================================================== */

.mpp-channels-hub {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
}

.mpp-hub-title {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-size: 2em;
    font-weight: 600;
}

.mpp-channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.mpp-channel-card {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.mpp-channel-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border-color: #0073aa;
}

.mpp-channel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.mpp-channel-name {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
    flex: 1;
}

.mpp-channel-name a {
    text-decoration: none;
    color: #0073aa;
    transition: color 0.2s ease;
}

.mpp-channel-name a:hover {
    color: #005a87;
}

.mpp-unread-badge {
    background: linear-gradient(135deg, #d63638, #b32629);
    color: white;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.75em;
    font-weight: 700;
    min-width: 24px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(214, 54, 56, 0.3);
}

.mpp-channel-description {
    margin-bottom: 20px;
    color: #666;
    font-size: 0.95em;
    line-height: 1.5;
}

.mpp-channel-stats {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    border-left: 4px solid #0073aa;
}

.mpp-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.mpp-stat:last-child {
    margin-bottom: 0;
}

.mpp-stat-label {
    color: #666;
    font-size: 0.9em;
    font-weight: 500;
}

.mpp-stat-value {
    font-weight: 700;
    color: #333;
}

.mpp-stat-value.mpp-unread {
    color: #d63638;
}

.mpp-channel-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ==========================================================================
   3. Channel Inbox Styles
   ========================================================================== */

.mpp-channel-inbox {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.mpp-inbox-header {
    background: linear-gradient(135deg, #0073aa, #005a87);
    color: white;
    padding: 24px;
}

.mpp-breadcrumb {
    margin-bottom: 12px;
}

.mpp-breadcrumb a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 0.9em;
    transition: color 0.2s ease;
}

.mpp-breadcrumb a:hover {
    color: white;
}

.mpp-inbox-title {
    margin: 0 0 8px 0;
    font-size: 1.8em;
    font-weight: 600;
}

.mpp-inbox-description {
    margin: 0;
    opacity: 0.9;
    font-size: 1em;
}

.mpp-inbox-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
    gap: 20px;
}

.mpp-search-form {
    flex: 1;
    max-width: 400px;
}

.mpp-search {
    display: flex;
    gap: 8px;
    align-items: center;
}

.mpp-search-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.mpp-search-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.mpp-messages-table-container {
    overflow-x: auto;
}

.mpp-messages-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.mpp-messages-table th {
    background: #f8f9fa;
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #e1e5e9;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mpp-messages-table td {
    padding: 16px 12px;
    border-bottom: 1px solid #f1f3f4;
    vertical-align: middle;
}

.mpp-message-row {
    transition: background-color 0.2s ease;
}

.mpp-message-row:hover {
    background: #f8f9fa;
}

.mpp-message-row.mpp-unread {
    background: linear-gradient(90deg, rgba(0, 115, 170, 0.02), transparent);
    border-left: 4px solid #0073aa;
}

.mpp-message-row.mpp-unread .mpp-message-summary {
    font-weight: 600;
}

.mpp-read-indicator {
    font-size: 12px;
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    text-align: center;
    line-height: 1;
}

.mpp-read-indicator.mpp-unread {
    background: #0073aa;
    color: #0073aa;
}

.mpp-read-indicator.mpp-read {
    background: #ddd;
    color: #ddd;
}

.mpp-message-summary {
    background: none;
    border: none;
    padding: 0;
    color: #0073aa;
    cursor: pointer;
    text-align: left;
    width: 100%;
    font-size: 14px;
    line-height: 1.4;
}

.mpp-message-summary:hover {
    text-decoration: underline;
    color: #005a87;
}

.mpp-webhook-name {
    display: inline-block;
    background: #e8f4f8;
    color: #0073aa;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 500;
}

/* ==========================================================================
   4. Message Details Modal
   ========================================================================== */

.mpp-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.mpp-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 900px;
    width: 95%;
    max-height: 90%;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: mpp-modal-appear 0.3s ease-out;
}

@keyframes mpp-modal-appear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.mpp-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid #e1e5e9;
    background: #f8f9fa;
}

.mpp-modal-title {
    margin: 0;
    font-size: 1.4em;
    font-weight: 600;
    color: #333;
}

.mpp-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mpp-modal-close:hover {
    background: #e1e5e9;
    color: #333;
}

.mpp-modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: 70vh;
}

.mpp-message-detail {
    font-size: 14px;
}

.mpp-message-meta {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 24px;
    border-left: 4px solid #0073aa;
}

.mpp-message-meta h4 {
    margin: 0 0 12px 0;
    color: #0073aa;
    font-size: 1.2em;
}

.mpp-message-meta p {
    margin: 8px 0;
    color: #666;
}

.mpp-message-fields {
    margin-bottom: 24px;
}

.mpp-message-fields h5 {
    margin: 0 0 16px 0;
    color: #333;
    font-size: 1.1em;
    font-weight: 600;
}

.mpp-fields-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    overflow: hidden;
}

.mpp-fields-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f3f4;
    vertical-align: top;
}

.mpp-fields-table td:first-child {
    background: #f8f9fa;
    font-weight: 600;
    width: 30%;
    color: #333;
}

.mpp-fields-table tr:last-child td {
    border-bottom: none;
}

.mpp-raw-json {
    margin-top: 24px;
}

.mpp-raw-json h5 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 1.1em;
    font-weight: 600;
}

.mpp-raw-json pre {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    padding: 16px;
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.4;
    color: #333;
}

/* ==========================================================================
   5. Buttons and Controls
   ========================================================================== */

.mpp-btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.mpp-btn-primary {
    background: linear-gradient(135deg, #0073aa, #005a87);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 115, 170, 0.3);
}

.mpp-btn-primary:hover {
    background: linear-gradient(135deg, #005a87, #004a73);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 115, 170, 0.4);
}

.mpp-btn-secondary {
    background: #f0f0f1;
    color: #50575e;
    border: 1px solid #c3c4c7;
}

.mpp-btn-secondary:hover {
    background: #e0e0e1;
    border-color: #a7aaad;
}

.mpp-btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.mpp-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.mpp-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    background: #f8f9fa;
    border-top: 1px solid #e1e5e9;
}

.mpp-pagination-link {
    padding: 10px 20px;
    background: #0073aa;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.mpp-pagination-link:hover {
    background: #005a87;
    color: white;
    transform: translateY(-1px);
}

.mpp-pagination-info {
    color: #666;
    font-weight: 500;
}

/* ==========================================================================
   6. Loading States and Animations
   ========================================================================== */

.mpp-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
}

.mpp-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 115, 170, 0.2);
    border-radius: 50%;
    border-top-color: #0073aa;
    animation: mpp-spin 1s ease-in-out infinite;
}

@keyframes mpp-spin {
    to { 
        transform: rotate(360deg); 
    }
}

.mpp-fade-in {
    animation: mpp-fadeIn 0.5s ease-in-out;
}

@keyframes mpp-fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.mpp-no-messages, .mpp-no-channels {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #ddd;
}

.mpp-no-messages p, .mpp-no-channels p {
    margin: 0 0 16px 0;
    font-size: 1.1em;
}

.mpp-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 16px;
    margin: 16px 0;
}

/* ==========================================================================
   7. Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .mpp-channels-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .mpp-channel-card {
        padding: 20px;
    }
    
    .mpp-channel-actions {
        flex-direction: column;
    }
    
    .mpp-btn {
        text-align: center;
        width: 100%;
    }
    
    .mpp-inbox-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .mpp-search-form {
        max-width: none;
    }
    
    .mpp-search {
        flex-direction: column;
        gap: 12px;
    }
    
    .mpp-search-input {
        width: 100%;
    }
    
    .mpp-bulk-actions {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .mpp-messages-table {
        font-size: 13px;
    }
    
    .mpp-messages-table th,
    .mpp-messages-table td {
        padding: 10px 8px;
    }
    
    .mpp-col-webhook,
    .mpp-col-size {
        display: none;
    }
    
    .mpp-col-actions {
        width: 20%;
    }
    
    .mpp-btn-small {
        padding: 4px 6px;
        font-size: 11px;
    }
    
    .mpp-pagination {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .mpp-modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .mpp-modal-body {
        padding: 16px;
        max-height: 60vh;
    }
    
    .mpp-fields-table td {
        padding: 8px 12px;
    }
    
    .mpp-fields-table td:first-child {
        width: 40%;
    }
}

@media (max-width: 480px) {
    .mpp-hub-title {
        font-size: 1.5em;
    }
    
    .mpp-inbox-title {
        font-size: 1.4em;
    }
    
    .mpp-channel-card {
        padding: 16px;
    }
    
    .mpp-channel-stats {
        padding: 12px;
    }
    
    .mpp-messages-table th,
    .mpp-messages-table td {
        padding: 8px 6px;
    }
    
    .mpp-col-received {
        display: none;
    }
    
    .mpp-modal-header {
        padding: 16px;
    }
    
    .mpp-modal-title {
        font-size: 1.2em;
    }
}

/* ==========================================================================
   8. Print Styles
   ========================================================================== */

@media print {
    .mpp-channel-actions,
    .mpp-bulk-actions,
    .mpp-col-actions,
    .mpp-pagination,
    .mpp-modal {
        display: none !important;
    }
    
    .mpp-channels-hub,
    .mpp-channel-inbox {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .mpp-channel-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .mpp-messages-table {
        font-size: 12px;
    }
    
    .mpp-messages-table th,
    .mpp-messages-table td {
        padding: 6px;
    }
}

/* ==========================================================================
   4. Messages
   ========================================================================== */

.plugin-success-message {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    padding: 15px;
    margin: 15px 0;
}

.plugin-error-message {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 15px;
    margin: 15px 0;
}

.plugin-warning-message {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 15px;
    margin: 15px 0;
}

/* ==========================================================================
   5. Progress Indicators
   ========================================================================== */

.plugin-progress {
    width: 100%;
    height: 6px;
    background: #e1e5e9;
    border-radius: 3px;
    overflow: hidden;
    margin: 20px 0;
}

.plugin-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #0043ce, #4589ff);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

/* ==========================================================================
   6. Results Styling
   ========================================================================== */

.plugin-result-item {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    padding: 20px;
    margin: 15px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.plugin-result-item h4 {
    margin: 0 0 10px 0;
    color: #161616;
    font-size: 18px;
}

.plugin-result-item p {
    margin: 10px 0;
    color: #666;
    line-height: 1.6;
}

/* ==========================================================================
   7. Badges
   ========================================================================== */

.plugin-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plugin-badge.success {
    background: #d4edda;
    color: #155724;
}

.plugin-badge.warning {
    background: #fff3cd;
    color: #856404;
}

.plugin-badge.error {
    background: #f8d7da;
    color: #721c24;
}

.plugin-badge.info {
    background: #d1ecf1;
    color: #0c5460;
}

/* ==========================================================================
   8. Tooltips
   ========================================================================== */

.plugin-tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.plugin-tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px 12px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 14px;
}

.plugin-tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.plugin-tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* ==========================================================================
   9. Media Queries
   ========================================================================== */

@media (max-width: 768px) {
    .plugin-result-item {
        padding: 15px;
        margin: 10px 0;
    }
    
    .plugin-tooltip .tooltiptext {
        width: 150px;
        margin-left: -75px;
        font-size: 12px;
    }
}

/* ==========================================================================
   10. Print Styles
   ========================================================================== */

@media print {
    .plugin-container {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .plugin-submit-btn,
    .form-actions {
        display: none;
    }
}
