/* LPH design system — portal layer.
   Ordered slice of lph-system.css, split to honour the <500-line rule.
   MUST load in sequence base -> components -> utilities -> portal -> responsive, BEFORE lph-theme.css.
   Do not reorder or edit across slice boundaries. */
/* --------------------------------------------------
   Short CSS variable aliases (for backward compat)
-------------------------------------------------- */

:root {
    --gold:           var(--lph-gold);
    --gold-soft:      var(--lph-gold-soft);
    --text-primary:   var(--lph-text-primary);
    --text-secondary: var(--lph-text-secondary);
    --text-muted:     var(--lph-text-muted);
    --surface-1:      var(--lph-surface-1);
    --surface-2:      var(--lph-surface-2);
    --border:         var(--lph-border-soft);
    --border-gold:    var(--lph-border-gold);
}

/* --------------------------------------------------
   Portal card (used in dashboard/order/case views)
-------------------------------------------------- */

.lph-card {
    background: var(--lph-surface-1);
    border: 1px solid var(--lph-border-soft);
    border-radius: var(--lph-radius-md);
    overflow: hidden;
}

.lph-card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--lph-border-soft);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--lph-text-primary);
}

.lph-card-body {
    padding: 16px 18px;
}

/* --------------------------------------------------
   Alert banners
-------------------------------------------------- */

.lph-alert {
    padding: 10px 16px;
    border-radius: var(--lph-radius-sm);
    font-size: 0.85rem;
    margin-bottom: 14px;
}

.lph-alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.25);
    color: #4ade80;
}

.lph-alert-danger, .lph-alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.lph-alert-warning {
    background: rgba(199, 162, 71, 0.1);
    border: 1px solid rgba(199, 162, 71, 0.25);
    color: #e6c97b;
}

.lph-alert-info {
    background: rgba(74, 144, 226, 0.1);
    border: 1px solid rgba(74, 144, 226, 0.25);
    color: #9cc7ff;
}

/* --------------------------------------------------
   Portal page header
-------------------------------------------------- */

.lph-portal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.lph-portal-header h1 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--lph-text-primary);
}

.lph-muted {
    color: var(--lph-text-muted);
    font-size: 0.85rem;
    margin: 0;
}

/* --------------------------------------------------
   Stats row (horizontal flex stats)
-------------------------------------------------- */

.lph-stats-row {
    display: flex;
    gap: 14px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.lph-stats-row .lph-stat-card {
    flex: 1;
    min-width: 140px;
    background: var(--lph-surface-1);
    border: 1px solid var(--lph-border-soft);
    border-radius: var(--lph-radius-md);
    padding: 16px 18px;
}

/* --------------------------------------------------
   Input size variants
-------------------------------------------------- */

.lph-input-sm {
    padding: 6px 10px;
    font-size: 0.82rem;
    border-radius: 8px;
}

.lph-btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    min-height: auto;
    border-radius: 8px;
}

.lph-btn-secondary {
    background: rgba(var(--ink-rgb), 0.06);
    border: 1px solid rgba(var(--ink-rgb), 0.1);
    color: var(--lph-text-primary);
}

.lph-btn-secondary:hover {
    background: rgba(var(--ink-rgb), 0.1);
    border-color: rgba(var(--ink-rgb), 0.18);
}

.lph-btn-outline {
    background: transparent;
    border: 1px solid rgba(var(--ink-rgb), 0.2);
    color: rgba(var(--ink-rgb), 0.65);
}

.lph-btn-outline:hover {
    background: rgba(var(--ink-rgb), 0.06);
    border-color: rgba(var(--ink-rgb), 0.3);
    color: rgba(var(--ink-rgb), 0.9);
}

/* --------------------------------------------------
   Badge extra tones
-------------------------------------------------- */

.lph-badge-muted {
    background: rgba(var(--ink-rgb), 0.04);
    border-color: rgba(var(--ink-rgb), 0.08);
    color: var(--lph-text-muted);
}

.lph-badge-customer {
    background: rgba(74, 144, 226, 0.14);
    border-color: rgba(74, 144, 226, 0.22);
    color: #9cc7ff;
}

.lph-badge-partner {
    background: rgba(199, 162, 71, 0.14);
    border-color: rgba(199, 162, 71, 0.24);
    color: #e6c97b;
}

.lph-badge-agent {
    background: rgba(37, 184, 101, 0.14);
    border-color: rgba(37, 184, 101, 0.22);
    color: #8ff0b7;
}

.lph-badge-lawyer {
    background: rgba(147, 114, 255, 0.14);
    border-color: rgba(147, 114, 255, 0.22);
    color: #c9b8ff;
}

.lph-badge-translator {
    background: rgba(255, 147, 51, 0.14);
    border-color: rgba(255, 147, 51, 0.22);
    color: #ffcb8e;
}

.lph-badge-finance {
    background: rgba(37, 211, 184, 0.14);
    border-color: rgba(37, 211, 184, 0.22);
    color: #7ef8e5;
}

.lph-badge-operations {
    background: rgba(236, 72, 72, 0.14);
    border-color: rgba(236, 72, 72, 0.22);
    color: #ffb0b0;
}

/* --------------------------------------------------
   Mobile sidebar overlay + hamburger
-------------------------------------------------- */

.lph-mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(2, 7, 17, 0.99);
    border-radius: var(--lph-radius-xl) var(--lph-radius-xl) 0 0;
    border-bottom: 1px solid var(--color-surface-hover);
}

.lph-mobile-topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lph-mobile-topbar-brand .lph-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 0.82rem;
}

.lph-mobile-topbar-brand span {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.lph-hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(var(--ink-rgb), 0.1);
    border-radius: 10px;
    background: rgba(var(--ink-rgb), 0.04);
    color: var(--color-text);
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.lph-hamburger-btn:hover {
    background: rgba(var(--ink-rgb), 0.08);
}

.lph-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 98;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.lph-sidebar-overlay.is-open {
    display: block;
}

/* --------------------------------------------------
   Mobile: prevent horizontal overflow in portal
-------------------------------------------------- */

@media (max-width: 768px) {
    .lph-mobile-topbar {
        display: flex;
    }

    .lph-shell {
        grid-template-columns: 1fr !important;
        border-radius: 0 0 var(--lph-radius-2xl) var(--lph-radius-2xl);
    }

    .lph-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 280px !important;
        height: 100vh !important;
        z-index: 99;
        overflow-y: auto !important;
        border-radius: 0 !important;
        border-right: 1px solid rgba(199, 162, 71, 0.15) !important;
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.7);
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .lph-sidebar.is-open {
        transform: translateX(0);
    }

    .lph-portal-header {
        flex-direction: column;
        gap: 10px;
    }

    .lph-stats-row {
        flex-direction: column;
    }

    .lph-stats-row .lph-stat-card {
        min-width: 0;
    }

    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    [style*="grid-template-columns:1fr 2fr auto"],
    [style*="grid-template-columns: 1fr 2fr auto"] {
        grid-template-columns: 1fr !important;
    }

    [style*="grid-template-columns:repeat(2,1fr)"],
    [style*="grid-template-columns: repeat(2, 1fr)"],
    [style*="grid-template-columns:repeat(2, 1fr)"],
    [style*="grid-template-columns: repeat(2,1fr)"] {
        grid-template-columns: 1fr !important;
    }

    [style*="grid-template-columns:repeat(4,1fr)"],
    [style*="grid-template-columns: repeat(4, 1fr)"],
    [style*="grid-template-columns:repeat(4, 1fr)"],
    [style*="grid-template-columns: repeat(4,1fr)"] {
        grid-template-columns: 1fr 1fr !important;
    }

    .lph-card-header[style*="display:flex"] {
        flex-direction: column;
        gap: 8px;
    }

    .lph-btn {
        white-space: nowrap;
    }

    .lph-page-actions {
        flex-wrap: wrap;
    }

    .lph-portal-header .lph-btn {
        width: 100%;
        justify-content: center;
    }

    /* Auto-scroll any card body containing a wide table (tablet only — overridden at 540px) */
    .lph-card-body > table,
    .lph-card > table {
        min-width: 480px;
    }

    .lph-card-body,
    .lph-card {
        overflow-x: auto;
    }

    /* Tighter grid on small screens */
    [style*="grid-template-columns:repeat(3,1fr)"] {
        grid-template-columns: 1fr !important;
    }
    [style*="grid-template-columns: repeat(3, 1fr)"] {
        grid-template-columns: 1fr !important;
    }
    [style*="grid-template-columns:repeat(auto-fill"] {
        grid-template-columns: 1fr 1fr !important;
    }
}

