/* ============================================================
   SHARED COMPONENT STYLES — single source of truth
   All pages use these. Remove duplicates from .razor.css files.
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
    --pm-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --pm-shadow-md: 0 8px 20px rgba(0, 0, 0, 0.08);
    --pm-transition: all 0.3s ease;
}

/* ── Analytics Tables ───────────────────────────────────────── */
.at-table { margin-bottom: 0; }

.at-table thead th {
    background: #f8fafc;
    color: #475569;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 0.875rem 1rem;
    border-bottom: 2px solid #e2e8f0;
    border-top: none;
    white-space: nowrap;
}

.at-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

.at-table tbody tr:hover { background: #f8fafc !important; }

.at-table tbody td {
    padding: 0.875rem 1rem;
    border-top: none;
    vertical-align: middle;
}

.at-table tfoot td {
    padding: 0.875rem 1rem;
    background: #f8fafc;
    border-top: 2px solid #e2e8f0;
    border-bottom: none;
    font-weight: 700;
}

/* Row left-border accents */
.at-row-success { border-left: 3px solid #16a34a; }
.at-row-warning { border-left: 3px solid #d97706; }
.at-row-danger  { border-left: 3px solid #dc2626; }
.at-row-info    { border-left: 3px solid #0891b2; }
.at-row-neutral { border-left: 3px solid #e2e8f0; }

/* Inline mini progress bar for table cells */
.at-mini-bar { width: 60px; height: 5px; background: #f1f5f9; border-radius: 3px; overflow: hidden; flex-shrink: 0; }
.at-mini-bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.at-fill-success { background: #16a34a; }
.at-fill-warning { background: #d97706; }
.at-fill-danger  { background: #dc2626; }
.at-fill-info    { background: #0891b2; }
.at-fill-primary { background: #2563eb; }

/* Growth / status badges for table rows */
.at-badge { display: inline-flex; align-items: center; padding: 0.2rem 0.55rem; border-radius: 12px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.at-badge-success { background: rgba(22,163,74,0.12);  color: #16a34a; }
.at-badge-danger  { background: rgba(220,38,38,0.12);  color: #dc2626; }
.at-badge-warning { background: rgba(217,119,6,0.12);  color: #d97706; }
.at-badge-info    { background: rgba(8,145,178,0.12);  color: #0891b2; }
.at-badge-neutral { background: rgba(71,85,105,0.1);   color: #64748b; }

/* YoY comparison layout */
.yoy-compare { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.yoy-year-col { flex: 1; background: #f8fafc; border-radius: 10px; padding: 0.875rem; border: 1px solid #e2e8f0; }
.yoy-year-label { display: block; font-size: 0.7rem; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.35rem; }
.yoy-year-value { display: block; font-size: 1.05rem; font-weight: 700; line-height: 1.2; }
.yoy-vs { font-size: 0.7rem; font-weight: 700; color: #94a3b8; flex-shrink: 0; }

.yoy-growth { text-align: center; padding: 0.875rem 1rem; background: #f8fafc; border-radius: 10px; border: 1px solid #e2e8f0; }
.growth-badge { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.45rem 1.1rem; border-radius: 20px; font-size: 1.1rem; font-weight: 700; margin-bottom: 0.4rem; }
.growth-up   { background: rgba(22,163,74,0.12);  color: #16a34a; }
.growth-down { background: rgba(220,38,38,0.12);  color: #dc2626; }
.growth-flat { background: rgba(71,85,105,0.1);   color: #64748b; }

/* ── Page Header ────────────────────────────────────────────── */
.modern-page-header {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 0;
}

.header-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: white;
    flex-shrink: 0;
    transition: var(--pm-transition);
}

.modern-page-header:hover .header-icon {
    transform: scale(1.05);
}

.header-content {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.5rem;
    padding-top: 0.25rem;
}

.header-content h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    line-height: 1.2;
}

.header-content p {
    font-size: 0.95rem;
    color: #64748b;
    margin: 0;
    font-weight: 400;
    line-height: 1.4;
}

.header-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ── Metric Cards (Analytics Design: icon box, badge, progress bar) */
.metrics-row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
}

.metrics-row > [class*="col-"] {
    display: flex;
    flex-direction: column;
}

.metric-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: var(--pm-transition);
    height: 100%;
    display: flex;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    border: none;
    cursor: pointer;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: #e2e8f0;
}

.metric-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

/* Top accent bar by card variant */
.metric-card-primary::before  { background: linear-gradient(90deg, #2563eb, #1d4ed8); }
.metric-card-success::before  { background: linear-gradient(90deg, #16a34a, #15803d); }
.metric-card-info::before     { background: linear-gradient(90deg, #0891b2, #0e7490); }
.metric-card-warning::before  { background: linear-gradient(90deg, #d97706, #b45309); }
.metric-card-danger::before   { background: linear-gradient(90deg, #dc2626, #b91c1c); }
.metric-card-purple::before   { background: linear-gradient(90deg, #d97706, #b45309); }

/* Icon box */
.metric-icon-box {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
    transition: var(--pm-transition);
}

.metric-card:hover .metric-icon-box {
    transform: scale(1.08);
}

.metric-icon-primary { background: rgba(37, 99, 235, 0.12);  color: #2563eb; }
.metric-icon-success { background: rgba(22, 163, 74, 0.12);   color: #16a34a; }
.metric-icon-info    { background: rgba(8, 145, 178, 0.12);   color: #0891b2; }
.metric-icon-warning { background: rgba(217, 119, 6, 0.12);   color: #d97706; }
.metric-icon-danger  { background: rgba(220, 38, 38, 0.12);   color: #dc2626; }
.metric-icon-amber   { background: rgba(217, 119, 6, 0.12);   color: #d97706; }

/* Content layout */
.metric-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.metric-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #6c757d;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.6rem;
    color: #0f172a;
}

/* Status badge pill */
.metric-footer {
    margin-top: auto;
    margin-bottom: 0.6rem;
}

.metric-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.65rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
}

.metric-badge-primary { background: rgba(37, 99, 235, 0.1);   color: #2563eb; }
.metric-badge-success { background: rgba(22, 163, 74, 0.12);   color: #16a34a; }
.metric-badge-info    { background: rgba(8, 145, 178, 0.12);   color: #0891b2; }
.metric-badge-warning { background: rgba(217, 119, 6, 0.12);   color: #d97706; }
.metric-badge-danger  { background: rgba(220, 38, 38, 0.12);   color: #dc2626; }

.badge-neutral    { background: rgba(71, 85, 105, 0.1);   color: #475569; }
.badge-success    { background: rgba(22, 163, 74, 0.12);   color: #16a34a; }
.badge-info       { background: rgba(8, 145, 178, 0.12);   color: #0891b2; }
.badge-percentage { background: rgba(22, 163, 74, 0.12);   color: #16a34a; }
.badge-danger     { background: rgba(220, 38, 38, 0.12);   color: #dc2626; }
.badge-amber      { background: rgba(217, 119, 6, 0.12);   color: #d97706; }

/* Progress bar */
.metric-progress-bar {
    height: 4px;
    background: #f1f5f9;
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s ease;
}

.fill-primary { background: #2563eb; }
.fill-success { background: #16a34a; }
.fill-info    { background: #0891b2; }
.fill-danger  { background: #dc2626; }
.fill-amber   { background: #d97706; }

/* Compact secondary cards */
.metric-card-compact {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: var(--pm-transition);
    height: 100%;
    display: flex;
    gap: 1rem;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.metric-card-compact::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: #e2e8f0;
}

.metric-card-compact:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-3px);
}

.metric-icon-box-compact {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.metric-content-compact { flex: 1; }

.metric-label-compact {
    font-size: 0.68rem;
    color: #6c757d;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 0.3rem;
}

.metric-value-compact {
    font-size: 1.1rem;
    font-weight: 700;
    color: #212529;
    margin: 0;
}

/* Currency prefix */
.currency-label    { font-size: 0.75rem; font-weight: 600; margin-right: 0.2rem; }
.currency-label-sm { font-size: 0.65rem; font-weight: 600; margin-right: 0.2rem; }

/* Color utility */
.text-amber { color: #d97706 !important; }

/* ── Key Insights Banner ────────────────────────────────────── */
.insights-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 1.75rem 2rem;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.insights-content { flex: 1; }

.insights-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.insights-header i { font-size: 1.4rem; }

.insights-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.insight-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
}

.insight-item i { font-size: 1rem; }
.insight-item strong { color: white; }

.insights-score { flex-shrink: 0; }

.score-circle {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 3px solid;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-number {
    font-size: 2.25rem;
    font-weight: 700;
    color: white;
    line-height: 1;
}

.score-text {
    font-size: 0.58rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 700;
    margin-top: 0.2rem;
    letter-spacing: 0.75px;
    text-align: center;
}

@media (max-width: 1199px) {
    .insights-banner { flex-direction: column; text-align: center; }
    .insights-metrics { justify-content: center; }
}

@media (max-width: 576px) {
    .insights-banner { padding: 1.25rem; gap: 1.25rem; }
    .insights-metrics { flex-direction: column; gap: 0.75rem; align-items: center; }
    .score-circle { width: 90px; height: 90px; }
    .score-number { font-size: 1.75rem; }
}

/* ── Card Headers ───────────────────────────────────────────── */
.bg-gradient-primary {
    background: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
    border-left: 4px solid #2563eb;
    color: #1e293b !important;
}

.bg-gradient-success {
    background: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
    border-left: 4px solid #16a34a;
    color: #1e293b !important;
}

.bg-gradient-warning {
    background: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
    border-left: 4px solid #d97706;
    color: #1e293b !important;
}

.bg-gradient-info {
    background: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
    border-left: 4px solid #0891b2;
    color: #1e293b !important;
}

.bg-gradient-danger {
    background: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
    border-left: 4px solid #dc2626;
    color: #1e293b !important;
}

/* ── Modals ─────────────────────────────────────────────────── */
.modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header .modal-title {
    font-weight: 600;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

/* ── Search Box ─────────────────────────────────────────────── */
.search-box-wrapper {
    display: flex;
    flex-direction: column;
}

.search-box-wrapper input {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    transition: var(--pm-transition);
}

.search-box-wrapper input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ── Action Section ─────────────────────────────────────────── */
.action-section {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.action-section .btn {
    transition: var(--pm-transition);
    border-radius: 8px;
    font-weight: 500;
}

.action-section .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
    padding: 2rem;
    text-align: center;
}

.empty-icon {
    margin-bottom: 1rem;
    font-size: 3rem;
    color: #cbd5e1;
}

/* ── Chart / Stat Cards ─────────────────────────────────────── */
.chart-card {
    transition: var(--pm-transition);
    border-radius: 12px;
}

.chart-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
}

/* ── Form Controls ──────────────────────────────────────────── */
.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    transition: var(--pm-transition);
}

.form-control:focus,
.form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ── Skeleton Loading ───────────────────────────────────────── */
.loading-skeleton {
    animation: pmFadeIn 0.3s ease-in;
}

.skeleton-card {
    background: #f0f0f0;
    border: none;
}

.skeleton-text {
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: pmSkeletonLoad 1.5s infinite;
    border-radius: 4px;
    width: 100%;
    margin-bottom: 0.5rem;
}

.skeleton-text-lg {
    height: 28px;
    margin-bottom: 0.5rem;
}

.skeleton-text-sm {
    height: 12px;
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes pmFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes pmSkeletonLoad {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes pmSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .metric-card { padding: 1.25rem; }
    .metric-icon-box { width: 60px; height: 60px; font-size: 1.5rem; }
    .metric-value { font-size: 1.5rem; }
}

@media (max-width: 768px) {
    .modern-page-header { gap: 1rem; }
    .header-icon { width: 48px; height: 48px; font-size: 1.5rem; }
    .header-content h1 { font-size: 1.5rem; }
    .header-content p { font-size: 0.9rem; }
    .header-actions { flex-wrap: wrap; }

    .metric-card { padding: 1.25rem; }
    .metric-icon-box { width: 56px; height: 56px; font-size: 1.5rem; }

    .action-section { flex-direction: column; }
    .action-section .btn { width: 100%; }
}

@media (max-width: 576px) {
    .modern-page-header { gap: 0.75rem; }
    .header-icon { width: 44px; height: 44px; font-size: 1.25rem; }
    .header-content h1 { font-size: 1.25rem; }
    .header-content p { font-size: 0.85rem; }

    .metric-card { padding: 1rem; flex-direction: column; text-align: center; }
    .metric-icon-box { width: 52px; height: 52px; font-size: 1.35rem; margin: 0 auto; }
    .metric-value { font-size: 1.5rem; }
    .metric-label { font-size: 0.7rem; }
    .metric-badge { font-size: 0.72rem; }
}
