/* ================================================
   NetImpact E2 App — Global Styles
   ================================================ */

/* Base */
html, body {
    font-family: 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    background-color: #F5F7FA;
    margin: 0;
    padding: 0;
    height: 100%;
}

/* Layout fill */
.mud-layout {
    height: 100vh;
}

/* Page content padding */
.page-content {
    padding: 0;
    background-color: #F5F7FA;
    min-height: calc(100vh - 64px);
}

.page-shell {
    padding-top: 24px;
    padding-bottom: 32px;
}

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.page-toolbar-filter {
    width: 220px;
    max-width: 100%;
}

.table-action-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-action-card {
    cursor: pointer;
    min-height: 132px;
    border-radius: var(--mud-default-borderradius);
}

.requests-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 16px;
}

.requests-toolbar-tabs {
    flex: 1 1 0;
    min-width: 0;
}

.requests-toolbar-search {
    flex: 0 1 420px;
    min-width: 280px;
}

.requests-toolbar-action {
    display: flex;
    flex: 1 1 0;
    justify-content: flex-end;
}

.requests-filter-clear {
    min-height: 40px;
    height: 40px;
}

/* Login page background */
.login-background {
    min-height: 100vh;
    background: linear-gradient(135deg, #1565C0 0%, #0D47A1 60%, #00897B 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* ================================================
   Responsive Tables
   ================================================ */
.mud-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Status chip min-width for readability */
.mud-chip {
    min-width: 80px;
    justify-content: center;
}

/* ================================================
   Card improvements
   ================================================ */
.stat-card {
    border-left: 4px solid var(--mud-palette-primary);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12) !important;
    transform: translateY(-2px);
}

.stat-card.success-card { border-left-color: #388E3C; }
.stat-card.warning-card { border-left-color: #F57C00; }
.stat-card.error-card   { border-left-color: #D32F2F; }
.stat-card.info-card    { border-left-color: #0288D1; }
.stat-card.default-card { border-left-color: #9E9E9E; }

/* ================================================
   Page header pattern
   ================================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header-title {
    font-size: 1.25rem;
    font-weight: 500;
    color: #212121;
}

/* ================================================
   Blazor error UI
   ================================================ */
#blazor-error-ui {
    background: #FFF3E0;
    border-top: 3px solid #F57C00;
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
    display: none;
    left: 0;
    padding: 12px 24px;
    position: fixed;
    width: 100%;
    z-index: 2000;
    font-family: 'Roboto', sans-serif;
    font-size: 0.875rem;
    color: #E65100;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 16px;
    top: 12px;
    font-weight: bold;
    color: #BF360C;
}

.blazor-error-boundary {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23D32F2F'%3E%3Cpath d='M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E")
        no-repeat 12px center, #FFEBEE;
    border-radius: 6px;
    border: 1px solid #EF9A9A;
    padding: 12px 12px 12px 44px;
    color: #D32F2F;
    font-size: 0.875rem;
    min-height: 40px;
}

.blazor-error-boundary::after {
    content: "An unhandled error has occurred.";
}

/* ================================================
   Responsive breakpoints
   ================================================ */

/* Hide on extra-small screens */
@media (max-width: 600px) {
    .d-xs-none { display: none !important; }

    .page-shell {
        padding-top: 16px;
        padding-bottom: 24px;
    }

    .page-toolbar,
    .page-header {
        align-items: stretch;
    }

    .page-toolbar > *,
    .page-header > * {
        width: 100%;
    }

    .page-toolbar-filter {
        width: 100%;
    }

    .table-action-row .mud-button,
    .table-action-row .mud-icon-button {
        min-height: 36px;
    }

    .quick-action-card {
        min-height: 116px;
    }

    .requests-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .requests-toolbar-search {
        flex: 1 1 auto;
        min-width: 0;
        width: 100%;
    }

    .requests-toolbar-action,
    .requests-toolbar-action .mud-button-root {
        width: 100%;
    }

    .requests-toolbar-action {
        justify-content: stretch;
    }

    .mud-table th,
    .mud-table td {
        padding: 6px 8px !important;
        font-size: 0.8125rem;
    }
}

/* Tablet adjustments */
@media (min-width: 600px) and (max-width: 960px) {
    .mud-table th,
    .mud-table td {
        padding: 8px 12px !important;
    }
}

/* Navigation drawer responsive */
.app-side-nav .mud-drawer-content {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

@media (max-width: 959px) {
    .mud-drawer {
        position: fixed;
        z-index: 1100;
    }
}

/* ================================================
   Print styles
   ================================================ */
@media print {
    .mud-appbar,
    .mud-drawer,
    .mud-button,
    .mud-icon-button {
        display: none !important;
    }

    .mud-main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* ================================================
   Environment Indicator
   ================================================ */
.env-chip {
    font-size: 0.625rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.06em !important;
    height: 20px !important;
    padding: 0 6px !important;
    text-transform: uppercase;
    border-radius: 4px !important;
}

/* ================================================
   User Profile & Notifications
   ================================================ */
.user-menu-trigger {
    padding: 4px 8px;
    border-radius: 24px;
    transition: background 0.2s ease;
}
.user-menu-trigger:hover {
    background: rgba(255,255,255,0.12);
}

/* ================================================
   App Bar search box
   ================================================ */
.appbar-search .mud-input-root {
    background: rgba(255,255,255,0.12);
    border-radius: 20px;
    color: white;
    padding: 4px 12px;
}
.appbar-search .mud-input-root input::placeholder { color: rgba(255,255,255,0.6); }
.appbar-search .mud-input-root .mud-input-adornment { color: rgba(255,255,255,0.7); }

/* ================================================
   Lifecycle Stage Progress
   ================================================ */
.lifecycle-rail {
    display: flex;
    align-items: flex-start;
    padding: 16px 0 8px;
    position: relative;
    overflow-x: auto;
}

.lifecycle-rail::before {
    content: '';
    position: absolute;
    top: 27px;
    left: 24px;
    right: 24px;
    height: 2px;
    background: var(--mud-palette-divider, #E0E0E0);
    z-index: 0;
}

.lc-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 64px;
    position: relative;
    z-index: 1;
}

.lc-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #BDBDBD;
    background: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #9E9E9E;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.lc-dot.lc-completed {
    background: #388E3C;
    border-color: #388E3C;
    color: white;
}

.lc-dot.lc-active {
    background: #1565C0;
    border-color: #1565C0;
    color: white;
    box-shadow: 0 0 0 4px rgba(21,101,192,0.25);
    animation: lc-pulse 2s ease-in-out infinite;
}

.lc-dot.lc-rejected {
    background: #D32F2F;
    border-color: #D32F2F;
    color: white;
}

.lc-dot.lc-cancelled {
    background: #757575;
    border-color: #757575;
    color: white;
}

@keyframes lc-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(21,101,192,0.25); }
    50% { box-shadow: 0 0 0 8px rgba(21,101,192,0.10); }
}

.lc-label {
    font-size: 0.6875rem;
    text-align: center;
    margin-top: 6px;
    font-weight: 500;
    color: #616161;
    white-space: nowrap;
}
.lc-label.lc-active-label { color: #1565C0; font-weight: 700; }
.lc-label.lc-completed-label { color: #388E3C; }
.lc-label.lc-rejected-label { color: #D32F2F; }

.lc-connector {
    position: absolute;
    top: 13px;
    left: calc(50% + 14px);
    right: calc(-50% + 14px);
    height: 2px;
    background: #E0E0E0;
    z-index: 0;
}
.lc-connector.lc-conn-done { background: #388E3C; }
.lc-connector.lc-conn-active { background: linear-gradient(90deg, #388E3C 50%, #E0E0E0 50%); }

/* ================================================
   SLA Indicators
   ================================================ */
.sla-banner {
    border-radius: 6px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    font-weight: 500;
}
.sla-overdue { background: rgba(211,47,47,0.10); border-left: 4px solid #D32F2F; color: #B71C1C; }
.sla-critical { background: rgba(245,124,0,0.10); border-left: 4px solid #F57C00; color: #E65100; }
.sla-warning { background: rgba(251,192,45,0.10); border-left: 4px solid #FBC02D; color: #F57F17; }
.sla-ok { background: rgba(56,142,60,0.08); border-left: 4px solid #388E3C; color: #1B5E20; }

/* ================================================
   Activity / Audit Timeline
   ================================================ */
.audit-timeline {
    position: relative;
    padding-left: 28px;
}
.audit-timeline::before {
    content: '';
    position: absolute;
    left: 9px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--mud-palette-divider, #E0E0E0);
}
.audit-item {
    position: relative;
    margin-bottom: 16px;
}
.audit-dot {
    position: absolute;
    left: -22px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #1565C0;
    border: 2px solid #FFFFFF;
    box-shadow: 0 0 0 2px #1565C0;
}
.audit-dot.audit-create { background: #388E3C; box-shadow: 0 0 0 2px #388E3C; }
.audit-dot.audit-update { background: #0288D1; box-shadow: 0 0 0 2px #0288D1; }
.audit-dot.audit-status { background: #F57C00; box-shadow: 0 0 0 2px #F57C00; }
.audit-dot.audit-delete { background: #D32F2F; box-shadow: 0 0 0 2px #D32F2F; }

.audit-content {
    background: var(--mud-palette-surface, #FFFFFF);
    border: 1px solid var(--mud-palette-divider, #E0E0E0);
    border-radius: 6px;
    padding: 8px 12px;
}
.audit-content:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

/* ================================================
   Request Activity Feed
   ================================================ */
.activity-feed-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--mud-palette-divider, #E0E0E0);
}
.activity-feed-item:last-child { border-bottom: none; }
.activity-feed-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ================================================
   KPI / Stat Cards — Enhanced
   ================================================ */
.kpi-card {
    border-radius: 10px !important;
    overflow: hidden;
    transition: box-shadow 0.25s ease, transform 0.25s ease;
    cursor: default;
}
.kpi-card:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,0.14) !important;
    transform: translateY(-3px);
}
.kpi-card-accent {
    height: 4px;
    width: 100%;
}
.kpi-number {
    font-size: 2rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    letter-spacing: -0.02em;
}
.kpi-label {
    font-size: 0.78rem !important;
    font-weight: 500 !important;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.7;
}

/* ================================================
   Request Status Pill
   ================================================ */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

/* ================================================
   Data Grid Enhancements
   ================================================ */
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: rgba(21,101,192,0.05) !important; }

/* ================================================
   Approval Cards
   ================================================ */
.approval-card {
    border-left: 4px solid #F57C00;
    border-radius: 8px;
    transition: box-shadow 0.2s ease;
}
.approval-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.10) !important; }

/* ================================================
   Empty state
   ================================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    opacity: 0.7;
}

/* ================================================
   Section divider with label
   ================================================ */
.section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 16px;
}
.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--mud-palette-divider, #E0E0E0);
}
.section-divider-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9E9E9E;
    white-space: nowrap;
}

/* ================================================
   Responsive print updates
   ================================================ */
@media (max-width: 600px) {
    .lifecycle-rail { padding: 12px 0 4px; }
    .lc-label { font-size: 0.6rem; }
}

/* ================================================
   Request Detail — Page Header
   ================================================ */
.rd-page-header {
    background: linear-gradient(135deg, #1565C0 0%, #0D47A1 60%, #1976D2 100%);
    border-radius: 12px;
    padding: 24px 28px;
    color: white;
}

.rd-request-number {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    color: white !important;
    letter-spacing: -0.01em;
    line-height: 1.2 !important;
}

.rd-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.rd-header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 12px;
}

.rd-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8125rem;
    color: rgba(255,255,255,0.85);
}

.rd-header-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

/* Status badge on header (white-on-dark) */
.rd-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.35);
    white-space: nowrap;
}

.rd-badge-overdue  { background: rgba(211,47,47,0.85) !important; border-color: rgba(211,47,47,0.6) !important; }
.rd-badge-sla-critical { background: rgba(245,124,0,0.85) !important; border-color: rgba(245,124,0,0.6) !important; }
.rd-badge-cancelled { background: #C62828 !important; border-color: #B71C1C !important; color: #FFF !important; }

/* ================================================
   Request Detail — Inline Status Indicators
   ================================================ */
.rd-inline-status {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    flex-shrink: 0;
    border: 1px solid transparent;
}

/* Request status colours */
.rd-status-draft           { background: rgba(158,158,158,0.12); color: #616161;  border-color: rgba(158,158,158,0.35); }
.rd-status-submitted       { background: rgba(2,136,209,0.10);   color: #0277BD;  border-color: rgba(2,136,209,0.3); }
.rd-status-in-progress     { background: rgba(245,124,0,0.10);   color: #E65100;  border-color: rgba(245,124,0,0.3); }
.rd-status-pending-approval{ background: rgba(251,192,45,0.15);  color: #F57F17;  border-color: rgba(251,192,45,0.4); }
.rd-status-approved        { background: rgba(56,142,60,0.10);   color: #2E7D32;  border-color: rgba(56,142,60,0.3); }
.rd-status-completed       { background: rgba(56,142,60,0.10);   color: #2E7D32;  border-color: rgba(56,142,60,0.3); }
.rd-status-rejected        { background: rgba(211,47,47,0.10);   color: #C62828;  border-color: rgba(211,47,47,0.3); }
.rd-status-cancelled       { background: #C62828; color: #FFF;  border-color: #B71C1C; }
.rd-status-revision-required { background: rgba(121,85,72,0.10); color: #4E342E; border-color: rgba(121,85,72,0.3); }

/* Action status colours */
.rd-action-approved, .rd-action-completed { background: rgba(56,142,60,0.10);   color: #2E7D32; border-color: rgba(56,142,60,0.3); }
.rd-action-pending         { background: rgba(21,101,192,0.10); color: #1565C0;  border-color: rgba(21,101,192,0.3); }
.rd-action-rejected        { background: rgba(211,47,47,0.10);  color: #C62828;  border-color: rgba(211,47,47,0.3); }
.rd-action-revision-needed { background: rgba(245,124,0,0.10);  color: #E65100;  border-color: rgba(245,124,0,0.3); }
.rd-action-terminated      { background: rgba(117,117,117,0.10);color: #616161;  border-color: rgba(117,117,117,0.3); }
.rd-action-delegated       { background: rgba(2,136,209,0.10);  color: #0277BD;  border-color: rgba(2,136,209,0.3); }

/* Stage state colours */
.rd-stage-completed { background: rgba(56,142,60,0.10);   color: #2E7D32; border-color: rgba(56,142,60,0.3); }
.rd-stage-active    { background: rgba(21,101,192,0.10);  color: #1565C0; border-color: rgba(21,101,192,0.3); }
.rd-stage-rejected  { background: rgba(211,47,47,0.10);   color: #C62828; border-color: rgba(211,47,47,0.3); }
.rd-stage-skipped   { background: rgba(117,117,117,0.10); color: #616161; border-color: rgba(117,117,117,0.3); }
.rd-stage-pending   { background: rgba(158,158,158,0.08); color: #9E9E9E; border-color: rgba(158,158,158,0.25); }

/* ================================================
   Request Detail — Field Display
   ================================================ */
.rd-field {
    display: flex;
    flex-direction: column;
    padding: 8px 4px;
}

.rd-field-label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #9E9E9E;
    margin-bottom: 3px;
}

.rd-field-value {
    font-size: 0.875rem;
    font-weight: 500;
    color: #212121;
    word-break: break-word;
}
.rd-field-value-muted { color: #9E9E9E !important; font-style: italic; font-weight: 400 !important; }
.rd-field-value-money { font-variant-numeric: tabular-nums; color: #1B5E20 !important; font-weight: 700 !important; }

/* Business Information dynamic form data */
.rd-form-data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2px 16px;
}

/* ================================================
   Stage Progress Bar (dynamic, API-driven)
   ================================================ */
.stage-progress-bar {
    display: flex;
    align-items: flex-start;
    width: 100%;
    overflow-x: auto;
    padding: 4px 0 8px;
    -webkit-overflow-scrolling: touch;
}

.spb-stage {
    display: flex;
    align-items: flex-start;
    flex: 1;
    min-width: 72px;
}

.spb-milestone {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 120px;
    flex-shrink: 0;
    cursor: default;
}

.spb-connector {
    flex: 1;
    height: 2px;
    background: #E0E0E0;
    margin-top: 17px;
    min-width: 12px;
    transition: background 0.3s ease;
}
.spb-conn-done   { background: #388E3C; }
.spb-conn-active { background: linear-gradient(90deg, #388E3C 50%, #E0E0E0 50%); }

.spb-node {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #BDBDBD;
    background: #F5F5F5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9E9E9E;
    transition: all 0.3s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    position: relative;
    z-index: 1;
}

.spb-completed .spb-node { background: #388E3C; border-color: #388E3C; color: white; box-shadow: 0 2px 6px rgba(56,142,60,0.3); }
.spb-active    .spb-node { background: #1565C0; border-color: #1565C0; color: white; box-shadow: 0 0 0 5px rgba(21,101,192,0.2); animation: spb-pulse 2s ease-in-out infinite; }
.spb-rejected  .spb-node { background: #D32F2F; border-color: #D32F2F; color: white; box-shadow: 0 2px 6px rgba(211,47,47,0.3); }
.spb-skipped   .spb-node { background: #9E9E9E; border-color: #9E9E9E; color: white; opacity: 0.65; }

@keyframes spb-pulse {
    0%, 100% { box-shadow: 0 0 0 5px rgba(21,101,192,0.2); }
    50%       { box-shadow: 0 0 0 9px rgba(21,101,192,0.07); }
}

.spb-step-num {
    font-size: 0.75rem;
    font-weight: 700;
    color: #BDBDBD;
}

.spb-label-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 7px;
    text-align: center;
    max-width: 120px;
}

.spb-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: #757575;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 116px;
}
.spb-completed .spb-label { color: #388E3C; }
.spb-active    .spb-label { color: #1565C0; font-weight: 700; }
.spb-rejected  .spb-label { color: #D32F2F; }
.spb-skipped   .spb-label { color: #9E9E9E; }

.spb-sublabel {
    font-size: 0.625rem;
    color: #BDBDBD;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 116px;
    margin-top: 2px;
}
.spb-assignee-text { color: #1565C0; font-weight: 600; }

/* ================================================
   Responsive — Request Detail
   ================================================ */
@media (max-width: 600px) {
    .rd-page-header        { padding: 16px; border-radius: 8px; }
    .rd-request-number     { font-size: 1.125rem !important; }
    .rd-header-meta        { gap: 8px; }
    .stage-progress-bar    { padding: 2px 0 4px; }
    .spb-milestone         { width: 92px; }
    .spb-label             { font-size: 0.625rem; max-width: 88px; }
    .spb-sublabel          { max-width: 88px; }
    .spb-node              { width: 30px; height: 30px; }
    .spb-connector         { margin-top: 14px; }
}
