/* Client Grid Admin - Styles */

/* Layout */
.content-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Summary cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.card-value {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.card-label {
    font-size: 13px;
    color: #64748b;
    margin-top: 4px;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.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: #ef4444;
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: #22c55e;
    color: #fff;
}

.btn-success:hover {
    background: #16a34a;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Table */
.table-wrapper {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: #f8fafc;
}

.data-table .actions {
    white-space: nowrap;
    display: flex;
    gap: 6px;
}

/* Status badge */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-enabled {
    background: #dcfce7;
    color: #166534;
}

.badge-disabled {
    background: #fee2e2;
    color: #991b1b;
}

/* Camera counts */
.camera-count {
    display: flex;
    gap: 8px;
    align-items: center;
}

.count-current {
    color: #16a34a;
    font-weight: 600;
}

.count-previous {
    color: #64748b;
}

/* Loading spinner */
.loading {
    text-align: center;
    padding: 40px;
    color: #64748b;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Modal overlay */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: #475569;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
}

/* Form */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: #1e293b;
    background: #fff;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group .hint {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Confirm overlay */
.confirm-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    align-items: center;
    justify-content: center;
}

.confirm-overlay.active {
    display: flex;
}

.confirm-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 32px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.confirm-box h3 {
    margin: 0 0 12px;
    font-size: 18px;
    color: #1e293b;
}

.confirm-box p {
    margin: 0 0 24px;
    color: #64748b;
    font-size: 14px;
}

.confirm-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* Detected clients section */
.detected-section {
    margin-top: 32px;
}

.detected-section h3 {
    margin: 0 0 12px;
    font-size: 16px;
    color: #1e293b;
}

.detected-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.detected-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 8px;
}

.detected-card .name {
    font-weight: 600;
    color: #92400e;
}

.detected-card .dir {
    font-size: 12px;
    color: #b45309;
}

/* Responsive */
@media (max-width: 768px) {
    .content-wrapper {
        padding: 12px;
    }

    .toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .data-table th:nth-child(4),
    .data-table td:nth-child(4),
    .data-table th:nth-child(5),
    .data-table td:nth-child(5) {
        display: none;
    }
}

/* ============================================================
   Dark mode
   ============================================================ */
[data-theme="dark"] .content-wrapper {
    color: #e2e8f0;
}

[data-theme="dark"] .summary-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .card-value {
    color: #f1f5f9;
}

[data-theme="dark"] .card-label {
    color: #94a3b8;
}

[data-theme="dark"] .toolbar h2 {
    color: #f1f5f9;
}

[data-theme="dark"] .table-wrapper {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .data-table th {
    background: #0f172a;
    color: #94a3b8;
}

[data-theme="dark"] .data-table td {
    color: #e2e8f0;
    border-bottom-color: #334155;
}

[data-theme="dark"] .data-table tr:hover td {
    background: #0f172a;
}

[data-theme="dark"] .btn-secondary {
    background: #334155;
    color: #e2e8f0;
    border-color: #475569;
}

[data-theme="dark"] .btn-secondary:hover {
    background: #475569;
}

[data-theme="dark"] .modal {
    background: #1e293b;
}

[data-theme="dark"] .modal-header {
    border-bottom-color: #334155;
}

[data-theme="dark"] .modal-header h3 {
    color: #f1f5f9;
}

[data-theme="dark"] .modal-footer {
    border-top-color: #334155;
}

[data-theme="dark"] .form-group label {
    color: #cbd5e1;
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}

[data-theme="dark"] .confirm-box {
    background: #1e293b;
}

[data-theme="dark"] .confirm-box h3 {
    color: #f1f5f9;
}

[data-theme="dark"] .confirm-box p {
    color: #94a3b8;
}

[data-theme="dark"] .detected-card {
    background: #1e293b;
    border-color: #b45309;
}

[data-theme="dark"] .detected-card .name {
    color: #fbbf24;
}

[data-theme="dark"] .detected-card .dir {
    color: #f59e0b;
}

[data-theme="dark"] .badge-enabled {
    background: #064e3b;
    color: #6ee7b7;
}

[data-theme="dark"] .badge-disabled {
    background: #7f1d1d;
    color: #fca5a5;
}

[data-theme="dark"] body {
    background: #0f172a;
}

[data-theme="dark"] .detected-section h3 {
    color: #f1f5f9;
}

[data-theme="dark"] .empty-state {
    color: #64748b;
}
