/**
 * Agentorie Chat Admin - Styles
 *
 * @package Agentorie_Chat
 * @since   1.0.0
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */
:root {
    --agentorie-primary: #6366f1;
    --agentorie-primary-light: #818cf8;
    --agentorie-primary-dark: #4f46e5;
    --agentorie-success: #10b981;
    --agentorie-success-dark: #059669;
    --agentorie-danger: #ef4444;
    --agentorie-warning: #f59e0b;
    --agentorie-info: #3b82f6;
    --agentorie-bg-primary: #f8fafc;
    --agentorie-bg-secondary: #ffffff;
    --agentorie-bg-tertiary: #f1f5f9;
    --agentorie-text-primary: #0f172a;
    --agentorie-text-secondary: #475569;
    --agentorie-text-tertiary: #94a3b8;
    --agentorie-border: #e2e8f0;
    --agentorie-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --agentorie-shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   General Wrapper
   ========================================================================== */
.agentorie-wrap {
    max-width: 1400px;
    margin: 20px 20px 20px 0;
}

.agentorie-wrap h1 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 23px;
    font-weight: 600;
    color: var(--agentorie-text-primary);
    margin-bottom: 20px;
}

.agentorie-wrap h1 .dashicons {
    color: var(--agentorie-primary);
}

/* ==========================================================================
   Cards
   ========================================================================== */
.agentorie-card {
    background: var(--agentorie-bg-secondary);
    border: 1px solid var(--agentorie-border);
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: var(--agentorie-shadow);
}

.agentorie-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--agentorie-border);
    background: var(--agentorie-bg-tertiary);
    border-radius: 8px 8px 0 0;
}

.agentorie-card .card-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--agentorie-text-primary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.agentorie-card .card-header .badge {
    background: var(--agentorie-warning);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.agentorie-card .card-body {
    padding: 20px;
}

.agentorie-card .card-body.disabled-section {
    opacity: 0.5;
    pointer-events: none;
}

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

.agentorie-stats-grid.four-cols {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1200px) {
    .agentorie-stats-grid.four-cols {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .agentorie-stats-grid.four-cols {
        grid-template-columns: 1fr;
    }
}

.agentorie-stat-card {
    background: var(--agentorie-bg-secondary);
    border: 1px solid var(--agentorie-border);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--agentorie-shadow);
    transition: all 0.2s;
}

.agentorie-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--agentorie-shadow-lg);
}

.agentorie-stat-card.small {
    padding: 16px;
}

.agentorie-stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.agentorie-stat-card .stat-icon .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #fff;
}

.agentorie-stat-card .stat-icon.conversations { background: linear-gradient(135deg, var(--agentorie-primary), var(--agentorie-primary-light)); }
.agentorie-stat-card .stat-icon.messages { background: linear-gradient(135deg, var(--agentorie-info), #60a5fa); }
.agentorie-stat-card .stat-icon.active { background: linear-gradient(135deg, var(--agentorie-success), #34d399); }
.agentorie-stat-card .stat-icon.human { background: linear-gradient(135deg, var(--agentorie-warning), #fbbf24); }
.agentorie-stat-card .stat-icon.admin { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.agentorie-stat-card .stat-icon.contacts { background: linear-gradient(135deg, var(--agentorie-danger), #f87171); }

.agentorie-stat-card .stat-content {
    flex: 1;
}

.agentorie-stat-card .stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--agentorie-text-primary);
    line-height: 1;
}

.agentorie-stat-card .stat-label {
    display: block;
    font-size: 12px;
    color: var(--agentorie-text-secondary);
    margin-top: 4px;
}

.agentorie-stat-card .stat-sub {
    display: block;
    font-size: 11px;
    color: var(--agentorie-text-tertiary);
    margin-top: 2px;
}

/* ==========================================================================
   Dashboard Grid
   ========================================================================== */
.agentorie-dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .agentorie-dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.agentorie-chart-card .card-body {
    height: 300px;
}

/* ==========================================================================
   Quick Actions
   ========================================================================== */
.agentorie-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--agentorie-bg-tertiary);
    border-radius: 8px;
    text-decoration: none;
    color: var(--agentorie-text-primary);
    transition: all 0.2s;
    position: relative;
}

.quick-action-btn:hover {
    background: var(--agentorie-primary);
    color: #fff;
    transform: translateY(-2px);
}

.quick-action-btn .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
    margin-bottom: 8px;
}

.quick-action-btn .action-label {
    font-size: 12px;
    font-weight: 500;
}

.quick-action-btn .badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--agentorie-danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
}

/* ==========================================================================
   Usage Stats
   ========================================================================== */
.agentorie-usage-stats {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.agentorie-usage-stats .usage-item {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--agentorie-border);
}

.agentorie-usage-stats .usage-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.agentorie-usage-stats .usage-label {
    font-size: 13px;
    color: var(--agentorie-text-secondary);
}

.agentorie-usage-stats .usage-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--agentorie-text-primary);
}

.agentorie-usage-stats .usage-unlimited {
    font-size: 11px;
    color: var(--agentorie-success);
    font-weight: 500;
}

.agentorie-usage-stats .usage-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.agentorie-usage-stats .usage-bar {
    width: 100%;
    height: 8px;
    background: var(--agentorie-bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.agentorie-usage-stats .usage-progress {
    height: 100%;
    background: linear-gradient(135deg, var(--agentorie-primary), var(--agentorie-primary-light));
    border-radius: 4px;
    transition: width 0.5s;
}

.agentorie-usage-stats .usage-progress.warning {
    background: linear-gradient(135deg, var(--agentorie-warning), #fbbf24);
}

.agentorie-usage-stats .usage-warning {
    width: 100%;
    font-size: 12px;
    color: var(--agentorie-warning);
    margin-top: 8px;
}

/* ==========================================================================
   License Info
   ========================================================================== */
.license-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
}

.license-plan {
    font-size: 14px;
    color: var(--agentorie-text-secondary);
}

.license-plan .plan-value {
    font-weight: 700;
    color: var(--agentorie-primary);
    text-transform: uppercase;
}

.license-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 6px;
}

.license-status.status-active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--agentorie-success);
}

.license-status.status-inactive,
.license-status.status-expired {
    background: rgba(245, 158, 11, 0.1);
    color: var(--agentorie-warning);
}

/* ==========================================================================
   Tabs Navigation
   ========================================================================== */
.agentorie-wrap .nav-tab-wrapper {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--agentorie-border);
}

.agentorie-wrap .nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--agentorie-text-secondary);
    text-decoration: none;
    border: 1px solid transparent;
    border-bottom: none;
    background: transparent;
    margin-bottom: -1px;
    border-radius: 4px 4px 0 0;
}

.agentorie-wrap .nav-tab:hover {
    color: var(--agentorie-primary);
}

.agentorie-wrap .nav-tab-active {
    background: var(--agentorie-bg-secondary);
    border-color: var(--agentorie-border);
    color: var(--agentorie-primary);
}

.agentorie-wrap .nav-tab .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.agentorie-wrap .nav-tab .count {
    font-size: 11px;
    color: var(--agentorie-text-tertiary);
}

/* ==========================================================================
   Tab Content
   ========================================================================== */
.agentorie-wrap .tab-content {
    display: none;
}

.agentorie-wrap .tab-content.active {
    display: block;
}

/* ==========================================================================
   Form Tables
   ========================================================================== */
.agentorie-wrap .form-table th {
    width: 200px;
    padding: 15px 10px 15px 0;
    font-weight: 500;
    color: var(--agentorie-text-primary);
}

.agentorie-wrap .form-table td {
    padding: 15px 10px;
}

.agentorie-wrap .form-table input[type="text"],
.agentorie-wrap .form-table input[type="email"],
.agentorie-wrap .form-table input[type="number"],
.agentorie-wrap .form-table select,
.agentorie-wrap .form-table textarea {
    border: 1px solid var(--agentorie-border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.agentorie-wrap .form-table input:focus,
.agentorie-wrap .form-table select:focus,
.agentorie-wrap .form-table textarea:focus {
    border-color: var(--agentorie-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    outline: none;
}

/* ==========================================================================
   Toggle Switch
   ========================================================================== */
.agentorie-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.agentorie-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: var(--agentorie-bg-tertiary);
    border: 1px solid var(--agentorie-border);
    border-radius: 12px;
    position: relative;
    transition: all 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.agentorie-toggle input:checked + .toggle-slider {
    background: var(--agentorie-primary);
    border-color: var(--agentorie-primary);
}

.agentorie-toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* ==========================================================================
   Tables
   ========================================================================== */
.agentorie-conversations-table {
    border-collapse: collapse;
}

.agentorie-conversations-table th,
.agentorie-conversations-table td {
    padding: 12px 10px;
    text-align: left;
}

.agentorie-conversations-table .check-column {
    width: 30px;
}

.agentorie-conversations-table .preview-column {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--agentorie-text-tertiary);
    font-size: 12px;
}

.agentorie-conversations-table .visitor-id {
    font-family: monospace;
    font-size: 11px;
    background: #2c88e3;
    padding: 2px 6px;
    border-radius: 4px;
}

.agentorie-conversations-table .indicators-column {
    white-space: nowrap;
}

.agentorie-conversations-table .indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    margin-right: 4px;
}

.agentorie-conversations-table .indicator-admin { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.agentorie-conversations-table .indicator-human { background: rgba(245, 158, 11, 0.1); color: var(--agentorie-warning); }
.agentorie-conversations-table .indicator-negotiate { background: rgba(245, 158, 11, 0.1); color: var(--agentorie-warning); }
.agentorie-conversations-table .indicator-contact { background: rgba(59, 130, 246, 0.1); color: var(--agentorie-info); }

.agentorie-conversations-table .actions-column {
    white-space: nowrap;
}

.agentorie-conversations-table .actions-column .button {
    padding: 4px 8px;
    margin-right: 4px;
}

/* ==========================================================================
   Contacts Grid
   ========================================================================== */
.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.contact-card {
    background: var(--agentorie-bg-secondary);
    border: 1px solid var(--agentorie-border);
    border-radius: 8px;
    padding: 16px;
}

.contact-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--agentorie-primary), var(--agentorie-primary-light));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.contact-name {
    font-weight: 600;
    color: var(--agentorie-text-primary);
}

.contact-date {
    font-size: 12px;
    color: var(--agentorie-text-tertiary);
}

.contact-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contact-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--agentorie-text-secondary);
}

.contact-row a {
    color: var(--agentorie-primary);
    text-decoration: none;
}

.contact-row a:hover {
    text-decoration: underline;
}

.contact-message {
    font-size: 13px;
    color: var(--agentorie-text-secondary);
    background: var(--agentorie-bg-tertiary);
    padding: 10px;
    border-radius: 6px;
    margin-top: 8px;
}

/* ==========================================================================
   Empty State
   ========================================================================== */
.agentorie-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--agentorie-text-tertiary);
}

.agentorie-empty-state .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.agentorie-empty-state p {
    font-size: 14px;
    margin: 0;
}

/* ==========================================================================
   Modal
   ========================================================================== */
.agentorie-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.agentorie-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.agentorie-modal .modal-content {
    position: relative;
    background: var(--agentorie-bg-secondary);
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--agentorie-shadow-lg);
    animation: agentorie-modal-in 0.2s ease;
}

.agentorie-modal .modal-content.modal-large {
    max-width: 700px;
}

@keyframes agentorie-modal-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.agentorie-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--agentorie-border);
}

.agentorie-modal .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.agentorie-modal .modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--agentorie-text-tertiary);
    cursor: pointer;
    line-height: 1;
}

.agentorie-modal .modal-close:hover {
    color: var(--agentorie-text-primary);
}

.agentorie-modal .modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.agentorie-modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ==========================================================================
   License Status Box
   ========================================================================== */
.license-status-box {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.license-status-box.status-active {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.license-status-box.status-inactive {
    background: var(--agentorie-bg-tertiary);
    border: 1px solid var(--agentorie-border);
}

.license-status-box.status-expired {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.plan-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.plan-badge.plan-free { background: var(--agentorie-bg-tertiary); color: var(--agentorie-text-secondary); }
.plan-badge.plan-starter { background: rgba(59, 130, 246, 0.1); color: var(--agentorie-info); }
.plan-badge.plan-pro { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.plan-badge.plan-enterprise { background: rgba(99, 102, 241, 0.1); color: var(--agentorie-primary); }

/* ==========================================================================
   Plans Table
   ========================================================================== */
.agentorie-plans-table {
    margin: 20px 0;
}

.agentorie-plans-table th,
.agentorie-plans-table td {
    text-align: center;
    padding: 12px;
}

.agentorie-plans-table th:first-child,
.agentorie-plans-table td:first-child {
    text-align: left;
}

.agentorie-plans-table .dashicons-yes {
    color: var(--agentorie-success);
}

.agentorie-plans-table .dashicons-no {
    color: var(--agentorie-text-tertiary);
}

.text-center {
    text-align: center;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 782px) {
    .agentorie-wrap {
        margin: 10px;
    }

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

    .agentorie-wrap .form-table td {
        display: block;
        padding-top: 5px;
    }

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

    .agentorie-quick-actions {
        grid-template-columns: 1fr;
    }
}

	.log-actions {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		gap: 5px;
	}
	.log-size-info {
		color: #50575e;
	}
	.log-actions .button .dashicons {
		font-size: 16px;
		width: 16px;
		height: 16px;
		margin-right: 4px;
	}
	