/* TCP Pull Access Control - CSS */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-w: 220px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--gray-900);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--gray-700);
}

.sidebar-header h2 {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.nav-menu {
    list-style: none;
    padding: 8px 0;
}

.nav-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--gray-300);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
}

.nav-menu a:hover { background: var(--gray-800); color: #fff; }
.nav-menu a.active { background: var(--primary); color: #fff; }

/* Content */
.content {
    margin-left: var(--sidebar-w);
    padding: 24px 32px;
    flex: 1;
    min-width: 0;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
}

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

.stat-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 20px;
}

.stat-card .label {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
}

.stat-card .value.online { color: var(--success); }
.stat-card .value.warning { color: var(--warning); }
.stat-card .value.danger { color: var(--danger); }

/* Panel */
.panel {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 24px;
}

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

.panel-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.panel-body { padding: 20px; }
.panel-body.no-pad { padding: 0; }

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    text-align: left;
    padding: 10px 16px;
    border-bottom: 2px solid var(--gray-200);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--gray-500);
    letter-spacing: 0.5px;
}

tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--gray-100);
}

tbody tr:hover { background: var(--gray-50); }

/* Status badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-online { background: #dcfce7; color: var(--success); }
.badge-offline { background: var(--gray-100); color: var(--gray-500); }
.badge-synced { background: #dcfce7; color: var(--success); }
.badge-pending { background: #fef3c7; color: var(--warning); }
.badge-sent { background: #dbeafe; color: var(--primary); }
.badge-confirmed { background: #dcfce7; color: var(--success); }
.badge-failed { background: #fee2e2; color: var(--danger); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-100); }

.btn-group { display: flex; gap: 8px; }

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

select.form-control { appearance: auto; }

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

.modal-overlay.hidden { display: none; }

.modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 480px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-header h3 { font-size: 16px; }

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray-500);
    padding: 4px;
}

.modal-body { padding: 20px; }

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Notification */
.notification {
    position: fixed;
    top: 16px;
    right: 16px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 2000;
    transition: opacity 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.notification.hidden { display: none; }
.notification.success { background: #dcfce7; color: var(--success); border: 1px solid #bbf7d0; }
.notification.error { background: #fee2e2; color: var(--danger); border: 1px solid #fecaca; }
.notification.info { background: #dbeafe; color: var(--primary); border: 1px solid #bfdbfe; }

/* Filters bar */
.filters {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filters .form-group { margin-bottom: 0; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 16px;
}

/* Door control buttons */
.door-btn-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.door-panel {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.door-panel h3 {
    margin-bottom: 16px;
    font-size: 16px;
}

.door-panel .btn-group {
    justify-content: center;
    flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
    }
    .content {
        margin-left: 0;
        padding: 16px;
    }
    body { flex-direction: column; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Sync status icons inline */
.sync-icon { font-size: 14px; margin-left: 4px; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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