/* --- ADMIN PANEL SPECIFIC STYLES --- */

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --secondary: #64748b;
    --bg-main: #f8fafc;
    --sidebar-bg: #1e293b;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius-lg: 16px;
    --radius-md: 12px;
    --shadow-premium: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    color: white;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    z-index: 10;
}

.sidebar h1 {
    font-size: 1.5rem;
    margin-bottom: 2.5rem;
    color: #38bdf8;
    text-align: center;
    font-weight: 800;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tab-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.85rem 1.25rem;
    text-align: left;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    border-radius: var(--radius-md);
    margin-bottom: 0.65rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    transform: translateX(4px);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.main-content {
    flex: 1;
    padding: 1.25rem 1.5rem;
    background: var(--bg-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden; /* Blokujemy przewijanie całego okna */
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    padding-right: 5px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.admin-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

/* Premium Components */
.premium-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-premium);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.card-header {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.25rem;
}

.card-icon {
    font-size: 2rem;
    background: #eff6ff;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.premium-modal {
    border-radius: var(--radius-lg);
    overflow: hidden;
    padding: 0 !important;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-header {
    padding: 1.5rem 2rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.close-modal {
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-muted);
    transition: color 0.2s;
}

.close-modal:hover { color: #ef4444; }

.premium-form {
    padding: 0.5rem 0 0.5rem 0;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.flex-3 { flex: 3; }

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.35rem;
}

.form-group {
    margin-bottom: 0.85rem;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
    background: #fff;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.form-help {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

/* Permissions Grid */
.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.perm-card {
    position: relative;
    cursor: pointer;
}

.perm-card input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.perm-content {
    background: #f1f5f9;
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.perm-card input:checked + .perm-content {
    background: #eff6ff;
    border-color: var(--primary);
}

.perm-icon { font-size: 1.5rem; }
.perm-name { font-size: 0.8rem; font-weight: 600; text-align: center; color: var(--text-main); }

.modal-footer {
    padding: 1.5rem 2rem;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn-glow:hover {
    box-shadow: 0 0 15px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    color: var(--secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #f1f5f9;
}

/* User Cards */
.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.user-card {
    background: white;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-premium);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.user-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.user-avatar {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #3b82f6, #818cf8);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.user-info {
    text-align: center;
    margin-bottom: 1rem;
}

.user-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.user-perms {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.perm-badge {
    font-size: 1.25rem;
    background: #f1f5f9;
    padding: 0.4rem;
    border-radius: 8px;
    cursor: default;
}

.user-actions {
    display: flex;
    gap: 0.75rem;
    width: 100%;
}

.user-actions .btn {
    flex: 1;
    justify-content: center;
}
/* Sticky Table Headers */
.table-responsive {
    flex: 1;
    overflow: auto; /* To jest teraz nasz główny kontener przewijania */
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-premium);
    margin-top: 1rem;
    position: relative;
}

#onusTable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 1100px;
}

#onusTable tbody tr:hover {
    background-color: #f1f5f9 !important;
}

.olt-link {
    color: #0369a1;
    background: #e0f2fe;
    padding: 1px 6px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 700;
    transition: all 0.2s;
    display: inline-block;
}

.olt-link:hover {
    background: #0ea5e9;
    color: white;
}

#onusTable thead th {
    position: sticky;
    top: 0;
    z-index: 110;
    background: #f8fafc !important;
    border-bottom: 2px solid var(--border);
    padding: 12px;
    box-shadow: 0 2px 2px rgba(0,0,0,0.05);
}

/* Zbiorczy nagłówek (WIDOK GLOBALNY) */
.master-header td {
    position: sticky;
    top: 45px; /* Wysokość thead th */
    z-index: 105;
    background: #1e293b !important;
    color: #f8fafc !important;
}

/* Nagłówki poszczególnych OLT */
.group-header td {
    position: sticky;
    top: 45px; 
    z-index: 100;
    background: #f1f5f9 !important;
}

/* Jeśli mamy oba nagłówki sticky na tej samej pozycji, musimy je obsłużyć. 
   W tym układzie group-header będzie wskakiwać pod/nad master-header w zależności od scrolla. */

/* Ajusting column widths in onusTable */
#onusTable .col-status {
    width: 100px;
    max-width: 100px;
}

#onusTable .col-sn {
    width: 140px;
    max-width: 140px;
}

#onusTable .col-model {
    width: 220px;
    max-width: 220px;
    white-space: normal !important;
}

#onusTable .col-olt-id {
    width: 70px;
    max-width: 70px;
}

/* Pulse Indicator for Auto Refresh */
.pulse-indicator {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.5s infinite;
    vertical-align: middle;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}


