/**
 * TG Live Chat - Admin Styles
 */

/* Button Icon Alignment Fix */
.tglivechat-admin-wrap .button .dashicons {
    vertical-align: middle;
    line-height: 1;
}

.tglivechat-admin-wrap .button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Main Container */
.tglivechat-admin-wrap {
    margin: 20px 20px 20px 0;
    background: #f8f9fa;
    min-height: 100vh;
}

.tglivechat-main-title {
    font-size: 28px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
}

.tglivechat-main-title .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
    color: #667eea;
}

/* Navigation Tabs */
.tglivechat-nav-tabs {
    margin: 0 20px 30px;
    border-bottom: 2px solid #e2e8f0;
    background: transparent;
}

.tglivechat-nav-tabs .nav-tab {
    border: none;
    background: transparent;
    color: #64748b;
    font-weight: 500;
    padding: 12px 20px;
    margin: 0 5px 0 0;
    border-radius: 8px 8px 0 0;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tglivechat-nav-tabs .nav-tab:hover {
    background: #f1f5f9;
    color: #334155;
}

.tglivechat-nav-tabs .nav-tab.nav-tab-active {
    background: #ffffff;
    color: #667eea;
    border-bottom: 3px solid #667eea;
    font-weight: 600;
}

.tglivechat-nav-tabs .nav-tab .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Tab Content */
.tglivechat-tab-content {
    padding: 0 20px;
}

/* Cards */
.tglivechat-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 24px;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.tglivechat-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.tglivechat-card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-bottom: 1px solid #e2e8f0;
    padding: 20px 24px;
}

.tglivechat-card-header h2,
.tglivechat-card-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tglivechat-card-header .dashicons {
    color: #667eea;
    font-size: 22px;
    width: 22px;
    height: 22px;
}

.tglivechat-card-body {
    padding: 24px;
}

.tglivechat-featured-card {
    border: 2px solid #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

/* Settings Grid */
.tglivechat-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

@media (max-width: 1200px) {
    .tglivechat-settings-grid {
        grid-template-columns: 1fr;
    }
}

/* Form Elements */
.tglivechat-settings-form .form-table th {
    font-weight: 600;
    color: #334155;
    padding: 16px 10px;
}

.tglivechat-settings-form .form-table td {
    padding: 16px 10px;
}

.tglivechat-settings-form .description {
    color: #64748b;
    font-size: 13px;
    margin-top: 6px;
}

/* Toggle Switch */
.tglivechat-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.tglivechat-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.tglivechat-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e0;
    transition: 0.3s;
    border-radius: 26px;
}

.tglivechat-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.tglivechat-switch input:checked + .tglivechat-slider {
    background-color: #667eea;
}

.tglivechat-switch input:checked + .tglivechat-slider:before {
    transform: translateX(24px);
}

/* Range Slider */
.tglivechat-range-slider {
    width: 100%;
    max-width: 300px;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    margin-right: 12px;
}

.tglivechat-range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.tglivechat-range-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

.tglivechat-range-slider + output {
    display: inline-block;
    padding: 4px 12px;
    background: #667eea;
    color: white;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    min-width: 50px;
    text-align: center;
}

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

.tglivechat-badge-success {
    background: #d1fae5;
    color: #065f46;
}

.tglivechat-badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.tglivechat-badge-default {
    background: #e5e7eb;
    color: #374151;
}

.tglivechat-badge-pro {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    margin-left: 8px;
}

/* Submit Button */
.tglivechat-submit-wrapper {
    text-align: center;
    padding: 30px 0;
}

.tglivechat-submit-wrapper .button-hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-weight: 600;
    font-size: 16px;
    padding: 14px 36px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tglivechat-submit-wrapper .button-hero:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Dashboard Stats */
.tglivechat-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 1400px) {
    .tglivechat-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.tglivechat-stat-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
}

.tglivechat-stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.tglivechat-stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.tglivechat-stat-danger .tglivechat-stat-icon {
    background: #fee2e2;
    color: #dc2626;
}

.tglivechat-stat-success .tglivechat-stat-icon {
    background: #d1fae5;
    color: #059669;
}

.tglivechat-stat-info .tglivechat-stat-icon {
    background: #dbeafe;
    color: #2563eb;
}

.tglivechat-stat-warning .tglivechat-stat-icon {
    background: #fef3c7;
    color: #d97706;
}

.tglivechat-stat-content {
    flex: 1;
}

.tglivechat-stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
    margin-bottom: 6px;
}

.tglivechat-stat-label {
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
}

/* Performance Grid */
.tglivechat-performance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 30px;
}

.tglivechat-performance-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e2e8f0;
}

.tglivechat-performance-item:last-child {
    border-bottom: none;
}

.tglivechat-performance-item .label {
    color: #64748b;
    font-weight: 500;
}

.tglivechat-performance-item .value {
    color: #1e293b;
    font-weight: 700;
    font-size: 18px;
}

/* Logs Table */
.tglivechat-logs-container {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.tglivechat-logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.tglivechat-logs-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #1e293b;
}

.tglivechat-logs-actions {
    display: flex;
    gap: 12px;
}

.tglivechat-table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.tglivechat-logs-table {
    margin: 0;
}

.tglivechat-logs-table thead th {
    background: #f8f9fa;
    color: #334155;
    font-weight: 600;
    padding: 14px 12px;
    text-align: left;
}

.tglivechat-logs-table tbody td {
    padding: 14px 12px;
    vertical-align: top;
}

.tglivechat-url-cell {
    max-width: 400px;
    word-break: break-all;
}

.tglivechat-url-cell a {
    color: #2563eb;
    text-decoration: none;
    font-size: 14px;
}

.tglivechat-url-cell a:hover {
    text-decoration: underline;
}

.tglivechat-referrer {
    margin-top: 6px;
    color: #94a3b8;
    font-size: 12px;
}

/* Empty State */
.tglivechat-empty-state {
    text-align: center;
    padding: 60px 20px;
}

.tglivechat-empty-state .dashicons {
    font-size: 64px;
    width: 64px;
    height: 64px;
    color: #cbd5e0;
    margin-bottom: 20px;
}

.tglivechat-empty-state h3 {
    font-size: 24px;
    color: #334155;
    margin-bottom: 12px;
}

.tglivechat-empty-state p {
    color: #64748b;
    font-size: 16px;
}

/* Pagination */
.tglivechat-pagination {
    text-align: center;
    margin-top: 30px;
}

.tglivechat-pagination .page-numbers {
    display: inline-block;
    padding: 8px 14px;
    margin: 0 4px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #334155;
    text-decoration: none;
    transition: all 0.2s ease;
}

.tglivechat-pagination .page-numbers:hover,
.tglivechat-pagination .page-numbers.current {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Help Page */
.tglivechat-help-container {
    display: flex !important;
    gap: 30px;
    align-items: flex-start;
    flex-wrap: nowrap;
}

.tglivechat-main-content {
    flex: 0 0 68% !important;
    max-width: 68%;
}

.tglivechat-sidebar {
    flex: 0 0 calc(32% - 30px) !important;
    max-width: calc(32% - 30px);
}

.tglivechat-sidebar-card {
    position: sticky;
    top: 20px;
}

.tglivechat-help-container ul,
.tglivechat-help-container ol {
    line-height: 1.8;
    color: #334155;
}

.tglivechat-help-container li {
    margin-bottom: 10px;
}

/* Contact Form */
.tglivechat-contact-form {
    margin: 0;
}

.tglivechat-form-group {
    margin-bottom: 16px;
}

.tglivechat-form-group label {
    display: block;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
    font-size: 14px;
}

.tglivechat-form-group label .required {
    color: #dc2626;
}

.tglivechat-form-group input[type="text"],
.tglivechat-form-group input[type="email"],
.tglivechat-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    box-sizing: border-box;
    font-family: inherit;
}

.tglivechat-form-group input:focus,
.tglivechat-form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.tglivechat-form-actions {
    display: block;
}

.tglivechat-submit-contact {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    border-radius: 8px;
}

.tglivechat-submit-contact:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.tglivechat-submit-contact:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.tglivechat-contact-status {
    font-size: 14px;
    font-weight: 600;
}

.tglivechat-contact-status.success {
    color: #059669;
}

.tglivechat-contact-status.error {
    color: #dc2626;
}

.tglivechat-help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
    margin: 24px 0;
}

/* Chart */
#tglivechat-chart {
    max-width: 100%;
    height: auto;
}

/* Services Grid */
.tglivechat-services-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 20px;
    margin-top: 30px;
}

/* Responsive - Stack on smaller screens */
@media (max-width: 1024px) {
    .tglivechat-help-container {
        flex-direction: column !important;
        flex-wrap: wrap !important;
    }
    
    .tglivechat-main-content,
    .tglivechat-sidebar {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }
    
    .tglivechat-services-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 768px) {
    .tglivechat-admin-wrap {
        margin: 10px;
    }
    
    .tglivechat-stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    .tglivechat-logs-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .tglivechat-logs-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .tglivechat-logs-actions button,
    .tglivechat-logs-actions a {
        width: 100%;
    }
}

/* Admin Bar */
.tglivechat-admin-bar-item .ab-icon::before {
    content: "\f534" !important;
    color: #ff6b6b;
    font-size: 20px;
}

/* Loading Spinner */
.tglivechat-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e2e8f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: aisr-spin 0.8s linear infinite;
}

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

/* Success/Error Messages */
.tglivechat-message {
    padding: 12px 20px;
    border-radius: 8px;
    margin: 16px 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.tglivechat-message-success {
    background: #d1fae5;
    color: #065f46;
}

.tglivechat-message-error {
    background: #fee2e2;
    color: #991b1b;
}

/* Admin Menu Icon Size */
#adminmenu .toplevel_page_tg-live-chat .wp-menu-image img,
#adminmenu .toplevel_page_tg-live-chat .wp-menu-image svg {
	max-width: 20px !important;
	height: auto;
}

/* Chat History Layout */
.tglivechat-history-container {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.tglivechat-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.tglivechat-history-filters {
    display: flex;
    gap: 8px;
}

.tglivechat-history-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    min-height: 600px;
}

.tglivechat-conversations-list {
    border-right: 1px solid #e2e8f0;
    padding-right: 24px;
    max-height: 600px;
    overflow-y: auto;
}

.tglivechat-conversation-item {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.tglivechat-conversation-item:hover {
    background: #f8f9fa;
    border-color: #e2e8f0;
}

.tglivechat-conversation-item.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.tglivechat-conversation-item.active a {
    color: white;
}

.tglivechat-conversation-item a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.tglivechat-conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.tglivechat-conversation-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    opacity: 0.8;
}

.tglivechat-conversation-detail {
    padding-left: 24px;
}

.tglivechat-conversation-detail-header h3 {
    margin: 0 0 16px 0;
    font-size: 20px;
    color: #1e293b;
}

.tglivechat-conversation-info {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 24px;
}

.tglivechat-conversation-info p {
    margin: 8px 0;
    font-size: 14px;
}

.tglivechat-messages-container {
    max-height: 500px;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
}

.tglivechat-message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.tglivechat-message-customer {
    align-items: flex-start;
}

.tglivechat-message-admin {
    align-items: flex-end;
}

.tglivechat-message-content {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 70%;
    word-wrap: break-word;
}

.tglivechat-message-customer .tglivechat-message-content {
    background: white;
    border: 1px solid #e2e8f0;
}

.tglivechat-message-admin .tglivechat-message-content {
    background: #667eea;
    color: white;
}

.tglivechat-message-time {
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
    padding: 0 4px;
}

.tglivechat-conversation-detail-empty {
    padding-left: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: #64748b;
}

@media (max-width: 1024px) {
    .tglivechat-history-layout {
        grid-template-columns: 1fr;
    }
    
    .tglivechat-conversations-list {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        padding-right: 0;
        padding-bottom: 24px;
        margin-bottom: 24px;
        max-height: 300px;
    }
    
    .tglivechat-conversation-detail {
        padding-left: 0;
    }
}

