/* Admin Dashboard Specific Styles */

/* Override global body styles to allow scrolling */
body {
    overflow-y: auto !important;
    height: auto !important;
    display: block !important;
    padding-bottom: 40px;
    /* Check this doesn't conflict */
}

/* Admin Container */
.admin-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.admin-header {
    margin-bottom: 24px;
}

/* Force lang-switch to flow with header items */
/* Force lang-switch to flow with header items */
.admin-header .lang-switch,
.header-right .lang-switch {
    width: auto !important;
    margin-bottom: 0 !important;
    flex: 0 0 auto;
    position: relative;
    justify-content: flex-start;
}

.header-right .lang-switch select {
    width: auto;
    padding-right: 32px;
    /* Ensure space for icon */
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.back-link svg {
    width: 18px;
    height: 18px;
}

.back-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
    transform: translateX(-2px);
}

/* Header Layout */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 10px 0;
}

.header-left {
    flex: 1;
}

.header-title-group h1 {
    font-size: 28px;
    font-weight: 700;
    color: #a78bfa;
    /* Light Purple for text */
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    text-shadow: 0 2px 10px rgba(167, 139, 250, 0.3);
}

.title-icon {
    width: 28px;
    height: 28px;
    color: #fb923c;
    /* Orange for lightning */
    fill: currentColor;
    filter: drop-shadow(0 0 8px rgba(251, 146, 60, 0.5));
}

/* Header Overview Stats */
.header-overview {
    display: flex;
    gap: 16px;
    margin-left: auto;
    /* Push to right */
    margin-right: 20px;
}

.overview-card {
    background: rgba(15, 23, 42, 0.6);
    /* Darker background */
    border: 1px solid var(--glass-border);
    /* Subtle border */
    border-radius: 16px;
    padding: 12px 20px;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.overview-value {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.overview-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
    text-align: center;
}

/* Circular Chart for Health */
.circular-chart-container {
    width: 40px;
    height: 40px;
    position: relative;
    margin-bottom: 4px;
}

.circular-chart {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    max-height: 100%;
}

.circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 3.8;
}

.circle {
    fill: none;
    stroke-width: 2.8;
    stroke-linecap: round;
    animation: progress 1s ease-out forwards;
}

.circular-chart.green .circle {
    stroke: #10b981;
}

.circular-chart.orange .circle {
    stroke: #f59e0b;
}

.circular-chart.red .circle {
    stroke: #ef4444;
}

.percentage {
    fill: #fff;
    font-family: 'Inter', sans-serif;
    font-weight: bold;
    font-size: 10px;
    text-anchor: middle;
}

/* Header Controls (Lang switch, Back button) */
.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-link-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.back-link-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.back-link-icon svg {
    width: 20px;
    height: 20px;
}

/* Refresh Countdown Positioning */
.admin-header .refresh-countdown {
    position: static;
    /* Remove absolute positioning */
    margin-bottom: 0;
    background: var(--glass-bg);
}

.admin-header .refresh-countdown.warning {
    color: var(--warning-color);
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(245, 158, 11, 0.1);
}

/* Sort Controls */
.sort-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Custom Select Dropdown */
.custom-select {
    position: relative;
    min-width: 140px;
    user-select: none;
}

.select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 8px;
}

.select-trigger:hover {
    border-color: rgba(167, 139, 250, 0.4);
    background-color: rgba(255, 255, 255, 0.05);
}

.custom-select.open .select-trigger {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.2);
}

.select-value {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.select-arrow {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    color: rgba(255, 255, 255, 0.5);
}

.custom-select.open .select-arrow {
    transform: rotate(180deg);
}

.select-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.custom-select.open .select-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.select-option {
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.select-option:hover {
    background: rgba(167, 139, 250, 0.15);
    border-left-color: var(--accent-color);
}

.select-option.selected {
    background: rgba(167, 139, 250, 0.2);
    border-left-color: var(--accent-color);
    color: #a78bfa;
}

/* Sort Order Button */
#sortOrderBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
    position: relative;
}

#sortOrderBtn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(167, 139, 250, 0.4);
}

#sortOrderBtn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease, color 0.3s ease;
}

/* Descending state - arrow pointing down (default rotation) */
#sortOrderBtn.desc {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

#sortOrderBtn.desc svg {
    transform: rotate(0deg);
    color: #ef4444;
}

#sortOrderBtn.desc:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.5);
}

#sortOrderBtn.desc:hover svg {
    color: #ff6b6b;
}

/* Ascending state - arrow pointing up (rotated 180 degrees) */
#sortOrderBtn.asc {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
}

#sortOrderBtn.asc svg {
    transform: rotate(180deg);
    color: #10b981;
}

#sortOrderBtn.asc:hover {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.5);
}

#sortOrderBtn.asc:hover svg {
    color: #34d399;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.loader-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 0.8s linear infinite;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 80px 20px;
    text-align: center;
}

.empty-icon {
    width: 64px;
    height: 64px;
    color: var(--text-secondary);
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    margin-top: 16px;
    background: var(--primary-gradient);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cta-button svg {
    width: 16px;
    height: 16px;
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px rgba(118, 75, 162, 0.5);
}

/* Error State */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 80px 20px;
    text-align: center;
}

.error-icon {
    width: 64px;
    height: 64px;
    color: var(--error-color);
}

.error-state h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.error-state p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    animation: fadeIn 0.5s ease forwards;
}

/* Single Key Card */
.key-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;

    /* Ensure flex column for stats card alignment */
    display: flex;
    flex-direction: column;
}

.key-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.6);
    border-color: rgba(167, 139, 250, 0.3);
}

/* Stats Header Overrides for Admin Grid */
.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.header-info-group {
    flex: 1;
    min-width: 0;
    /* Enable text truncation */
    margin-right: 12px;
}

.key-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: monospace;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s ease;
}

.key-title:hover {
    color: var(--accent-color);
}

.key-title:hover .copy-icon {
    opacity: 1;
}

.copy-icon {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.user-email-text {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Stats Main Area Overrides */
.stats-main {
    margin-bottom: 24px;
}

/* Circular Progress Size Adjustment for Grid */
.circular-progress-container {
    padding-bottom: 24px;
    margin-bottom: 0;
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 16px auto;
}

.circular-progress {
    /* Reduced to 100px to avoid overlap with linear progress */
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 100px;
    margin: 0;
    border-radius: 50%;
    /* Background set inline by JS now */
    transition: all 0.5s ease;
    -webkit-mask: radial-gradient(transparent 42px, black 42.5px);
    mask: radial-gradient(transparent 42px, black 42.5px);
}

.circular-progress::before {
    display: none;
}

/* Ensure inner circle content sits on top */
.inner-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 84px;
    height: 84px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.inner-circle span:first-child {
    font-size: 20px;
    font-weight: 700;
}

/* Linear Progress Overrides */
.linear-progress-container {
    margin-top: 12px;
}

/* Stats Grid Overrides */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.stat-label {
    font-size: 10px;
}

.stat-value {
    font-size: 13px;
    font-weight: 600;
}

/* Helper Colors */
.text-green {
    color: var(--success-color);
}

.text-red {
    color: var(--error-color);
}

.text-orange {
    color: var(--warning-color);
}

.bg-green {
    background-color: var(--success-color);
}

.bg-red {
    background-color: var(--error-color);
}

.bg-orange {
    background-color: var(--warning-color);
}

/* Footer Status Area */
.status-indicator-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
}

.status-active {
    background: rgba(16, 185, 129, 0.15) !important;
    color: #10b981 !important;
    border: 1px solid rgba(16, 185, 129, 0.25) !important;
}

.status-error {
    background: rgba(239, 68, 68, 0.15) !important;
    color: #ef4444 !important;
    border: 1px solid rgba(239, 68, 68, 0.25) !important;
}

.status-unknown {
    background: rgba(245, 158, 11, 0.15) !important;
    color: #f59e0b !important;
    border: 1px solid rgba(245, 158, 11, 0.25) !important;
}

.balance-badge {
    font-family: monospace;
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 600;
}

/* Responsive Grid Layout */
@media (min-width: 768px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1600px) {
    .cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Mobile Header Adjustments */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        width: 100%;
    }

    .lang-switch {
        width: 100%;
        justify-content: flex-start;
    }

    .header-title-group h1 {
        font-size: 24px;
    }
}

/* Login Modal */
.login-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.login-modal {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 32px;
    width: 90%;
    max-width: 320px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-header h3 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 8px 0;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0;
}

.login-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
}

.input-group input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.2);
}

.login-error {
    color: var(--error-color);
    font-size: 13px;
    text-align: center;
    margin: -8px 0 0 0;
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary-gradient);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px rgba(118, 75, 162, 0.5);
}

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}