/* OSDU Engagement Dashboard - Styles */
/* Aligned with osdu-activity/osdu-quality design system */

:root {
    /* The Open Group Brand - Teal Palette */
    --primary-500: #00667F;     /* The Open Group Dark Teal */
    --primary-600: #005266;     /* Darker teal for hover */
    --primary-700: #003d4d;     /* Deepest teal */
    --secondary-500: #0891b2;   /* Lighter teal */
    --secondary-600: #0e7490;   /* Medium teal */
    --accent-light: #dbf6ff;    /* The Open Group light blue */

    /* Status Colors (Universal Standards) */
    --success-500: #16a34a;
    --success-600: #15803d;
    --warning-500: #ca8a04;
    --warning-600: #a16207;
    --error-500: #dc2626;
    --error-600: #b91c1c;
    --info-500: #0891b2;

    /* Neutral Colors */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-600: #64748b;
    --gray-900: #0f172a;

    /* Semantic Tokens */
    --bg-main: var(--gray-50);
    --card-bg: #ffffff;
    --card-alt-bg: var(--gray-50);
    --header-bg: linear-gradient(135deg, var(--primary-500), var(--secondary-500));
    --border-subtle: var(--gray-200);

    /* Accents */
    --accent-primary: var(--primary-500);
    --accent-primary-hover: var(--primary-600);
    --accent-primary-soft: rgba(0, 102, 127, 0.1);
    --accent-secondary: var(--secondary-500);
    --accent-success: var(--success-500);
    --accent-warning: var(--warning-500);
    --accent-error: var(--error-500);
    --accent-info: var(--info-500);

    /* Text */
    --text-main: var(--gray-900);
    --text-muted: var(--gray-600);

    /* Shadows */
    --shadow-soft: 0 4px 20px rgba(0, 102, 127, 0.12);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.12);

    /* Radius */
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

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

body {
    margin: 0;
    padding: 32px 20px 40px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #f0fdfa 0%, #f8fafc 50%, #e0f2fe 100%);
    color: var(--text-main);
    line-height: 1.6;
}

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

/* Material Icons Global Styling */
.material-symbols-outlined {
    font-variation-settings:
        'FILL' 0,
        'wght' 400,
        'GRAD' 0,
        'opsz' 24;
    vertical-align: middle;
}

/* Header */
.header {
    background: linear-gradient(135deg, #00667F 0%, #008299 100%);
    border-radius: var(--radius-lg);
    padding: 24px 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(148, 163, 184, 0.25);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: "";
    position: absolute;
    inset: -40px;
    background: radial-gradient(
        circle at top left,
        rgba(255, 255, 255, 0.3),
        transparent 55%
    );
    opacity: 0.8;
    pointer-events: none;
}

.header-content {
    position: relative;
    z-index: 1;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

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

.header-icon {
    font-size: 2.5rem !important;
    color: white;
    opacity: 0.95;
}

.header h1 {
    margin: 0;
    font-size: 1.75rem;
    letter-spacing: 0.01em;
    color: #ffffff;
    font-weight: 600;
}

.header-subtitle {
    margin: 0 0 12px 0;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.4;
}

.header-meta {
    position: relative;
    z-index: 1;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
}

.header-meta-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

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

.header-logo {
    height: 28px;
    width: auto;
    padding: 8px 14px;
    background: #f0fdfa;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-logo:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    background: white;
}

.header-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-meta-item .material-symbols-outlined {
    font-size: 18px;
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 0;
}

.metrics-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
    .metrics-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .metrics-grid-4 {
        grid-template-columns: 1fr;
    }
}

.metric-card {
    background: white;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    position: relative;
    cursor: default;
}

.metric-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(-3px);
}

.metric-icon {
    font-size: 32px !important;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.metric-value {
    font-size: 2.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-bottom: 4px;
    color: var(--text-main);
}

.metric-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}

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

/* Metric Card Variants */
.metric-success {
    background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
    border-color: rgba(22, 163, 74, 0.2);
}
.metric-success .metric-value { color: var(--accent-success); }
.metric-success .metric-icon { color: var(--accent-success); }
.metric-success:hover {
    border-color: var(--success-500);
    box-shadow: 0 8px 20px rgba(22, 163, 74, 0.2);
}

.metric-warning {
    background: linear-gradient(135deg, #ffffff 0%, #fefce8 100%);
    border-color: rgba(202, 138, 4, 0.2);
}
.metric-warning .metric-value { color: var(--accent-warning); }
.metric-warning .metric-icon { color: var(--accent-warning); }
.metric-warning:hover {
    border-color: var(--warning-500);
    box-shadow: 0 8px 20px rgba(202, 138, 4, 0.2);
}

.metric-error {
    background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%);
    border-color: rgba(220, 38, 38, 0.2);
}
.metric-error .metric-value { color: var(--accent-error); }
.metric-error .metric-icon { color: var(--accent-error); }
.metric-error:hover {
    border-color: var(--error-500);
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.2);
}

.metric-neutral {
    background: linear-gradient(135deg, #ffffff 0%, #e2e8f0 100%) !important;
    border-color: rgba(100, 116, 139, 0.2);
}
.metric-neutral .metric-value { color: var(--text-main); }
.metric-neutral .metric-icon { color: var(--gray-600); }
.metric-neutral:hover {
    border-color: var(--gray-600);
    box-shadow: 0 8px 20px rgba(100, 116, 139, 0.2);
}

.metric-info {
    background: linear-gradient(135deg, #ffffff 0%, #ecfeff 100%);
    border-color: rgba(8, 145, 178, 0.2);
}
.metric-info .metric-value { color: var(--accent-info); }
.metric-info .metric-icon { color: var(--accent-info); }
.metric-info:hover {
    border-color: var(--info-500);
    box-shadow: 0 8px 20px rgba(8, 145, 178, 0.2);
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 0;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.2s;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.card-title .material-symbols-outlined {
    font-size: 28px;
    color: var(--accent-primary);
}

/* Key Insights Card */
.insights-card {
    background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
    border-left: 4px solid var(--primary-500);
}

.insights-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    transition: all 0.2s;
}

.insight-item:hover {
    box-shadow: var(--shadow-card);
    transform: translateX(4px);
}

.insight-icon {
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.insight-icon .material-symbols-outlined {
    font-size: 24px;
}

.insight-content {
    flex: 1;
}

.insight-text {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 2px;
}

.insight-detail {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Insight type variants */
.insight-item.critical { border-left: 3px solid var(--error-500); }
.insight-item.critical .insight-icon .material-symbols-outlined { color: var(--error-500); }
.insight-item.warning { border-left: 3px solid var(--warning-500); }
.insight-item.warning .insight-icon .material-symbols-outlined { color: var(--warning-500); }
.insight-item.info { border-left: 3px solid var(--primary-500); }
.insight-item.info .insight-icon .material-symbols-outlined { color: var(--primary-500); }
.insight-item.success { border-left: 3px solid var(--success-500); }
.insight-item.success .insight-icon .material-symbols-outlined { color: var(--success-500); }

/* Section Grid (Two Column) */
.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 20px;
    margin-bottom: 0;
}

@media (max-width: 960px) {
    .section-grid {
        grid-template-columns: 1fr;
    }
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

.chart-container-small {
    height: 220px;
}

/* Category List (for bar visualization) */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 16px;
}

.category-item .name {
    width: 140px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-bar-container {
    flex: 1;
    height: 24px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

.category-bar {
    height: 100%;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--primary-500), var(--secondary-500));
    transition: width 0.5s ease;
}

.category-item .count {
    width: 50px;
    text-align: right;
    font-size: 0.9rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

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

th {
    background: #f1f5f9;
    color: var(--text-main);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 2px solid var(--border-subtle);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.9rem;
}

tr:hover {
    background: rgba(0, 102, 127, 0.03);
}

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

/* Rank Badge */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
}

.rank-badge.gold {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
}

.rank-badge.silver {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    color: white;
}

.rank-badge.bronze {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
}

.rank-badge.default {
    background: var(--gray-100);
    color: var(--text-muted);
}

/* Username styling */
.username {
    font-weight: 600;
    color: var(--text-main);
}

/* Score styling */
.score {
    font-weight: 700;
    color: var(--accent-primary);
}

/* Category Badge */
.category-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--accent-primary-soft);
    color: var(--accent-primary);
}

/* Card Footer */
.card-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
}

.card-footer a {
    color: var(--accent-primary);
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.card-footer a:hover {
    text-decoration: underline;
}

.card-footer .material-symbols-outlined {
    font-size: 18px;
}

/* Trend indicator */
.trend-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.trend-indicator.up {
    color: var(--success-500);
}

.trend-indicator.down {
    color: var(--error-500);
}

.trend-indicator.stable {
    color: var(--text-muted);
}

/* Footer */
.footer {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-subtle);
    margin-top: 48px;
}

.footer a {
    color: var(--accent-primary);
    text-decoration: none;
    border-bottom: 1px dashed rgba(0, 102, 127, 0.5);
    padding-bottom: 1px;
}

.footer a:hover {
    border-bottom-style: solid;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0, 102, 127, 0.1);
    border-top: 3px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

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

/* Error State */
.error {
    background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%);
    border: 1px solid var(--accent-error);
    border-radius: var(--radius-md);
    padding: 24px;
    color: var(--accent-error);
    text-align: center;
}

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

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 16px 12px 24px;
    }

    .header {
        padding: 20px 24px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .header-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-meta-right {
        display: none;
    }

    .card {
        padding: 16px;
    }

    .card-title {
        font-size: 1.1rem;
    }

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

    .category-item .name {
        width: 100px;
        font-size: 0.8rem;
    }

    th, td {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
}
