* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
}

header {
    background: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 20px;
    margin-right: 400px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 32px;
    color: #2d3748;
    margin-bottom: 20px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.stat-value {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
}

.content-wrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.groups-container {
    display: flex;
    flex-direction: column;
    gap: 15px; /* Reasonable spacing between group cards */
}

.logs-sidebar {
    width: 380px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
    position: fixed;
    top: 20px;
    right: 20px;
    flex-shrink: 0;
}

main {
    flex: 1;
    display: grid;
    gap: 20px;
    min-width: 0;
    margin-right: 400px;
}

.logs-sidebar-header {
    padding: 20px;
    border-bottom: 2px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.logs-sidebar-header h2 {
    font-size: 16px;
    color: #2d3748;
    margin: 0;
    font-weight: 700;
    flex: 1;
}

.group-tabs {
    display: flex;
    flex-direction: column;
    border-bottom: 2px solid #e2e8f0;
}

.group-tab {
    padding: 14px 20px;
    border: none;
    background: white;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.group-tab:hover {
    background: #f7fafc;
    color: #2d3748;
}

.group-tab.active {
    background: #edf2f7;
    color: #667eea;
    border-left-color: #667eea;
}

.no-groups-sidebar {
    padding: 20px;
    color: #a0aec0;
    font-size: 13px;
    text-align: center;
}

.logs-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.logs-sidebar-content::-webkit-scrollbar {
    width: 8px;
}

.logs-sidebar-content::-webkit-scrollbar-track {
    background: #f7fafc;
}

.logs-sidebar-content::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.logs-sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.no-groups {
    background: white;
    padding: 60px 30px;
    border-radius: 12px;
    text-align: center;
    color: #718096;
    font-size: 18px;
}

.group-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-left: 5px solid #48bb78;
}

.group-card.paused {
    border-left-color: #f56565;
    opacity: 0.85;
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.group-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.group-info h2 {
    font-size: 24px;
    color: #2d3748;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.status-badge.active {
    background: #c6f6d5;
    color: #22543d;
}

.status-badge.paused {
    background: #fed7d7;
    color: #742a2a;
}

.bot-count {
    color: #718096;
    font-size: 14px;
}

.group-actions {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
}

.group-actions button {
    cursor: pointer;
    border: none;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
    padding: 12px 20px;
}

.group-actions .group-action-btn {
    flex: 1;
    min-width: 0;
}

.btn {
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-success:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(72, 187, 120, 0.3);
}

.btn-warning {
    background: #ed8936;
    color: white;
}

.btn-warning:hover {
    background: #dd6b20;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(237, 137, 54, 0.3);
}

.btn-primary {
    background: #4299e1;
    color: white;
}

.btn-primary:hover {
    background: #3182ce;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(66, 153, 225, 0.3);
}

.btn-danger {
    background: #f56565;
    color: white;
}

.btn-danger:hover {
    background: #e53e3e;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(245, 101, 101, 0.3);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.bots-list {
    display: grid;
    gap: 35px; /* Increased spacing between bot items */
}

.bot-item {
    background: #f7fafc;
    padding: 20px;
    border-radius: 8px;
    border-left: 3px solid #48bb78;
    display: flex;
    flex-direction: column;
}

.bot-item.dead {
    border-left-color: #f56565;
    opacity: 0.6;
}

.bot-item.paused {
    border-left-color: #ed8936;
}

/* Bot Header: Name + Status + Actions */
.bot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.bot-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bot-name {
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bot-status {
    font-size: 16px;
}

.bot-actions {
    display: flex;
    gap: 10px;
}

/* Bot Details */
.bot-details {
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: #718096;
    margin-bottom: 15px;
}

.bot-details span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Progress Section */
.bot-progress-section {
    margin-bottom: 15px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
    color: #4a5568;
}

.progress-bar {
    height: 24px;
    background: #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    width: 100%;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #48bb78 0%, #38a169 100%);
    transition: width 0.3s ease;
    border-radius: 12px;
    width: 0%; /* Default to 0% */
}

/* Button Statistics Grid */
.button-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-top: 15px;
}

.button-stat {
    background: white;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.button-label {
    display: block;
    font-size: 12px;
    color: #718096;
    margin-bottom: 4px;
    font-weight: 500;
}

.button-count {
    display: block;
    font-size: 18px;
    font-weight: bold;
    color: #2d3748;
}

/* Log Items in Sidebar */
.log-item {
    padding: 12px 14px;
    margin-bottom: 6px;
    background: #f7fafc;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    border-left: 4px solid #cbd5e0;
    transition: all 0.2s;
}

.log-item:hover {
    background: #edf2f7;
}

.log-item.slot_found {
    background: #c6f6d5;
    border-left-color: #48bb78;
}

.log-item.register {
    background: #bee3f8;
    border-left-color: #4299e1;
}

.log-item.group_paused,
.log-item.bot_paused {
    background: #feebc8;
    border-left-color: #ed8936;
}

.log-item.group_resumed {
    background: #c6f6d5;
    border-left-color: #48bb78;
}

.log-item.refresh_sent {
    background: #e9d8fd;
    border-left-color: #9f7aea;
}

.log-item.disconnect,
.log-item.heartbeat_timeout {
    background: #fed7d7;
    border-left-color: #f56565;
}

.log-item .log-time {
    color: #718096;
    font-size: 12px;
    font-weight: 600;
}

.log-item .log-bot {
    color: #4299e1;
    font-weight: 600;
    display: inline-block;
    margin-right: 8px;
}

.log-item .log-message {
    color: #2d3748;
    line-height: 1.5;
    margin-top: 4px;
    font-weight: 500;
}

footer {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
    margin-right: 400px;
    text-align: center;
    color: #718096;
    font-size: 14px;
}

footer p {
    margin: 5px 0;
}

#countdown {
    font-weight: bold;
    color: #667eea;
}

@media (max-width: 1200px) {
    header,
    main,
    footer {
        margin-right: 0;
    }

    .logs-sidebar {
        width: 100%;
        max-height: 400px;
        position: static;
        order: 2;
    }

    .content-wrapper {
        flex-direction: column;
    }

    .group-tabs {
        flex-direction: row;
        overflow-x: auto;
    }
}

@media (max-width: 768px) {
    .group-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .bot-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .bot-actions {
        width: 100%;
    }

    .bot-actions .btn {
        flex: 1;
    }

    .bot-details {
        flex-direction: column;
        gap: 8px;
    }

    .button-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Button Statistics Styles */
.button-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
    background: #f7fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.button-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

.button-label {
    font-size: 12px;
    color: #4a5568;
    font-weight: 500;
}

.button-count {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    background: #edf2f7;
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 20px;
    text-align: center;
}

@media (max-width: 768px) {
    .button-stats {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .button-stat {
        padding: 6px 8px;
    }
    
    .button-label {
        font-size: 11px;
    }
    
    .button-count {
        font-size: 12px;
    }
}