/**
 * Admin Dashboard Styles
 * Witit - AI Image Generator
 */

/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #06060a;
    color: white;
    min-height: 100vh;
    line-height: 1.5;
}

/* Header */
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.admin-header-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.admin-back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s ease;
}

.admin-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

.admin-back-btn svg {
    width: 16px;
    height: 16px;
}

.admin-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.admin-title h1 {
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.admin-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-period-select {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.admin-period-select:focus {
    border-color: rgba(0, 212, 255, 0.4);
}

.admin-period-select option {
    background: #1a1a1e;
    color: white;
}

.admin-refresh-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.admin-refresh-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
}

.admin-refresh-btn svg {
    width: 16px;
    height: 16px;
}

/* Main Content */
.admin-main {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Summary Cards */
.admin-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.admin-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.admin-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.admin-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    flex-shrink: 0;
}

.admin-card-icon svg {
    width: 24px;
    height: 24px;
}

.admin-card-icon.users {
    background: rgba(0, 212, 255, 0.15);
    color: #00d4ff;
}

.admin-card-icon.cost {
    background: rgba(255, 170, 0, 0.15);
    color: #ffaa00;
}

.admin-card-icon.personas {
    background: rgba(255, 0, 170, 0.15);
    color: #ff00aa;
}

.admin-card-icon.engagement {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.admin-card-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-card-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-card-value {
    font-size: 28px;
    font-weight: 700;
    color: white;
    line-height: 1.2;
}

.admin-card-sub {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
}

/* Charts */
.admin-charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.admin-chart-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 20px;
}

.admin-chart-container h3 {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 16px;
}

.admin-chart-container canvas {
    max-height: 250px;
}

/* Tables */
.admin-tables-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 16px;
}

.admin-table-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 20px;
}

.admin-table-container h3 {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 16px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-table th {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-table td {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.admin-table .loading {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
}

.admin-table .type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.admin-table .type-badge.friend {
    background: rgba(255, 0, 170, 0.15);
    color: #ff00aa;
}

.admin-table .type-badge.utility {
    background: rgba(0, 212, 255, 0.15);
    color: #00d4ff;
}

/* Loading Overlay */
.admin-loading {
    position: fixed;
    inset: 0;
    background: rgba(6, 6, 10, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.admin-loading.active {
    opacity: 1;
    visibility: visible;
}

.admin-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #00d4ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .admin-header {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }

    .admin-header-left,
    .admin-header-right {
        width: 100%;
        justify-content: space-between;
    }

    .admin-main {
        padding: 16px;
    }

    .admin-charts-row,
    .admin-tables-row {
        grid-template-columns: 1fr;
    }

    .admin-card-value {
        font-size: 24px;
    }
}

/* Debug Info Modal (for Phase 4) */
.debug-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.debug-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.debug-modal {
    background: #1a1a1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(0.98);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.debug-modal-overlay.active .debug-modal {
    transform: translateY(0) scale(1);
}

.debug-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.debug-modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.debug-modal-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s ease;
}

.debug-modal-close:hover {
    color: white;
}

.debug-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.debug-section {
    margin-bottom: 20px;
}

.debug-section:last-child {
    margin-bottom: 0;
}

.debug-section-title {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.debug-code {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 12px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}

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

.debug-stat {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.debug-stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.debug-stat-value {
    font-size: 18px;
    font-weight: 600;
    color: #00d4ff;
}

/* Admin menu item styling */
.user-menu-item.admin-only {
    color: #ffaa00;
}

.user-menu-item.admin-only:hover {
    background: rgba(255, 170, 0, 0.1);
}

.user-menu-item.admin-only svg {
    color: #ffaa00;
}

/* Info button for message actions (admin only) */
.inline-action-btn.info:hover {
    color: #ffaa00;
    background: rgba(255, 170, 0, 0.1);
}
