/* TFSS Communication Plugin Admin Styles */

#recipient-count {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    transition: all 0.3s ease;
}

#committee-role-container {
    margin-left: 20px;
    padding: 5px 0;
}

#committee_role {
    min-width: 200px;
}

.tfss-preview-count {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
}

.tfss-count-success {
    background-color: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

.tfss-count-warning {
    background-color: #fff3cd;
    color: #664d03;
    border: 1px solid #ffecb5;
}

.tfss-count-error {
    background-color: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
}

.tfss-loading {
    background-color: #e2e3e5;
    color: #495057;
    border: 1px solid #d3d3d4;
}

/* Button styling */
#send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#test-sms-button, #ai-rewrite-button {
    margin-left: 10px;
}

/* AI Button Enhanced Styling */
#ai-rewrite-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    margin-left: 10px;
    transition: all 0.3s ease;
    font-weight: 500;
}

#ai-rewrite-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#ai-rewrite-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* AI Popup Styles */
.ai-popup-button {
    transition: all 0.2s ease;
    font-weight: 500;
}

.ai-popup-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#ai-approve-btn:hover {
    background: #005a87 !important;
}

#ai-reject-btn:hover {
    background: #555 !important;
}

#ai-close-btn:hover {
    background: #c82333 !important;
}

/* Ensure popups appear above everything */
#ai-loading-popup, #ai-review-popup {
    z-index: 999999 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* Override any conflicting admin styles */
.wrap #ai-loading-popup,
.wrap #ai-review-popup,
#wpbody #ai-loading-popup,
#wpbody #ai-review-popup {
    position: fixed !important;
    z-index: 999999 !important;
}

/* Loading spinner and text animations */
@keyframes ai-pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.ai-loading-text {
    animation: ai-pulse 1.5s ease-in-out infinite;
}

/* Responsive popup adjustments */
@media (max-width: 768px) {
    #ai-review-popup > div {
        width: 95% !important;
        padding: 20px !important;
        margin: 10px !important;
    }
    
    #ai-loading-popup > div {
        width: 90% !important;
        padding: 20px !important;
    }
    
    .ai-popup-button {
        padding: 10px 16px !important;
        margin: 5px !important;
        display: block !important;
        width: 100% !important;
    }
}

/* Form improvements */
.form-table th {
    width: 140px;
}

.recipient-section {
    max-width: 600px;
}

.recipient-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.recipient-section input[type="radio"] {
    margin-right: 8px;
}

/* AI and SMS test section styling */
.button-section {
    margin-top: 10px;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
}

.button-section .button {
    margin-right: 10px;
}

/* Message composition improvements */
#message-content {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    border: 2px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    background-color: #fdfdfd;
    transition: border-color 0.3s ease;
}

#message-content:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 5px rgba(0, 115, 170, 0.3);
}

/* HTML Preview styling - Layout safe version */
#message-preview {
    border: 2px solid #e1e1e1;
    border-radius: 6px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    margin-top: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

#preview-content {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    background: white;
    min-height: 100px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: Arial, sans-serif;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: 100%;
    box-sizing: border-box;
}

/* Ensure ALL preview content stays within bounds */
#preview-content,
#preview-content * {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.tfss-invoice-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.tfss-invoice-modal {
    background: #fff;
    border-radius: 12px;
    padding: 25px;
    max-width: 960px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 65px rgba(0, 0, 0, 0.25);
}

.tfss-invoice-modal h2 {
    margin-top: 0;
    margin-bottom: 5px;
}

.tfss-invoice-modal p {
    margin-top: 0;
    color: #4a5568;
}

.tfss-invoice-frame {
    width: 100%;
    height: 60vh;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    margin-top: 15px;
    background: #fff;
}

.tfss-invoice-modal__actions {
    margin-top: 15px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.tfss-invoice-modal__actions .button-primary {
    padding: 8px 18px;
}

#preview-content table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
}

#preview-content td,
#preview-content th {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    max-width: 0 !important;
}

#preview-content img {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
}

#preview-content pre {
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow-x: auto !important;
}

/* Prevent any absolute or fixed positioning in preview */
#preview-content * {
    position: static !important;
}

/* HTML Help section */
#html-help {
    background: #f0f8ff;
    border: 1px solid #b6d7ff;
    border-radius: 6px;
    padding: 15px;
    margin-top: 10px;
    font-family: Arial, sans-serif;
}

#html-help code {
    background: #e7f3ff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
    color: #0066cc;
}

/* Button group styling */
.tfss-button-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.tfss-button-group .button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* Enhanced AI button styling */
#ai-rewrite-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    font-weight: 500;
}

#ai-rewrite-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#ai-rewrite-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Preview and help buttons */
#toggle-preview-btn, #html-help-btn {
    background: #f7f7f7;
    border: 1px solid #ccc;
    transition: all 0.2s ease;
}

#toggle-preview-btn:hover, #html-help-btn:hover {
    background: #e6e6e6;
    border-color: #999;
}

/* Responsive design */
@media (max-width: 768px) {
    .form-table th {
        width: auto;
        display: block;
        padding-bottom: 5px;
    }
    
    .form-table td {
        display: block;
        padding-top: 0;
    }
    
    #committee-role-container {
        margin-left: 0;
        margin-top: 10px;
    }

    .tfss-invoice-modal {
        padding: 15px;
        max-height: 95vh;
    }

    .tfss-invoice-frame {
        height: 50vh;
    }
}
