/* Main Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, #1f2933, #0b1016);
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Maintenance Overlay */
#maintenance-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #fff;
    text-align: center;
}

#maintenance-overlay.active {
    display: flex;
}

.maintenance-content {
    background: rgba(17, 24, 39, 0.9);
    padding: 40px;
    border-radius: 16px;
    border: 1px solid rgba(75, 85, 99, 1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-width: 500px;
}

.maintenance-icon {
    font-size: 3rem;
    margin-bottom: 20px;
}

.maintenance-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
    background: linear-gradient(to right, #f59e0b, #d97706);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.maintenance-text {
    font-size: 1.1rem;
    color: #d1d5db;
    line-height: 1.6;
}

header {
    padding: 12px 20px;
    background: linear-gradient(90deg, #111827, #1f2937);
    border-bottom: 1px solid #111827;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 10;
    position: relative;
    overflow: hidden;
}

.header-left {
    display: flex;
    flex-direction: column;
}

h1 {
    margin: 0;
    font-size: 1.3rem;
    letter-spacing: 0.03em;
}

.subtitle {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-top: 4px;
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.message-counter {
    font-size: 1.8rem;
    font-weight: 700;
    color: #60a5fa;
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.5);
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.message-counter-label {
    font-size: 0.7rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.header-right {
    font-size: 0.8rem;
    color: #9ca3af;
    text-align: right;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    font-size: 0.7rem;
    margin-left: 6px;
}

.forum-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 6px;
}

.forum-status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.forum-status-indicator.online {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
    animation: pulse 2s infinite;
}

.forum-status-indicator.offline {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    animation: none;
}

.forum-status-indicator.busy {
    background: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
    animation: pulse 1.5s infinite;
}

.forum-status-link {
    color: #9ca3af;
    text-decoration: none;
    transition: color 0.2s;
}

.forum-status-link:hover {
    color: #60a5fa;
}

.layout {
    flex: 1;
    display: flex;
    min-height: 0;
    padding: 10px 14px 14px;
    gap: 12px;
    overflow-y: auto;
    overflow-x: hidden;
}

.card {
    background: rgba(17, 24, 39, 0.98);
    border-radius: 12px;
    border: 1px solid rgba(75, 85, 99, 0.6);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.55);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: 100%;
    min-height: 0;
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
    overflow: hidden;
    min-width: 0;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.card-subtitle {
    font-size: 0.75rem;
    color: #9ca3af;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex-shrink: 0;
}

.pane-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.pane-right {
    flex: 1.3;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pane-right .card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Bot Status Indicator */
.bot-status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 2s infinite;
}

.bot-status-indicator.bot-online {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.bot-status-indicator.bot-offline {
    background: #6b7280;
    animation: none;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.bot-invite-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(88, 101, 242, 0.4);
}

.bot-invite-button:active {
    transform: translateY(0);
}

/* Online Players */
#online-players {
    max-height: none;
    min-height: 60px;
    overflow-y: visible;
    overflow-x: hidden;
    margin-top: 8px;
    margin-bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 6px;
    padding: 8px;
    box-sizing: border-box;
    flex: 0 0 auto;
}

#online-players .players-grid {
    display: grid;
    gap: 4px;
}

#online-players .players-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
}

#online-players .players-grid.cols-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

#online-players .players-grid.cols-4 {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

#online-players .player-item {
    display: flex;
    flex-direction: column;
    padding: 6px 8px;
    border-bottom: 1px solid rgba(55, 65, 81, 0.3);
    font-size: 0.7rem;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 4px;
    gap: 4px;
}

#online-players .player-item .player-name {
    color: #e5e7eb;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#online-players .player-item .player-stats {
    display: flex;
    gap: 12px;
    color: #9ca3af;
    font-size: 0.65rem;
}

/* Live chat */
#live-chat {
    flex: 1 1 0;
    min-height: 150px;
    overflow-y: auto;
    overflow-x: hidden;
    margin-top: 8px;
    margin-bottom: 0;
    padding: 4px 8px 4px 4px;
    box-sizing: border-box;
}

.chat-item {
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-meta {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-bottom: 2px;
}

.chat-username {
    font-weight: 600;
    color: #60a5fa;
}

.chat-time {
    opacity: 0.8;
}

.chat-bubble {
    align-self: flex-start;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    background: linear-gradient(135deg, #111827, #020617);
    border-radius: 10px;
    padding: 6px 8px;
    font-size: 0.83rem;
    line-height: 1.3;
    border: 1px solid rgba(55, 65, 81, 0.9);
}

/* Filters + table */
form {
    margin-bottom: 6px;
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(55, 65, 81, 0.8);
    font-size: 0.8rem;
    box-sizing: border-box;
    overflow: hidden;
}

form .row {
    margin-bottom: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

form .row>* {
    flex-shrink: 0;
}

label {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-right: 4px;
}

input[type="text"],
input[type="date"],
input[type="number"] {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(55, 65, 81, 0.9);
    border-radius: 999px;
    padding: 4px 8px;
    color: #e5e7eb;
    font-size: 0.8rem;
    outline: none;
    width: auto;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

input[type="date"] {
    min-width: 140px;
    max-width: 180px;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="number"]:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.7);
}

button {
    padding: 4px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: white;
    font-weight: 500;
}

button:hover {
    filter: brightness(1.07);
}

a.reset-link {
    font-size: 0.78rem;
    color: #9ca3af;
    text-decoration: none;
}

a.reset-link:hover {
    color: #e5e7eb;
}

#status {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 4px;
}

#log-container {
    flex: 1 1 auto;
    min-height: 200px;
    max-height: none;
    overflow: auto;
    overflow-x: hidden;
    border-radius: 10px;
    border: 1px solid rgba(55, 65, 81, 0.9);
    background: radial-gradient(circle at top left, #020617, #020617);
    box-sizing: border-box;
}

table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.78rem;
    table-layout: auto;
}

th,
td {
    padding: 5px 7px;
    border-bottom: 1px solid rgba(31, 41, 55, 0.9);
    vertical-align: top;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

td {
    max-width: 300px;
}

th {
    position: sticky;
    top: 0;
    background: #020617;
    z-index: 1;
    text-align: left;
    font-weight: 600;
    color: #9ca3af;
}

tr:nth-child(even) td {
    background: rgba(15, 23, 42, 0.7);
}

tr:nth-child(odd) td {
    background: rgba(15, 23, 42, 0.4);
}

.raw {
    color: #9ca3af;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    white-space: pre-wrap;
}

.server-message {
    opacity: 0.6;
    font-style: italic;
}

.server-message .chat-username {
    color: #9ca3af;
}

.server-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(156, 163, 175, 0.2);
    color: #9ca3af;
    font-size: 0.65rem;
    margin-left: 4px;
    text-transform: uppercase;
}

.user-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
    font-size: 0.65rem;
    margin-left: 4px;
    text-transform: uppercase;
}

/* Analytics Dashboard */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
    box-sizing: border-box;
}

.stat-card {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(55, 65, 81, 0.7);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-height: fit-content;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #60a5fa;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.7rem;
    color: #9ca3af;
    text-transform: uppercase;
}

.chart-container {
    height: 200px;
    margin-top: 10px;
    background: rgba(15, 23, 42, 0.7);
    border-radius: 8px;
    padding: 12px;
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid rgba(55, 65, 81, 0.5);
}

.user-list {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    margin-top: 10px;
    background: rgba(15, 23, 42, 0.7);
    border-radius: 6px;
    padding: 8px;
    box-sizing: border-box;
    min-height: 50px;
    border: 1px solid rgba(55, 65, 81, 0.5);
}

.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(55, 65, 81, 0.5);
    min-height: 32px;
    gap: 10px;
    box-sizing: border-box;
    overflow: hidden;
}

.user-item:last-child {
    border-bottom: none;
}

.user-item>span:first-of-type {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-item>span:not(:first-of-type) {
    flex-shrink: 0;
    white-space: nowrap;
}

.user-item>div {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Export & Backup */
.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.btn-export,
.btn-backup {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.btn-export {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.btn-backup {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.btn-export:hover,
.btn-backup:hover {
    filter: brightness(1.1);
}

.backup-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.backup-modal.active {
    display: flex;
}

.backup-content {
    background: rgba(17, 24, 39, 0.98);
    border: 1px solid rgba(75, 85, 99, 0.8);
    border-radius: 12px;
    padding: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Bot Card */
.bot-card {
    flex: 0 0 auto;
    padding: 6px 8px;
    min-height: auto;
    height: auto;
    max-height: none;
}

.bot-card .card-header {
    margin-bottom: 3px;
}

.bot-card .card-title {
    font-size: 0.8rem;
    line-height: 1.2;
}

.bot-card .card-subtitle {
    font-size: 0.65rem;
    line-height: 1.2;
}

.bot-card-content {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    min-height: auto;
    flex-shrink: 0;
}

.bot-avatar {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid;
    box-shadow: 0 0 8px;
}

.bot-avatar.online {
    border-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.bot-avatar.offline {
    border-color: #6b7280;
    box-shadow: 0 0 8px rgba(107, 114, 128, 0.4);
}

.bot-info {
    flex: 1;
    min-width: 0;
}

.bot-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
    color: #e5e7eb;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bot-description {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-bottom: 6px;
    line-height: 1.3;
}

.bot-invite-button {
    display: inline-block;
    padding: 4px 10px;
    background: linear-gradient(135deg, #5865F2 0%, #4752C4 100%);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.75rem;
    transition: all 0.2s;
    box-shadow: 0 1px 4px rgba(88, 101, 242, 0.3);
    line-height: 1.3;
}

/* Players Card */
.players-card {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 400px;
    overflow: visible;
}

.players-section {
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
}

.live-chat-section {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    max-height: 100%;
    margin-top: 15px;
    border-top: 1px solid rgba(55, 65, 81, 0.5);
    padding-top: 12px;
    overflow: hidden;
}

/* Analytics Tab */
.analytics-tab {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    padding: 0;
    gap: 15px;
}

.analytics-note {
    flex: 0 0 auto;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.75rem;
    color: #9ca3af;
}

.analytics-section {
    flex: 0 0 auto;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(55, 65, 81, 0.5);
    border-radius: 8px;
    padding: 12px;
}

.analytics-section h3 {
    font-size: 0.9rem;
    margin: 0 0 10px 0;
    color: #e5e7eb;
}

.analytics-grid-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Logs Tab */
.logs-tab {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.filter-form {
    flex: 0 0 auto;
}

.action-buttons {
    flex: 0 0 auto;
}

.log-status {
    flex: 0 0 auto;
}

.log-container {
    flex: 1 1 auto;
    min-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
}

.backup-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 10px 0;
}

.backup-item {
    padding: 10px;
    border: 1px solid rgba(55, 65, 81, 0.5);
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.backup-item:hover {
    background: rgba(55, 65, 81, 0.3);
}

.backup-item.selected {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
}

.backup-password {
    margin-top: 10px;
}

.backup-password input {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(55, 65, 81, 0.5);
}

.tab {
    padding: 8px 16px;
    cursor: pointer;
    border: none;
    background: transparent;
    color: #9ca3af;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
}

.tab-content {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    flex-direction: column;
}

.tab-content.active {
    display: flex;
}

/* Human-friendly time */
.time-human {
    color: #9ca3af;
    font-size: 0.75rem;
}

@media (max-width: 900px) {
    .layout {
        flex-direction: column;
    }

    .analytics-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .header-center {
        position: static;
        transform: none;
        margin: 8px 0;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-right {
        text-align: left;
        margin-top: 8px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons button {
        width: 100%;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab {
        flex: 1;
        min-width: 100px;
    }

    .analytics-grid-section {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 600px) {
    .stat-value {
        font-size: 1.2rem;
    }

    .message-counter {
        font-size: 1.4rem;
    }

    .card {
        padding: 8px;
    }
}

/* Heartbeat Dot - Dynamic */
.heartbeat-container {
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.heartbeat-dot {
    width: 12px;
    height: 12px;
    background-color: #9ca3af;
    /* Default gray, JS will change it */
    border-radius: 50%;
    display: inline-block;
    transition: all 0.3s ease;
}

.heartbeat-text {
    font-size: 0.85rem;
    color: #d1d5db;
    /* Default gray */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: color 0.3s ease;
}

/* Country Flags */
#country-flags {
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
}

.country-flag-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(96, 165, 250, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.country-flag-badge:hover {
    background: rgba(96, 165, 250, 0.2);
}