/* Admin-specific styles */

/* Admin Avatar */
.admin-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.admin-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-left {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-input {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 12px;
    min-width: 280px;
}

.search-input svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.search-input input {
    border: none;
    background: none;
    padding: 10px 12px;
    width: 100%;
    color: var(--text-primary);
    font-size: 14px;
}

.search-input input:focus {
    outline: none;
}

.filter-bar select {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

.result-count {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Admin Tabs */
.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0;
}

.admin-tab {
    padding: 12px 20px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
}

.admin-tab:hover {
    color: var(--text-primary);
}

.admin-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

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

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

/* Provider Filter Tabs */
.provider-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.provider-tab {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.provider-tab:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.provider-tab.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* Provider Group Header in Table */
.provider-group-header {
    background: var(--bg-tertiary) !important;
}

.provider-group-header td {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    padding: 12px 16px !important;
    border-top: 2px solid var(--border-color);
}

/* Provider Badge */
.provider-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.provider-badge.provider-openai {
    background: rgba(16, 163, 127, 0.15);
    color: #10a37f;
}

.provider-badge.provider-anthropic {
    background: rgba(204, 150, 90, 0.15);
    color: #cc965a;
}

.provider-badge.provider-google {
    background: rgba(66, 133, 244, 0.15);
    color: #4285f4;
}

.provider-badge.provider-unknown {
    background: rgba(128, 128, 128, 0.15);
    color: #808080;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.section-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

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

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.stat-icon.blue {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.stat-icon.green {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.stat-icon.purple {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
}

.stat-icon.orange {
    background: rgba(249, 115, 22, 0.1);
    color: #f97316;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Stats Row */
.stats-row {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}

.stats-half {
    flex: 1;
}

.stats-inline {
    display: flex;
    gap: 40px;
    margin-top: 16px;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-num {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Table Styles */
.loading-cell {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.active {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.status-badge.inactive {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.status-badge.pending {
    background: rgba(234, 179, 8, 0.1);
    color: #eab308;
}

.status-badge.sent {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.status-badge.failed {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Role Badges */
.role-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.role-badge.admin,
.role-badge.super_admin {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    color: #764ba2;
}

.role-badge.user {
    background: rgba(100, 116, 139, 0.1);
    color: #64748b;
}

/* Action Buttons */
.action-btn {
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn.view {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.action-btn.edit {
    background: rgba(234, 179, 8, 0.1);
    color: #eab308;
}

.action-btn.delete {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.action-btn.test {
    background: rgba(6, 182, 212, 0.1);
    color: #06b6d4;
}

.action-btn.activate {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.action-btn:hover {
    opacity: 0.8;
}

/* Form Styles */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-group input[readonly] {
    background: var(--bg-secondary);
    cursor: not-allowed;
}

/* Combobox: input + dropdown */
.combobox {
    position: relative;
}
.combobox input {
    width: 100%;
    padding-right: 32px;
}
.combobox-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 12px;
    user-select: none;
    line-height: 1;
}
.combobox-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.combobox-dropdown.open {
    display: block;
}
.combobox-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.combobox-item:hover {
    background: var(--bg-tertiary);
}
.combobox-item.highlighted {
    background: var(--bg-tertiary);
}
.combobox-empty {
    padding: 8px 12px;
    color: var(--text-secondary);
    font-size: 13px;
    font-style: italic;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

/* Modal Styles */
.modal.active {
    display: flex;
}

.modal-content.large {
    max-width: 900px;
    width: 95%;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* User Select List for Send Coupon */
.user-select-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
}

.user-select-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.user-select-item:last-child {
    border-bottom: none;
}

.user-select-item:hover {
    background: var(--bg-card-hover);
}

.user-select-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-purple);
}

.user-select-item .user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-select-item .user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.user-select-item .user-email {
    font-size: 12px;
    color: var(--text-tertiary);
}

.action-btn.primary {
    background: var(--accent-purple);
    color: white;
    border: none;
}

.action-btn.primary:hover {
    background: #7c3aed;
}

/* User Detail Modal Content */
.user-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.user-detail-section {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
}

.user-detail-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-detail-section p {
    margin: 8px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.user-detail-section strong {
    color: var(--text-primary);
}

.mini-table {
    max-height: 200px;
    overflow-y: auto;
}

.mini-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.mini-row:last-child {
    border-bottom: none;
}

/* Health Bar */
.health-bar {
    width: 60px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.health-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.health-fill.good {
    background: #22c55e;
}

.health-fill.warning {
    background: #eab308;
}

.health-fill.bad {
    background: #ef4444;
}

/* Pagination */
.table-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.page-btn {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Logout Button */
.logout-btn:hover {
    color: #ef4444;
}

/* Section Header */
.section-header {
    margin-bottom: 20px;
}

.section-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.section-desc {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* Form Hint */
.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Textarea in forms */
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'Fira Code', 'Courier New', monospace;
    resize: vertical;
    min-height: 60px;
    box-sizing: border-box;
}

.form-group textarea:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
}

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

    .user-detail-grid {
        grid-template-columns: 1fr;
    }

    .stats-inline {
        flex-wrap: wrap;
        gap: 20px;
    }

    .form-row {
        flex-direction: column;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-input {
        min-width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .admin-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .admin-tab {
        white-space: nowrap;
    }
}
