/**
 * Inqyra Admin Styles
 *
 * @package Inqyra
 */

/* General */
.inqyra-admin {
    max-width: 1400px;
}

.inqyra-admin h1 {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Cards */
.inqyra-card {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
}

.inqyra-card h2 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.inqyra-card-full {
    width: 100%;
}

/* Stats Grid */
.inqyra-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.inqyra-stat-card {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.inqyra-stat-icon {
    width: 48px;
    height: 48px;
    font-size: 48px;
    color: #2271b1;
}

.inqyra-stat-value {
    font-size: 28px;
    font-weight: 600;
    color: #1d2327;
    line-height: 1.2;
}

.inqyra-stat-label {
    color: #646970;
    font-size: 13px;
}

/* Dashboard Grid */
.inqyra-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* Settings Grid */
.inqyra-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

/* Status Badges */
.inqyra-status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
    background: #f0f0f1;
    color: #50575e;
}

.inqyra-status-success {
    background: #d4edda;
    color: #155724;
}

.inqyra-status-warning {
    background: #fff3cd;
    color: #856404;
}

.inqyra-status-error {
    background: #f8d7da;
    color: #721c24;
}

/* License Status */
.inqyra-license-status {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.inqyra-license-status.inqyra-status-success {
    background: #d4edda;
}

.inqyra-license-status.inqyra-status-warning {
    background: #fff3cd;
}

.inqyra-license-status.inqyra-status-error {
    background: #f8d7da;
}

.inqyra-license-status .inqyra-status-badge {
    margin-bottom: 10px;
}

.inqyra-license-status p {
    margin: 0;
}

.inqyra-license-expires {
    margin-top: 10px !important;
    font-size: 12px;
    color: #666;
}

/* Info Tables */
.inqyra-info-table {
    width: 100%;
    border-collapse: collapse;
}

.inqyra-info-table th,
.inqyra-info-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #f0f0f1;
}

.inqyra-info-table th {
    font-weight: 600;
    color: #1d2327;
    width: 40%;
}

.inqyra-info-table tr:last-child th,
.inqyra-info-table tr:last-child td {
    border-bottom: none;
}

/* Tabs */
.inqyra-tabs {
    margin-bottom: 20px;
}

.inqyra-tab-content {
    display: none;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-top: none;
    padding: 20px;
}

.inqyra-tab-content.inqyra-tab-active {
    display: block;
}

/* Forms */
.inqyra-form .form-table th {
    width: 200px;
    padding-left: 0;
}

.inqyra-form .submit {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inqyra-form .spinner {
    float: none;
    margin: 0;
}

.inqyra-save-status {
    color: #00a32a;
    font-weight: 500;
}

.inqyra-save-status.error {
    color: #d63638;
}

/* API Key Input */
.inqyra-api-key-input {
    font-family: monospace;
}

.inqyra-api-key-row {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.inqyra-api-key-row .inqyra-api-key-input {
    flex: 0 1 auto;
}

.inqyra-api-key-row .button {
    min-width: 32px;
    height: 32px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.inqyra-api-key-row .button .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
}

.inqyra-api-key-row .inqyra-key-status {
    flex-shrink: 0;
}

.inqyra-key-validate-status {
    font-size: 13px;
    margin-left: 4px;
}

/* Agent Selector */
.inqyra-agent-selector {
    font-size: 14px;
    padding: 5px 10px;
    margin-left: auto;
}

/* Model Selects */
.inqyra-model-select {
    min-width: 200px;
}

/* Empty State */
.inqyra-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #646970;
    background: #f6f7f7;
    border-radius: 4px;
}

/* Content Preview */
.inqyra-content-preview {
    color: #646970;
    font-size: 12px;
}

/* Filter Bar */
.inqyra-filter-bar {
    margin-bottom: 20px;
}

.inqyra-filter-bar select {
    min-width: 150px;
}

/* Conversation Messages */
.inqyra-conversation-messages {
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    background: #f9f9f9;
}

.inqyra-conversation-messages .inqyra-message {
    margin-bottom: 15px;
    padding: 12px;
    border-radius: 8px;
    max-width: 80%;
}

.inqyra-conversation-messages .inqyra-message-user {
    background: #e3f2fd;
    margin-left: auto;
}

.inqyra-conversation-messages .inqyra-message-assistant {
    background: #fff;
    border: 1px solid #ddd;
}

.inqyra-conversation-messages .inqyra-message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
}

.inqyra-conversation-messages .inqyra-message-time {
    color: #666;
}

.inqyra-conversation-messages .inqyra-message-content {
    line-height: 1.5;
}

.inqyra-conversation-messages .inqyra-message-meta {
    margin-top: 8px;
    font-size: 11px;
    color: #888;
}

/* Embedding Status */
.inqyra-embedding-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.inqyra-embedding-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inqyra-embedding-stat .label {
    font-size: 12px;
    color: #646970;
    font-weight: 500;
}

.inqyra-embedding-stat .value {
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
}

.inqyra-embedding-progress-bar,
.inqyra-crawl-progress-bar {
    height: 8px;
    background: #f0f0f1;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
}

.inqyra-crawl-progress-bar {
    margin-top: 10px;
}

.inqyra-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2271b1 0%, #72aee6 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

#inqyra-embedding-message {
    margin-left: 10px;
    color: #646970;
}

/* Icon Upload */
.inqyra-icon-upload {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.inqyra-icon-preview {
    width: 60px;
    height: 60px;
    border: 2px dashed #c3c4c7;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f6f7f7;
    overflow: hidden;
}

.inqyra-icon-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.inqyra-icon-upload .button {
    flex-shrink: 0;
}

.inqyra-icon-upload .description {
    width: 100%;
    margin-top: 8px;
}

/* Responsive */
@media screen and (max-width: 782px) {
    .inqyra-stats-grid {
        grid-template-columns: 1fr;
    }

    .inqyra-dashboard-grid {
        grid-template-columns: 1fr;
    }

    .inqyra-settings-grid {
        grid-template-columns: 1fr;
    }

    .inqyra-form .form-table th {
        width: auto;
        display: block;
        padding-bottom: 5px;
    }

    .inqyra-form .form-table td {
        display: block;
        padding-left: 0;
    }

    .inqyra-message {
        max-width: 100%;
    }

    .inqyra-embedding-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Widget Preview Modal */
.inqyra-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inqyra-preview-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
}

.inqyra-preview-container {
    position: relative;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.inqyra-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-bottom: 1px solid #ddd;
}

.inqyra-preview-header h2 {
    margin: 0;
    font-size: 16px;
}

.inqyra-preview-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    line-height: 1;
}

.inqyra-preview-close:hover {
    color: #000;
}

.inqyra-preview-body {
    padding: 20px;
    overflow: auto;
    flex: 1;
}

.inqyra-preview-device {
    background: #f5f5f5;
    border-radius: 8px;
    min-height: 500px;
    position: relative;
    overflow: hidden;
}

#inqyra-preview-widget-container {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
}

/* Widget CSS overrides for preview context */
#inqyra-preview-widget-container .inqyra-widget {
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: auto !important;
}

#inqyra-preview-widget-container .inqyra-container {
    position: absolute !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    display: flex !important;
    box-shadow: none !important;
    animation: none !important;
    border-radius: 12px !important;
}

#inqyra-preview-widget-container .inqyra-widget.inqyra-position-bottom-right .inqyra-container,
#inqyra-preview-widget-container .inqyra-widget.inqyra-position-bottom-left .inqyra-container {
    bottom: 70px;
    top: 10px;
    right: 15px;
    left: 15px;
}

#inqyra-preview-widget-container .inqyra-widget.inqyra-position-top-right .inqyra-container,
#inqyra-preview-widget-container .inqyra-widget.inqyra-position-top-left .inqyra-container {
    top: 70px;
    bottom: 10px;
    right: 15px;
    left: 15px;
}

#inqyra-preview-widget-container .inqyra-toggle {
    position: absolute !important;
}

#inqyra-preview-widget-container .inqyra-widget.inqyra-position-bottom-right .inqyra-toggle {
    bottom: 15px;
    right: 15px;
}

#inqyra-preview-widget-container .inqyra-widget.inqyra-position-bottom-left .inqyra-toggle {
    bottom: 15px;
    left: 15px;
}

#inqyra-preview-widget-container .inqyra-widget.inqyra-position-top-right .inqyra-toggle {
    top: 15px;
    right: 15px;
}

#inqyra-preview-widget-container .inqyra-widget.inqyra-position-top-left .inqyra-toggle {
    top: 15px;
    left: 15px;
}

#inqyra-preview-widget-container .inqyra-messages {
    min-height: 120px;
}

#inqyra-preview-widget-container .inqyra-message {
    animation: none !important;
}

.inqyra-preview-note {
    margin: 15px 0 0 0;
    padding: 10px;
    background: #fff8e1;
    border-radius: 4px;
    font-size: 13px;
    color: #666;
    text-align: center;
}

/* Premium badge */
.inqyra-premium-badge {
    display: inline-block;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    font-size: 7px;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Free tier notice in config */
.inqyra-free-tier-notice {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.inqyra-free-tier-notice a {
    font-weight: 600;
}

/* Refresh models link */
.inqyra-refresh-models-link {
    text-decoration: none;
    font-size: 13px;
}

.inqyra-refresh-models-link .dashicons {
    transition: transform 0.3s;
}

.inqyra-refresh-models-link .dashicons.spin {
    animation: inqyra-spin 1s linear infinite;
}

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