/* ===== Admin Dashboard Styles ===== */

/* ── Base ── */
.admin-body {
    background: var(--bg-primary);
    min-height: 100vh;
}

.admin-badge {
    background: linear-gradient(135deg, #ff4654, #ff2d55);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 800;
    letter-spacing: 2px;
    padding: 3px 8px;
    border-radius: 4px;
    margin-left: 10px;
    vertical-align: middle;
    text-transform: uppercase;
    box-shadow: 0 0 12px rgba(255,70,84,0.4);
}

/* ── Unauthorized ── */
.admin-unauthorized {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.unauthorized-card {
    text-align: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 60px 48px;
    max-width: 460px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.unauthorized-icon {
    font-size: 4rem;
    color: var(--valorant-red);
    margin-bottom: 24px;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { text-shadow: 0 0 20px rgba(255,70,84,0.3); }
    50% { text-shadow: 0 0 40px rgba(255,70,84,0.6); }
}

.unauthorized-card h2 {
    color: var(--text-primary);
    font-size: 1.8rem;
    margin-bottom: 12px;
}

.unauthorized-card p {
    color: var(--text-secondary);
    margin-bottom: 28px;
    line-height: 1.6;
}

.btn-admin-login {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #5865F2;
    color: #fff;
    padding: 14px 32px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(88,101,242,0.3);
}

.btn-admin-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(88,101,242,0.5);
}

/* ── Loading ── */
.admin-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 20px;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--valorant-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ── Dashboard Layout ── */
.admin-dashboard {
    display: flex;
    min-height: calc(100vh - 70px);
    padding-top: 70px;
}

/* ── Sidebar ── */
.admin-sidebar {
    width: 220px;
    min-width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 24px 12px;
    position: sticky;
    top: 70px;
    height: calc(100vh - 70px);
    overflow-y: auto;
    z-index: 10;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: 'Inter', sans-serif;
}

.sidebar-btn i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-btn.active {
    background: linear-gradient(135deg, rgba(255,70,84,0.15), rgba(139,95,191,0.1));
    color: var(--valorant-red);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--valorant-red);
}

/* ── Content Area ── */
.admin-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ── Tab System ── */
.admin-tab {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

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

.tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}

.tab-header h1 {
    color: var(--text-primary);
    font-size: 1.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tab-header h1 i {
    color: var(--valorant-red);
}

.tab-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-refresh {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-refresh:hover {
    background: var(--bg-accent);
    color: var(--text-primary);
}

.last-updated {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ── KPI Cards ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 16px 16px 0 0;
}

.kpi-users::before { background: linear-gradient(90deg, #00d4ff, #00ff88); }
.kpi-views::before { background: linear-gradient(90deg, #ff4654, #ff8a3d); }
.kpi-sessions::before { background: linear-gradient(90deg, #8b5fbf, #00d4ff); }
.kpi-riot::before { background: linear-gradient(90deg, #ff4654, #8b5fbf); }
.kpi-today::before { background: linear-gradient(90deg, #f4d03f, #ff8a3d); }
.kpi-features::before { background: linear-gradient(90deg, #00ff88, #00d4ff); }

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    border-color: rgba(255,255,255,0.1);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.kpi-users .kpi-icon { background: rgba(0,212,255,0.15); color: #00d4ff; }
.kpi-views .kpi-icon { background: rgba(255,70,84,0.15); color: #ff4654; }
.kpi-sessions .kpi-icon { background: rgba(139,95,191,0.15); color: #8b5fbf; }
.kpi-riot .kpi-icon { background: rgba(255,70,84,0.15); color: #ff4654; }
.kpi-today .kpi-icon { background: rgba(244,208,63,0.15); color: #f4d03f; }
.kpi-features .kpi-icon { background: rgba(0,255,136,0.15); color: #00ff88; }

.kpi-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Chart Cards ── */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.chart-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    transition: border-color 0.3s ease;
}

.chart-card:hover {
    border-color: rgba(255,255,255,0.08);
}

.chart-card.chart-wide {
    grid-column: 1 / -1;
}

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

.chart-card-header h3 {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-card-header h3 i {
    color: var(--valorant-red);
    font-size: 0.9rem;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    max-height: 320px;
}

/* ── Tables ── */
.admin-table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.admin-table thead {
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 2;
}

.admin-table th {
    color: var(--text-secondary);
    font-weight: 600;
    text-align: left;
    padding: 14px 16px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.admin-table th.sortable:hover {
    color: var(--valorant-red);
}

.admin-table td {
    color: var(--text-primary);
    padding: 12px 16px;
    border-bottom: 1px solid rgba(58,84,112,0.3);
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-table tbody tr {
    transition: background 0.15s ease;
}

.admin-table tbody tr:hover {
    background: rgba(0, 212, 255, 0.04);
}

.admin-table .avatar-cell {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

/* ── Search & Select ── */
.admin-search {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    min-width: 200px;
    outline: none;
    transition: border-color 0.2s ease;
}

.admin-search:focus {
    border-color: var(--valorant-red);
    box-shadow: 0 0 0 3px rgba(255,70,84,0.1);
}

.admin-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    outline: none;
}

.admin-select:focus {
    border-color: var(--valorant-red);
}

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.pagination button:hover {
    background: var(--bg-accent);
    color: var(--text-primary);
}

.pagination button.active {
    background: var(--valorant-red);
    color: #fff;
    border-color: var(--valorant-red);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Feature Cards ── */
.feature-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 28px;
    position: relative;
    overflow: hidden;
}

.feature-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,70,84,0.05) 0%, transparent 70%);
    pointer-events: none;
}

.feature-card-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    text-transform: capitalize;
}

.feature-card-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.feature-card-stats {
    display: flex;
    gap: 24px;
    margin-top: 16px;
}

.feature-stat {
    text-align: center;
}

.feature-stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--valorant-blue);
}

.feature-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Security ── */
.security-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.security-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
}

.security-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.security-card-header h3 {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-danger {
    background: rgba(255,70,84,0.2);
    color: #ff4654;
}

.badge-warning {
    background: rgba(244,208,63,0.2);
    color: #f4d03f;
}

.badge-success {
    background: rgba(0,255,136,0.2);
    color: #00ff88;
}

.blacklist-items, .suspicious-items {
    max-height: 300px;
    overflow-y: auto;
}

.bl-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.bl-item-ip {
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.bl-item-remove {
    background: rgba(255,70,84,0.15);
    border: none;
    color: var(--valorant-red);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.2s ease;
}

.bl-item-remove:hover {
    background: rgba(255,70,84,0.3);
}

.suspicious-item {
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 8px;
}

.suspicious-item-ip {
    color: var(--valorant-yellow);
    font-family: 'Courier New', monospace;
    font-weight: 600;
    font-size: 0.9rem;
}

.suspicious-item-detail {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 4px;
}

/* ── Realtime ── */
.realtime-status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--valorant-green);
    font-weight: 600;
    font-size: 0.9rem;
}

.pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--valorant-green);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0,255,136,0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 8px rgba(0,255,136,0); }
}

.realtime-kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.realtime-kpi {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 28px;
    text-align: center;
}

.realtime-kpi-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--valorant-red), var(--valorant-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.realtime-kpi-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

.realtime-feed {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

.realtime-feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.realtime-feed-header h3 {
    color: var(--text-primary);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.realtime-feed-body {
    max-height: 500px;
    overflow-y: auto;
    padding: 8px;
}

.rt-entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 4px;
    font-size: 0.85rem;
    animation: slideIn 0.3s ease;
    transition: background 0.15s ease;
}

.rt-entry:hover {
    background: var(--bg-tertiary);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}

.rt-time {
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.rt-page {
    background: rgba(0,212,255,0.12);
    color: var(--valorant-blue);
    padding: 2px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.rt-ip {
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

.rt-user {
    color: var(--valorant-green);
    font-weight: 600;
    font-size: 0.8rem;
}

/* ── Toggle Switch ── */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    width: 36px;
    height: 20px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    position: relative;
    transition: background 0.3s ease;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--valorant-green);
}

.toggle-switch input:checked + .toggle-slider::after {
    left: 19px;
    background: #fff;
}

/* ── Access Summary Grid ── */
.access-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.access-summary-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.access-summary-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.access-summary-count {
    color: var(--valorant-blue);
    font-weight: 800;
    font-size: 1.2rem;
}

/* ── User Avatar ── */
.admin-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--valorant-red);
    object-fit: cover;
}

.admin-name-text {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
}

.btn-admin-logout {
    color: var(--text-muted);
    padding: 6px;
    border-radius: 6px;
    transition: color 0.2s ease;
    text-decoration: none;
}

.btn-admin-logout:hover {
    color: var(--valorant-red);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-actions #admin-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Empty States ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.95rem;
}

/* ── Scrollbar ── */
.admin-content::-webkit-scrollbar,
.admin-table-wrapper::-webkit-scrollbar,
.realtime-feed-body::-webkit-scrollbar,
.blacklist-items::-webkit-scrollbar,
.suspicious-items::-webkit-scrollbar {
    width: 6px;
}

.admin-content::-webkit-scrollbar-track,
.admin-table-wrapper::-webkit-scrollbar-track,
.realtime-feed-body::-webkit-scrollbar-track {
    background: transparent;
}

.admin-content::-webkit-scrollbar-thumb,
.admin-table-wrapper::-webkit-scrollbar-thumb,
.realtime-feed-body::-webkit-scrollbar-thumb {
    background: var(--bg-accent);
    border-radius: 3px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .admin-sidebar {
        width: 60px;
        min-width: 60px;
        padding: 24px 8px;
    }

    .sidebar-btn span {
        display: none;
    }

    .sidebar-btn {
        justify-content: center;
        padding: 12px;
    }

    .sidebar-btn i {
        margin: 0;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .security-grid {
        grid-template-columns: 1fr;
    }

    .realtime-kpi-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .admin-dashboard {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        min-width: 100%;
        height: auto;
        position: relative;
        top: 0;
        flex-direction: row;
        overflow-x: auto;
        padding: 8px 12px;
    }

    .sidebar-nav {
        flex-direction: row;
    }

    .sidebar-btn {
        flex-shrink: 0;
    }

    .admin-content {
        padding: 16px;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .tab-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* 検索ログ（リアルタイム）新着行ハイライト */
.searchlog-new {
    animation: searchLogHighlight 2s ease;
}

@keyframes searchLogHighlight {
    0% { background: rgba(0, 212, 255, 0.25); }
    100% { background: transparent; }
}

#searchlogs-table tbody tr {
    transition: background 0.2s ease;
}

#searchlogs-table tbody tr:hover {
    background: var(--bg-tertiary);
}
