/* ═══════════════════════════════════════════════════════════
   Admin Subroles Panel — CSS Styles
   Etap 4: Admin Panel & Analytics
   ═══════════════════════════════════════════════════════════ */

/* ── Section Container ── */
.admin-subroles-section {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-subroles-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.admin-subroles-section .section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #e0e0e0;
}

.admin-subroles-section .header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.admin-subroles-section .header-actions button {
    padding: 0.5rem 1rem;
    border: 1px solid rgba(127, 255, 0, 0.3);
    background: rgba(127, 255, 0, 0.08);
    color: #7FFF00;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.admin-subroles-section .header-actions button:hover {
    background: rgba(127, 255, 0, 0.15);
    border-color: #7FFF00;
}

.admin-subroles-section .header-actions button.btn-primary {
    background: linear-gradient(135deg, #7FFF00, #66CC00);
    color: #0A1A1A;
    border-color: transparent;
}

.admin-subroles-section .header-actions button.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* ── Tab Navigation ── */
.sr-admin-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 2rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.sr-admin-tabs::-webkit-scrollbar { display: none; }

.sr-admin-tab {
    padding: 0.75rem 1.25rem;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    transition: all 0.2s;
}

.sr-admin-tab:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.03);
}

.sr-admin-tab.active {
    color: #7FFF00;
}

.sr-admin-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: #7FFF00;
    border-radius: 2px 2px 0 0;
}

.sr-admin-tab .tab-badge {
    background: rgba(127, 255, 0, 0.15);
    color: #7FFF00;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-size: 0.7rem;
    margin-left: 0.4rem;
}

/* ── Tab Panels ── */
.sr-admin-panel {
    display: none;
}

.sr-admin-panel.active {
    display: block;
    animation: srFadeIn 0.3s ease;
}

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

/* ── Stats Cards Grid ── */
.sr-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.sr-stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
    transition: all 0.2s;
}

.sr-stat-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(127, 255, 0, 0.2);
}

.sr-stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.sr-stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: #e0e0e0;
    font-family: 'Inter', system-ui, sans-serif;
}

.sr-stat-card .stat-value.accent { color: #7FFF00; }
.sr-stat-card .stat-value.warning { color: #FFB74D; }
.sr-stat-card .stat-value.danger { color: #EF5350; }

.sr-stat-card .stat-label {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
}

.sr-stat-card .stat-sub {
    font-size: 0.7rem;
    color: rgba(127, 255, 0, 0.6);
    margin-top: 0.25rem;
}

/* ── Table Styles ── */
.sr-table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.02);
}

.sr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.sr-table thead th {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.7rem;
    padding: 0.75rem 1rem;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sr-table tbody td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: #ccc;
    vertical-align: middle;
}

.sr-table tbody tr:hover {
    background: rgba(127, 255, 0, 0.03);
}

.sr-table .cell-icon {
    font-size: 1.2rem;
    text-align: center;
    width: 40px;
}

.sr-table .cell-id {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.sr-table .cell-title {
    font-weight: 600;
    color: #e0e0e0;
}

.sr-table .cell-number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.sr-table .cell-actions {
    display: flex;
    gap: 0.3rem;
    justify-content: flex-end;
}

/* ── Small Action Buttons ── */
.sr-btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.72rem;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: #ccc;
    transition: all 0.15s;
    white-space: nowrap;
}

.sr-btn-sm:hover { background: rgba(255, 255, 255, 0.08); }
.sr-btn-sm.edit { color: #42A5F5; border-color: rgba(66, 165, 245, 0.3); }
.sr-btn-sm.edit:hover { background: rgba(66, 165, 245, 0.1); }
.sr-btn-sm.danger { color: #EF5350; border-color: rgba(239, 83, 80, 0.3); }
.sr-btn-sm.danger:hover { background: rgba(239, 83, 80, 0.1); }
.sr-btn-sm.success { color: #66BB6A; border-color: rgba(102, 187, 106, 0.3); }
.sr-btn-sm.success:hover { background: rgba(102, 187, 106, 0.1); }
.sr-btn-sm.grant { color: #7FFF00; border-color: rgba(127, 255, 0, 0.3); }
.sr-btn-sm.grant:hover { background: rgba(127, 255, 0, 0.1); }

/* ── Status Badge ── */
.sr-status {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: capitalize;
}

.sr-status.active {
    background: rgba(102, 187, 106, 0.15);
    color: #66BB6A;
    border: 1px solid rgba(102, 187, 106, 0.3);
}

.sr-status.expired {
    background: rgba(255, 183, 77, 0.15);
    color: #FFB74D;
    border: 1px solid rgba(255, 183, 77, 0.3);
}

.sr-status.revoked {
    background: rgba(239, 83, 80, 0.15);
    color: #EF5350;
    border: 1px solid rgba(239, 83, 80, 0.3);
}

/* ── Filters Bar ── */
.sr-filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.sr-filters input,
.sr-filters select {
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border-radius: 8px;
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.2s;
}

.sr-filters input:focus,
.sr-filters select:focus {
    border-color: rgba(127, 255, 0, 0.5);
}

.sr-filters input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.sr-filters select option {
    background: #1a2a1a;
    color: #e0e0e0;
}

/* ── Pagination ── */
.sr-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.sr-pagination button {
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #ccc;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s;
}

.sr-pagination button:hover:not(:disabled) {
    background: rgba(127, 255, 0, 0.1);
    border-color: rgba(127, 255, 0, 0.3);
}

.sr-pagination button:disabled {
    opacity: 0.3;
    cursor: default;
}

.sr-pagination .page-info {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.5);
}

/* ── Charts Area ── */
.sr-chart-container {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.sr-chart-container h4 {
    font-size: 0.9rem;
    color: #e0e0e0;
    margin-bottom: 1rem;
    font-weight: 600;
}

.sr-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sr-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sr-bar-label {
    min-width: 120px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.6);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sr-bar-track {
    flex: 1;
    height: 22px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.sr-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, rgba(127, 255, 0, 0.6), rgba(127, 255, 0, 0.3));
    border-radius: 6px;
    transition: width 0.6s ease;
    display: flex;
    align-items: center;
    padding-left: 0.5rem;
}

.sr-bar-fill .bar-value {
    font-size: 0.7rem;
    color: #0A1A1A;
    font-weight: 700;
    white-space: nowrap;
}

.sr-bar-count {
    min-width: 50px;
    text-align: right;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.5);
    font-variant-numeric: tabular-nums;
}

/* ── Trends Mini-Chart (CSS sparkline) ── */
.sr-sparkline {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 60px;
    padding: 0.5rem 0;
}

.sr-sparkline-bar {
    flex: 1;
    background: rgba(127, 255, 0, 0.3);
    border-radius: 2px 2px 0 0;
    min-width: 4px;
    transition: all 0.3s;
    position: relative;
}

.sr-sparkline-bar:hover {
    background: rgba(127, 255, 0, 0.7);
}

.sr-sparkline-bar .tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1a2a1a;
    border: 1px solid rgba(127, 255, 0, 0.3);
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    font-size: 0.65rem;
    color: #e0e0e0;
    white-space: nowrap;
    z-index: 10;
}

.sr-sparkline-bar:hover .tooltip {
    display: block;
}

/* ── Modal ── */
.sr-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: srFadeIn 0.2s ease;
}

.sr-modal {
    background: #0f1f0f;
    border: 1px solid rgba(127, 255, 0, 0.2);
    border-radius: 16px;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.sr-modal h3 {
    font-size: 1.1rem;
    color: #e0e0e0;
    margin-bottom: 1.5rem;
}

.sr-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.sr-modal-close:hover { color: #EF5350; }

/* ── Form Fields ── */
.sr-form-group {
    margin-bottom: 1rem;
}

.sr-form-group label {
    display: block;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.sr-form-group input,
.sr-form-group textarea,
.sr-form-group select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.sr-form-group input:focus,
.sr-form-group textarea:focus,
.sr-form-group select:focus {
    border-color: rgba(127, 255, 0, 0.5);
}

.sr-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.sr-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.sr-form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.sr-form-actions button {
    padding: 0.6rem 1.5rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.sr-form-actions .btn-cancel {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #ccc;
}

.sr-form-actions .btn-cancel:hover {
    background: rgba(255, 255, 255, 0.05);
}

.sr-form-actions .btn-save {
    background: linear-gradient(135deg, #7FFF00, #66CC00);
    border: none;
    color: #0A1A1A;
}

.sr-form-actions .btn-save:hover {
    filter: brightness(1.1);
}

/* ── Expiring Alert Banner ── */
.sr-alert-banner {
    background: rgba(255, 183, 77, 0.08);
    border: 1px solid rgba(255, 183, 77, 0.3);
    border-radius: 10px;
    padding: 0.8rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 0.82rem;
    color: #FFB74D;
}

.sr-alert-banner .alert-icon { font-size: 1.2rem; }
.sr-alert-banner .alert-count { font-weight: 700; font-size: 1rem; }

/* ── History Feed ── */
.sr-history-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

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

.sr-history-icon {
    font-size: 1.1rem;
    min-width: 28px;
    text-align: center;
}

.sr-history-content {
    flex: 1;
}

.sr-history-content .action-text {
    font-size: 0.82rem;
    color: #e0e0e0;
}

.sr-history-content .action-text strong {
    color: #7FFF00;
}

.sr-history-content .action-meta {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 0.15rem;
}

/* ── Empty State ── */
.sr-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: rgba(255, 255, 255, 0.3);
}

.sr-empty .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.sr-empty .empty-text {
    font-size: 0.9rem;
}

/* ── Loading Spinner ── */
.sr-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.85rem;
    gap: 0.75rem;
}

.sr-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid rgba(127, 255, 0, 0.2);
    border-top-color: #7FFF00;
    border-radius: 50%;
    animation: srSpin 0.6s linear infinite;
}

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

/* ── Responsive ── */
@media (max-width: 900px) {
    .sr-stats-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
    .sr-form-row {
        grid-template-columns: 1fr;
    }
    .sr-bar-label {
        min-width: 80px;
    }
}

@media (max-width: 600px) {
    .admin-subroles-section {
        padding: 1rem;
    }
    .sr-admin-tabs {
        gap: 0;
    }
    .sr-admin-tab {
        padding: 0.6rem 0.75rem;
        font-size: 0.75rem;
    }
    .sr-filters {
        flex-direction: column;
    }
    .sr-filters input,
    .sr-filters select {
        width: 100%;
    }
}
