/* Client Auth Admin Dashboard Styles */

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: #f8fafc;
    color: #1e293b;
}

.admin-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Tabs */
.tab-bar {
    display: flex;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 24px;
    gap: 0;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
    font-family: inherit;
}

.tab-btn:hover { color: #1e293b; }

.tab-btn.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.tab-panel {
    display: none;
}

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

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

.stat-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
}

.stat-label {
    font-size: 13px;
    color: #64748b;
    margin-top: 4px;
}

/* Table styles */
.data-table-wrap {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.data-table-wrap table {
    width: 100%;
    border-collapse: collapse;
}

.data-table-wrap th {
    background: #f8fafc;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.data-table-wrap td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.data-table-wrap tr:last-child td {
    border-bottom: none;
}

.data-table-wrap tr:hover td {
    background: #f8fafc;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle-switch input { display: none; }

.toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #cbd5e1;
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: #22c55e;
}

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

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-input {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    width: 220px;
    font-family: inherit;
}

.search-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    font-family: inherit;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
    font-family: inherit;
}

.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }

.btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }

.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.badge-green { background: #dcfce7; color: #16a34a; }
.badge-yellow { background: #fef9c3; color: #ca8a04; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-blue { background: #dbeafe; color: #2563eb; }
.badge-gray { background: #f1f5f9; color: #64748b; }

/* Activity stream */
.activity-stream {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    gap: 12px;
}

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

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.activity-icon.login { background: #dcfce7; color: #16a34a; }
.activity-icon.logout { background: #f1f5f9; color: #64748b; }
.activity-icon.failed { background: #fee2e2; color: #dc2626; }
.activity-icon.config { background: #dbeafe; color: #2563eb; }
.activity-icon.user { background: #fef9c3; color: #ca8a04; }

.activity-text {
    flex: 1;
    min-width: 0;
}

.activity-text strong { color: #1e293b; }

.activity-time {
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
}

/* Hidden clients banner */
.hidden-clients-banner {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: #92400e;
}

.hidden-clients-banner .banner-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hidden-clients-banner .banner-link {
    color: #2563eb;
    cursor: pointer;
    font-weight: 500;
    text-decoration: underline;
    background: none;
    border: none;
    font-size: 14px;
    font-family: inherit;
    padding: 0;
}

.hidden-clients-banner .banner-link:hover {
    color: #1d4ed8;
}

/* Hidden client row */
.client-hidden td {
    opacity: 0.5;
}

.client-hidden:hover td {
    opacity: 0.75;
}

/* Location expansion */
.location-row {
    background: #f8fafc;
}

.location-row td:first-child {
    padding-left: 48px !important;
}

/* Location thumbnail */
.location-thumb {
    width: 60px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    vertical-align: middle;
}

.location-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}

.location-link:hover {
    text-decoration: underline;
}

.expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: #64748b;
    transition: transform 0.2s;
    font-size: 14px;
}

.expand-btn.expanded {
    transform: rotate(90deg);
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    padding: 24px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.15);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #64748b;
    padding: 0;
    line-height: 1;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
}

/* Password toggle */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 40px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle .eye-icon {
    width: 18px;
    height: 18px;
    color: #94a3b8;
    transition: color 0.2s;
}

.password-toggle:hover .eye-icon {
    color: #2563eb;
}

.eye-icon.hidden { display: none; }

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
}

/* Settings panel */
.settings-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 16px;
}

.settings-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px;
}

.settings-desc {
    font-size: 13px;
    color: #64748b;
    margin: 0 0 16px;
}

.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

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

.settings-label strong {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}

.settings-label small {
    font-size: 12px;
    color: #94a3b8;
}

.settings-control select {
    min-width: 160px;
}

/* Dark mode */
[data-theme="dark"] body { background: #0f172a; color: #e2e8f0; }
[data-theme="dark"] .stat-card { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .stat-value { color: #e2e8f0; }
[data-theme="dark"] .stat-label { color: #94a3b8; }
[data-theme="dark"] .data-table-wrap { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .data-table-wrap th { background: #0f172a; color: #94a3b8; border-color: #334155; }
[data-theme="dark"] .data-table-wrap td { border-color: #1e293b; color: #cbd5e1; }
[data-theme="dark"] .data-table-wrap tr:hover td { background: #0f172a; }
[data-theme="dark"] .tab-bar { border-color: #334155; }
[data-theme="dark"] .tab-btn { color: #94a3b8; }
[data-theme="dark"] .tab-btn:hover { color: #e2e8f0; }
[data-theme="dark"] .tab-btn.active { color: #60a5fa; border-bottom-color: #60a5fa; }
[data-theme="dark"] .toolbar .search-input { background: #1e293b; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .toolbar .filter-select { background: #1e293b; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .btn-secondary { background: #1e293b; border-color: #334155; color: #cbd5e1; }
[data-theme="dark"] .btn-secondary:hover { background: #334155; }
[data-theme="dark"] .activity-stream { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .activity-item { border-color: #334155; }
[data-theme="dark"] .activity-text strong { color: #e2e8f0; }
[data-theme="dark"] .modal-content { background: #1e293b; }
[data-theme="dark"] .modal-header h3 { color: #e2e8f0; }
[data-theme="dark"] .form-group label { color: #94a3b8; }
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea { background: #0f172a; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .location-row { background: #0f172a; }
[data-theme="dark"] .badge-green { background: rgba(22,163,74,0.15); color: #4ade80; }
[data-theme="dark"] .badge-red { background: rgba(220,38,38,0.15); color: #f87171; }
[data-theme="dark"] .badge-blue { background: rgba(37,99,235,0.15); color: #60a5fa; }
[data-theme="dark"] .badge-gray { background: rgba(100,116,139,0.15); color: #94a3b8; }
[data-theme="dark"] .toggle-slider { background: #475569; }
[data-theme="dark"] .hidden-clients-banner { background: rgba(146, 64, 14, 0.15); border-color: #92400e; color: #fbbf24; }
[data-theme="dark"] .hidden-clients-banner .banner-link { color: #60a5fa; }
[data-theme="dark"] .hidden-clients-banner .banner-link:hover { color: #93bbfd; }
[data-theme="dark"] .password-toggle .eye-icon { color: #64748b; }
[data-theme="dark"] .password-toggle:hover .eye-icon { color: #60a5fa; }
[data-theme="dark"] .settings-section { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .settings-title { color: #e2e8f0; }
[data-theme="dark"] .settings-desc { color: #94a3b8; }
[data-theme="dark"] .settings-row { border-color: #334155; }
[data-theme="dark"] .settings-label strong { color: #e2e8f0; }
[data-theme="dark"] .settings-label small { color: #64748b; }
[data-theme="dark"] .location-thumb { border-color: #334155; }
[data-theme="dark"] .location-link { color: #60a5fa; }
[data-theme="dark"] .location-link:hover { color: #93bbfd; }

/* Location row camera count badge */
.loc-camera-count {
    display: inline-block;
    font-size: 11px;
    color: #64748b;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 6px;
}

/* Location name clickable style */
.location-name-link {
    color: #1e293b;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    border-bottom: 1px dashed #cbd5e1;
}

.location-name-link:hover {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* External link icon next to location name */
.location-external-link {
    color: #94a3b8;
    text-decoration: none;
    font-size: 12px;
    margin-left: 6px;
    vertical-align: middle;
}

.location-external-link:hover {
    color: #2563eb;
}

[data-theme="dark"] .loc-camera-count { background: rgba(100,116,139,0.2); color: #94a3b8; }
[data-theme="dark"] .location-name-link { color: #e2e8f0; border-bottom-color: #475569; }
[data-theme="dark"] .location-name-link:hover { color: #60a5fa; border-bottom-color: #60a5fa; }
[data-theme="dark"] .location-external-link { color: #64748b; }
[data-theme="dark"] .location-external-link:hover { color: #60a5fa; }

/* Client settings row (inside expanded view) */
.client-settings-row {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.client-setting-group {
    flex: 1;
    min-width: 200px;
}

.client-setting-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.client-setting-input {
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    width: 100%;
    max-width: 300px;
}

.client-setting-input:focus {
    outline: none;
    border-color: #3b82f6;
}

/* Domain pills */
.domain-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.domain-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: #dbeafe;
    color: #1e40af;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.domain-pill-remove {
    background: none;
    border: none;
    color: #1e40af;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.6;
}

.domain-pill-remove:hover {
    opacity: 1;
    color: #dc2626;
}

.domain-add-input {
    padding: 4px 8px;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    width: 140px;
    background: transparent;
}

.domain-add-input:focus {
    outline: none;
    border-color: #3b82f6;
    border-style: solid;
}

/* Dark mode for client settings */
[data-theme="dark"] .client-setting-label { color: #94a3b8; }
[data-theme="dark"] .client-setting-input { background: #0f172a; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .domain-pill { background: rgba(37,99,235,0.2); color: #60a5fa; }
[data-theme="dark"] .domain-pill-remove { color: #60a5fa; }
[data-theme="dark"] .domain-pill-remove:hover { color: #f87171; }
[data-theme="dark"] .domain-add-input { border-color: #475569; color: #e2e8f0; }

/* Responsive */
@media (max-width: 768px) {
    .admin-content { padding: 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-input { width: 100%; }
    .data-table-wrap { overflow-x: auto; }
}
