/* Clevdex - Admin Styles */

.clevdex-chatbot-admin {
    margin-right: 20px;
}

.clevdex-chatbot-admin .notice {
    margin-top: 20px;
}

/* Dashboard Grid Layout */
.ai-chatbot-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-template-rows: auto auto auto;
    grid-gap: 20px;
    grid-template-areas: 
        "status-cards quick-actions"
        "recent-activity config-summary"
        "recent-activity .";
}

.ai-chatbot-status-cards {
    grid-area: status-cards;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    grid-gap: 20px;
}

.ai-chatbot-quick-actions {
    grid-area: quick-actions;
}

.ai-chatbot-recent-activity {
    grid-area: recent-activity;
}

.ai-chatbot-config-summary {
    grid-area: config-summary;
}

/* Status Cards */
.status-card {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
    min-height: 120px;
}

.status-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.status-card.connected {
    border-left: 4px solid #00a32a;
}

.status-card.disconnected {
    border-left: 4px solid #d63638;
}

.status-card.enabled {
    border-left: 4px solid #007cba;
}

.status-card.disabled {
    border-left: 4px solid #ddd;
}

.status-icon {
    font-size: 32px;
    min-width: 40px;
}

.status-card.connected .status-icon {
    color: #00a32a;
}

.status-card.disconnected .status-icon {
    color: #d63638;
}

.status-card.enabled .status-icon {
    color: #007cba;
}

.status-card.disabled .status-icon {
    color: #a7aaad;
}

.status-content {
    flex: 1;
}

.status-content h3 {
    margin: 0 0 5px 0;
    font-size: 16px;
    font-weight: 600;
}

.status-text {
    margin: 0 0 10px 0;
    color: #646970;
    font-size: 14px;
}

/* Quick Actions */
.quick-action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-gap: 15px;
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    text-decoration: none;
    background: #f6f7f7;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.3s ease;
    color: #1d2327;
}

.quick-action:hover {
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    color: #007cba;
    text-decoration: none;
}

.quick-action .dashicons {
    font-size: 24px;
    margin-bottom: 8px;
}

/* Analytics Stats */
.analytics-stats {
    display: flex;
    gap: 20px;
}

.stat {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 24px;
    font-weight: 600;
    color: #007cba;
}

.stat-label {
    font-size: 12px;
    color: #646970;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Configuration Summary */
.config-summary-table {
    width: 100%;
    border-spacing: 0;
}

.config-summary-table td {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f1;
}

.config-summary-table td:first-child {
    font-weight: 600;
    width: 40%;
}

.color-indicator {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    margin-right: 8px;
    vertical-align: middle;
    border: 1px solid #ddd;
}

/* Settings Tabs */
.ai-chatbot-settings-tabs {
    margin-top: 20px;
}

.nav-tab-wrapper {
    border-bottom: 1px solid #c3c4c7;
}

.tab-content {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-top: none;
    padding: 20px;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Connection Test Section */
.connection-test-section {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 4px;
    padding: 20px;
    margin-top: 20px;
}

.connection-test-section h3 {
    margin: 0 0 10px 0;
}

#connection-test-result {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
    display: none;
}

#connection-test-result.success {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

#connection-test-result.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Widget Preview */
.widget-preview-section {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 4px;
    padding: 20px;
    margin-top: 20px;
}

#widget-preview-container {
    margin-top: 15px;
    padding: 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-height: 200px;
}

.widget-preview-placeholder {
    text-align: center;
    color: #646970;
    font-style: italic;
    padding: 60px 0;
}

/* Display Rules Help */
.display-rules-help {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 4px;
    padding: 20px;
    margin-top: 20px;
}

.display-rules-help h4 {
    margin: 0 0 15px 0;
}

.display-rules-help ul {
    margin: 0;
    padding-left: 20px;
}

.display-rules-help li {
    margin-bottom: 5px;
}

/* Advanced Actions */
.advanced-actions {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 4px;
    padding: 20px;
    margin-top: 20px;
}

.advanced-actions h4 {
    margin: 0 0 15px 0;
}

.advanced-actions .button {
    margin-right: 10px;
    margin-bottom: 10px;
}

/* Settings Footer */
.ai-chatbot-settings-footer {
    background: #f8f9fa;
    border: 1px solid #c3c4c7;
    border-top: none;
    padding: 20px;
    text-align: right;
}

.ai-chatbot-settings-footer .button {
    margin-left: 10px;
}

/* Password Field */
.password-field-container {
    position: relative;
    display: inline-block;
}

.toggle-password {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    padding: 5px;
    cursor: pointer;
}

/* Analytics */
.clevdex-chatbot-analytics .analytics-filters {
    background: #fff;
    padding: 20px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    margin-bottom: 20px;
}

.analytics-filters label {
    font-weight: 600;
    margin-right: 10px;
}

.analytics-filters select {
    margin-right: 15px;
}

.analytics-dashboard {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    min-height: 400px;
}

#analytics-content {
    padding: 20px;
}

/* Analytics Summary Cards */
.analytics-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    grid-gap: 16px;
    margin-bottom: 24px;
}

.analytics-card {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.analytics-card-icon .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
    color: #435ebe;
}

.analytics-card-number {
    display: block;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    color: #1d2327;
}

.analytics-card-label {
    display: block;
    font-size: 13px;
    color: #646970;
}

/* Analytics Chart Section */
.analytics-chart-section {
    margin-bottom: 24px;
}

.analytics-chart-section h3 {
    margin-top: 0;
}

/* Analytics Topics */
.analytics-topic-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.analytics-topic-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f1;
}

.topic-count {
    font-weight: 600;
    color: #435ebe;
}

.analytics-meta {
    padding-top: 12px;
    border-top: 1px solid #f0f0f1;
    color: #8c8f94;
}

/* Activity Items */
.activity-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f1;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item .dashicons {
    color: #646970;
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.activity-time {
    margin-left: auto;
    font-size: 12px;
    color: #8c8f94;
    white-space: nowrap;
}

/* Tools */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    grid-gap: 20px;
}

.tool-card {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px;
}

.tool-card h3 {
    margin: 0 0 10px 0;
}

.tool-card p {
    color: #646970;
    margin-bottom: 15px;
}

/* Modal */
.ai-chatbot-modal {
    position: fixed;
    z-index: 100000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fff;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    width: 80%;
    max-width: 600px;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: #646970;
}

.modal-close:hover {
    color: #000;
}

/* Status Monitor */
.ai-chatbot-status-monitor {
    position: fixed;
    top: 32px;
    right: 20px;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 10px 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 1000;
    min-width: 200px;
}

.monitor-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.monitor-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00a32a;
    animation: pulse 2s infinite;
}

.monitor-indicator.warning {
    background: #dba617;
}

.monitor-indicator.error {
    background: #d63638;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.button.loading {
    position: relative;
}

.button.loading:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Success/Error Messages */
.ai-chatbot-message {
    padding: 10px 15px;
    border-radius: 4px;
    margin: 10px 0;
}

.ai-chatbot-message.success {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.ai-chatbot-message.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.ai-chatbot-message.warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .ai-chatbot-dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-areas: 
            "status-cards"
            "quick-actions"
            "recent-activity"
            "config-summary";
    }
}

@media (max-width: 768px) {
    .ai-chatbot-status-cards {
        grid-template-columns: 1fr;
    }
    
    .status-card {
        flex-direction: column;
        text-align: center;
    }
    
    .quick-action-grid {
        grid-template-columns: 1fr;
    }
    
    .analytics-stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .tools-grid {
        grid-template-columns: 1fr;
    }
}

/* Form Validation States */
.form-table .invalid {
    border-color: #d63638;
    box-shadow: 0 0 0 1px #d63638;
}

.form-table .valid {
    border-color: #00a32a;
    box-shadow: 0 0 0 1px #00a32a;
}

/* Tooltips */
.ai-chatbot-tooltip {
    position: relative;
    cursor: help;
}

.ai-chatbot-tooltip:hover:after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1d2327;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
}

.ai-chatbot-tooltip:hover:before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1d2327;
    margin-bottom: -5px;
}

/* Color Picker Enhancements */
.wp-picker-container {
    margin-bottom: 10px;
}

/* Settings Header */
.ai-chatbot-settings-header {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
}

.ai-chatbot-settings-header p.description {
    margin: 0;
    font-size: 14px;
}

/* =============================================
   Setup Wizard
   ============================================= */

.clevdex-chatbot-setup-wizard {
    max-width: 800px;
    margin: 20px auto;
}

/* Progress bar */
.wizard-progress {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px 24px 14px;
    margin-bottom: 24px;
}

.wizard-progress-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.wizard-step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
}

.wizard-step-indicator .step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #dcdcde;
    color: #50575e;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    transition: all 0.3s ease;
}

.wizard-step-indicator.active .step-number {
    background: #435ebe;
    color: #fff;
}

.wizard-step-indicator.completed .step-number {
    background: #00a32a;
    color: #fff;
}

.wizard-step-indicator .step-label {
    font-size: 12px;
    color: #646970;
    text-align: center;
}

.wizard-step-indicator.active .step-label {
    color: #1d2327;
    font-weight: 600;
}

.wizard-progress-bar {
    height: 4px;
    background: #dcdcde;
    border-radius: 2px;
    overflow: hidden;
}

.wizard-progress-fill {
    height: 100%;
    background: #435ebe;
    border-radius: 2px;
    transition: width 0.4s ease;
}

/* Step content cards */
.wizard-content {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 32px;
}

.wizard-step h2 {
    margin-top: 0;
    font-size: 24px;
}

.wizard-step-description {
    font-size: 14px;
    color: #646970;
    max-width: 600px;
    line-height: 1.6;
}

/* Welcome step */
.wizard-step-welcome {
    text-align: center;
}

.wizard-step-welcome .wizard-step-description {
    margin: 0 auto 24px;
}

.wizard-step-icon {
    margin-bottom: 12px;
}

.wizard-checklist {
    list-style: none;
    padding: 0;
    display: inline-block;
    text-align: left;
    margin: 0 0 28px;
}

.wizard-checklist li {
    padding: 6px 0;
    font-size: 14px;
}

.wizard-checklist li .dashicons {
    color: #00a32a;
    margin-right: 6px;
    vertical-align: middle;
}

/* Actions row */
.wizard-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #f0f0f1;
}

.wizard-skip-link {
    display: block;
    margin-top: 14px;
    color: #646970;
    text-decoration: none;
    font-size: 13px;
}

.wizard-skip-link:hover {
    color: #135e96;
}

/* Activate step */
.wizard-activate-toggle {
    background: #f6f7f7;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 24px;
}

.wizard-toggle-label {
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.wizard-toggle-label input[type="checkbox"] {
    transform: scale(1.3);
    margin-right: 8px;
    vertical-align: middle;
}

.wizard-config-summary {
    margin-bottom: 20px;
}

.wizard-config-summary h3 {
    margin: 0 0 12px;
}

/* Complete step */
.wizard-step-complete {
    text-align: center;
}

.wizard-step-complete .wizard-step-description {
    margin: 0 auto 28px;
}

.wizard-next-steps {
    text-align: left;
    max-width: 600px;
    margin: 0 auto;
}

.wizard-next-steps h3 {
    margin: 0 0 16px;
}

.wizard-next-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
}

.wizard-next-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 14px;
    background: #f6f7f7;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    text-decoration: none;
    color: #1d2327;
    transition: border-color 0.2s, box-shadow 0.2s;
    text-align: center;
}

.wizard-next-card:hover {
    border-color: #435ebe;
    box-shadow: 0 0 0 1px #435ebe;
    color: #1d2327;
}

.wizard-next-card .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
    color: #435ebe;
}

.wizard-next-card strong {
    font-size: 14px;
}

.wizard-next-card span:last-child {
    font-size: 12px;
    color: #646970;
}

/* Required field indicator */
.required {
    color: #d63638;
}

/* Responsive Wizard */
@media (max-width: 600px) {
    .wizard-progress-steps {
        flex-wrap: wrap;
        gap: 8px;
    }

    .wizard-step-indicator .step-label {
        display: none;
    }

    .wizard-next-grid {
        grid-template-columns: 1fr;
    }

    .wizard-content {
        padding: 20px 16px;
    }
}