/*
 * P4 Design System — Transitional Styles
 * =======================================
 * This file contains ONLY transitional form, layout, and dialog styles
 * that have not yet been scoped to .razor.css files.
 *
 * CSS ownership layers (see CLAUDE.md):
 * - design-tokens.css: tokens only
 * - syncfusion-overrides.css: Syncfusion vendor overrides (all !important)
 * - p4-utilities.css: low-level generic utility classes
 * - p4-components.css: reusable shared-component and page-shell styling
 * - .razor.css: page/component-specific styling
 * - THIS FILE: transitional compatibility (shrink over time)
 *
 * Reorganized: 2026-04-02
 *
 * Remaining contents:
 * - Global resets (box-sizing, body, .p4-icon)
 * - Form inputs (.p4-input, .p4-select, .p4-textarea)
 * - Form groups (.p4-form-group, .p4-label)
 * - Detail form shell (.ds-detail-form, .ds-detail-label, .p4-form-field)
 * - Dialog styles (.p4-dialog, .p4-dialog-form)
 * - Form dialog styles (.p4-form-fields, .p4-form-row, .p4-form-label)
 * - Fieldset sections (.p4-fieldset)
 * - Detail page layout (.p4-detail-layout, .p4-detail-tabs)
 * - Layout shell (.p4-layout, .p4-appbar, .p4-sidebar)
 * - Loading overlays (.p4-loading-*)
 * - Responsive breakpoints for shell/form
 * - Geo popup, filter bar, toolbar toggle
 */


/* ============================================
   GLOBAL BOX-SIZING RESET
   ============================================ */

*,
*::before,
*::after {
    box-sizing: border-box;
}


/* ============================================
   GLOBAL BODY STYLES
   ============================================ */

body {
    font-family: var(--font-primary, 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
    color: var(--p4-on-surface, #1E293B);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* ============================================
   MATERIAL SYMBOLS ICON CLASS
   General-purpose UI icons (nav, dashboard, dialogs, status).
   Syncfusion e-icons covers component-level icons (SfButton, grid toolbar).
   ============================================ */

.p4-icon {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'liga';
}


/* ============================================
   1. FORM INPUTS
   ============================================ */

/* Base Input - Fluent 2 tokens */
.p4-input,
.p4-select,
.p4-textarea {
    font-family: var(--font-primary);
    font-size: var(--p4-body-medium);
    color: var(--p4-on-surface);
    background-color: var(--p4-surface);
    border: 1px solid var(--p4-outline-variant);
    border-radius: var(--p4-shape-extra-small);
    padding: 10px 12px;
    width: 100%;
    transition: border-color 0.15s ease;
    outline: none;
}

.p4-input::placeholder,
.p4-textarea::placeholder {
    color: var(--p4-text-caption, #A0AEC0);
}

.p4-input:focus,
.p4-select:focus,
.p4-textarea:focus {
    border-color: var(--p4-primary);
}

.p4-input:hover:not(:focus):not(:disabled),
.p4-select:hover:not(:focus):not(:disabled),
.p4-textarea:hover:not(:focus):not(:disabled) {
    border-color: var(--p4-outline);
}

.p4-input:disabled,
.p4-select:disabled,
.p4-textarea:disabled {
    background-color: var(--p4-surface-variant);
    color: var(--p4-text-caption, #A0AEC0);
    cursor: not-allowed;
}

.p4-input-error,
.p4-input.error {
    border-color: var(--p4-error);
}

.p4-input-error:focus,
.p4-input.error:focus {
    border-color: var(--p4-error);
}

/* Small Input */
.p4-input-sm {
    padding: 6px 10px;
    font-size: 13px;
}

/* Large Input */
.p4-input-lg {
    padding: 12px 14px;
    font-size: 16px;
}

/* Select Specific */
.p4-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23718096' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* Textarea Specific */
.p4-textarea {
    min-height: 100px;
    resize: vertical;
}

/* Shared utilities moved to p4-utilities.css */

/* Shared page header shell moved to p4-components.css */


/* ============================================
   20. FORM GROUP
   ============================================ */

.p4-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.p4-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--p4-on-surface-variant);
}

.p4-label-required::after {
    content: " *";
    color: var(--p4-error);
}

.p4-helper-text {
    font-size: 12px;
    color: var(--p4-outline);
}

.p4-error-text {
    font-size: 12px;
    color: var(--p4-error);
}


/* ============================================
   23. DIALOG STYLES (Fluent 2 + P4 Design Specs)
   ============================================

   P4 Design Specs:
   - Modal radius: Fluent 2 extra-large (12px)
   - Button radius: 6px
   - Input radius: 2px
   - Consistent form spacing in all dialogs
*/

/* .e-dlg-overlay + .e-dlg-container overrides moved to syncfusion-overrides.css */

/* Dialog Container - Fluent 2 extra-large radius */
.p4-dialog.e-dialog {
    border-radius: var(--p4-shape-extra-large) !important;
    overflow: hidden;
}

.p4-dialog .e-dlg-header-content {
    padding: 20px 24px 16px !important;
    border-bottom: none !important;
    background: var(--p4-surface) !important;
}

.p4-dialog .e-dlg-header {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: var(--p4-on-surface) !important;
}

.p4-dialog .e-dlg-content {
    padding: 0 24px 8px !important;
    background: var(--p4-surface) !important;
}

.p4-dialog .e-footer-content {
    padding: 16px 24px 20px !important;
    background: var(--p4-surface) !important;
    border-top: none !important;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Line-editor dialogs size via .dialog-sm|lg|xl|xxl utility classes (syncfusion-overrides.css).
   Do not add raw-px `.e-dlg-container` width overrides here — they break the
   .p4-dialog.e-dialog centering scope (MEMORY.md 2026-03-01). */

/* Dialog Form - floating labels */
.p4-dialog-form {
    display: flex;
    flex-direction: column;
}

.p4-dialog-form .e-input-group,
.p4-dialog-form .e-float-input {
    margin-bottom: 0;
}

.p4-dialog-form .e-float-input.e-input-focus label.e-float-text,
.p4-dialog-form .e-float-input label.e-label-top {
    color: var(--p4-primary) !important;
    font-size: 12px !important;
}

.p4-dialog-form .e-input-group.e-input-focus,
.p4-dialog-form .e-float-input.e-input-focus {
    border-color: var(--p4-primary) !important;
}

/* Legacy dialog header (for backwards compat) */
.p4-dialog-header {
    display: flex;
    flex-direction: column;
}

.p4-dialog-subtitle {
    font-size: 13px;
    font-weight: 400;
    color: var(--p4-outline);
    margin-top: 2px;
}

.p4-dialog-content {
    font-size: 14px;
    color: var(--p4-on-surface-variant);
    line-height: 1.5;
}

/* Hardware key display */
.p4-hardware-key {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    background: var(--p4-surface-variant);
    padding: 12px;
    border-radius: 4px;
    word-break: break-all;
    user-select: all;
}

/* Progress messages */
.progress-messages {
    max-height: 300px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 13px;
    background: var(--p4-surface-variant);
    border-radius: 4px;
    padding: 12px;
}

.progress-messages div {
    padding: 4px 0;
    border-bottom: 1px solid var(--p4-outline-variant);
}

.progress-messages div:last-child {
    border-bottom: none;
}


/* ============================================
   24. FORM DIALOG STYLES
   ============================================ */

.p4-form-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: center;
    gap: 12px;
}

.p4-form-label {
    font-size: 14px;
    color: var(--p4-on-surface-variant);
    text-align: left;
}

/* Right-align labels only in horizontal form rows (detail page layouts) */
.p4-form-row > .p4-form-label {
    text-align: right;
}

.p4-dialog .p4-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Required field indicator */
.p4-required {
    color: var(--p4-error, #d32f2f);
}

/* Field validation error message */
.p4-field-error {
    font-size: 12px;
    color: var(--p4-error, #d32f2f);
    margin-top: 4px;
}

/* SfCard header + hover overrides moved to syncfusion-overrides.css */


/* ============================================
   24b. COLLAPSIBLE CARD (SfCard + p4-collapsible-card)
   Used on detail pages — SfCard styled to match p4-card look with collapse toggle.
   Pattern: <SfCard CssClass="e-custom-card p4-collapsible-card">
            <CardHeader><div class="p4-collapsible-header">...</div></CardHeader>
   ============================================ */

/* Shared collapsible section shell moved to p4-components.css */


/* ============================================
   24c. FIELDSET SECTIONS (ERP-style outline grouping)
   Angular-style <fieldset> with <legend> on the border.
   Title sits ON the border → 0px vertical overhead.
   Optional collapse chevron in the legend row.
   ============================================ */

.p4-fieldset {
    border: 1px solid var(--p4-outline-variant, #E2E8F0);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
}

.p4-fieldset > legend,
.p4-fieldset-legend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: auto;
    padding: 0 8px;
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--p4-on-surface, #1E293B);
    cursor: pointer;
    user-select: none;
    float: none;
}

.p4-fieldset > legend .p4-collapse-icon,
.p4-fieldset-legend .p4-collapse-icon {
    font-size: 12px;
    color: var(--ds-text-muted, #94a3b8);
    margin-left: 8px;
    transition: color 0.15s;
}

.p4-fieldset > legend:hover .p4-collapse-icon,
.p4-fieldset-legend:hover .p4-collapse-icon {
    color: var(--p4-on-surface, #1E293B);
}

/* When collapsed, only legend is visible (no padding for content) */
.p4-fieldset.p4-fieldset-collapsed {
    padding-bottom: 0;
}

/* Dark mode */
[data-theme*="dark"] .p4-fieldset {
    border-color: var(--ds-outline-variant, #444);
}


/* ============================================
   32. DETAILS GRID (Two-Column Layout)
   ============================================ */

.p4-details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

@media (max-width: 992px) {
    .p4-details-grid {
        grid-template-columns: 1fr;
    }
}


/* ============================================
   34. GEO POPUP (IP Address Lookup)
   ============================================ */

.p4-geo-popup {
    position: fixed;
    z-index: 9999;
    width: 320px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: var(--p4-surface);
    border-radius: var(--p4-shape-large);
    box-shadow: var(--p4-elevation-3);
    overflow: hidden;
}

.p4-geo-map {
    width: 100%;
    height: 180px;
    background: var(--p4-light-gray, #F7FAFC);
}

.p4-geo-map iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.p4-geo-body {
    padding: 16px;
    font-size: 13px;
}

.p4-geo-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}


/* ============================================
   35. IP CELL (Hover State)
   ============================================ */

.p4-ip-cell {
    cursor: pointer;
}


/* ============================================
   47. DETAIL PAGE LAYOUT
   ============================================ */

/* Two-column layout for detail pages — 55/45 split */
.p4-detail-layout {
    display: grid;
    grid-template-columns: 11fr 9fr;
    gap: 24px;
}

.p4-detail-main {
    min-width: 0;
}

.p4-detail-sidebar {
    min-width: 0;
}

/* Group two small cards side-by-side within a column */
.p4-card-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Responsive: Stack on tablet and smaller */
@media (max-width: 1200px) {
    .p4-detail-layout {
        grid-template-columns: 1fr;
    }

    .p4-card-row {
        grid-template-columns: 1fr;
    }

    .p4-detail-sidebar {
        order: 0; /* Keep sidebar below main on mobile */
    }
}

/* HTML detail-page tabs (replaces SfTab for reliability) */
.p4-detail-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--ds-border-default);
    margin-bottom: 0;
}

.p4-detail-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ds-text-secondary);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.p4-detail-tab:hover {
    color: var(--ds-text-primary);
}

.p4-detail-tab.active {
    color: var(--ds-primary);
    border-bottom-color: var(--ds-primary);
    font-weight: 600;
}

/* Tab content improvements */
.p4-tab-content {
    padding: 24px 0;
}

/* Disable tab content animation — prevents flash of previous tab content during switch */
.e-tab .e-content > .e-item {
    animation: none !important;
    transition: none !important;
}

.e-tab .e-content > .e-item:not(.e-active) {
    display: none !important;
}

/* Remove extra padding from nested cards in tabs */
.e-tab .e-content .p4-card {
    margin-bottom: 0;
}

/* Grid container in tabs - full height */
.e-tab .e-content .p4-grid-container {
    min-height: 400px;
}

/* Better totals display */
.p4-totals-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.p4-totals-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

/* Summary totals grid (used in detail pages) */
.p4-totals-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.p4-totals-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0;
    font-size: 14px;
}

.p4-totals-row.p4-text-small {
    font-size: 13px;
    padding-left: 12px;
    color: var(--p4-outline, #64748B);
}

.p4-totals-total {
    padding-top: 12px;
    margin-top: 8px;
    font-weight: 600;
    font-size: 16px;
    border-top: 1px solid var(--p4-outline-variant, #E2E8F0);
}

/* Info list for audit/metadata */
.p4-info-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.p4-info-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.p4-info-label {
    color: var(--p4-text-muted, #718096);
    flex-shrink: 0;
}

.p4-info-value {
    text-align: right;
    color: var(--p4-text-secondary, #4A5568);
}

/* List items for related documents */
.p4-list {
    display: flex;
    flex-direction: column;
}

.p4-list-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.15s ease;
}

.p4-list-item:hover {
    background-color: var(--p4-surface-variant);
}

/* .p4-divider moved to p4-utilities.css */


/* ============================================
   LAYOUT SHELL — .p4-layout, .p4-appbar, .p4-sidebar, .p4-content-area
   Replaces RadzenLayout / RadzenSidebar / RadzenBody with pure HTML+CSS.
   ============================================ */

.p4-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Appbar (Header) ─────────────────────── */
/* Note: Button styles (.p4-appbar-icon-btn, .p4-appbar-profile, etc.)
   are defined in header.css. This file only handles the layout shell. */

.p4-appbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height, 56px);
    min-height: var(--header-height, 56px);
    padding: 0 12px;
    background: var(--p4-surface, #FFFFFF);
    color: var(--p4-on-surface, #1E293B);
    border-bottom: 1px solid var(--p4-outline-variant, #E2E8F0);
    position: relative;
    z-index: var(--z-sticky, 100);
    flex-shrink: 0;
    font-family: var(--font-primary);
}

.p4-appbar-left,
.p4-appbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.p4-appbar-divider {
    width: 1px;
    height: 28px;
    background: var(--p4-outline-variant, #E2E8F0);
    margin: 0 4px;
}

/* ── Main Container (sidebar + content) ─── */

.p4-main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    z-index: 1; /* Below overlay on mobile */
}

/* ── Sidebar ─────────────────────────────── */

.p4-sidebar {
    width: var(--sidebar-width, 260px);
    min-width: var(--sidebar-width, 260px);
    display: flex;
    flex-direction: column;
    background: var(--p4-sidebar-bg, #F8FAFC);
    border-right: 1px solid var(--p4-outline-variant, #E2E8F0);
    overflow: hidden;
    transition: width 0.25s ease, min-width 0.25s ease;
}

.p4-sidebar-collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}

.p4-sidebar-footer {
    padding: 12px 16px;
    margin-top: auto;
    text-align: center;
    border-top: 1px solid var(--p4-outline-variant, #E2E8F0);
    flex-shrink: 0;
}

.p4-sidebar-footer p {
    margin: 0;
    font-size: 11px;
    color: var(--p4-on-surface-muted, #64748B);
    line-height: 1.6;
}

/* ── Mobile Sidebar Overlay ─────────────── */

.p4-sidebar-overlay {
    display: none;
}

/* Mobile: Full overlay sidebar */
@media (max-width: 768px) {
    .p4-sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        top: 56px; /* Below appbar */
        background: rgba(0, 0, 0, 0.5);
        z-index: 1050; /* High enough to be above all content */
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        pointer-events: none;
    }

    .p4-sidebar-overlay.visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .p4-sidebar {
        position: fixed;
        left: 0;
        top: 56px; /* Below appbar */
        bottom: 0;
        z-index: 1051; /* Above overlay */
        width: 280px !important;
        min-width: 280px !important;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    /* Show sidebar when NOT collapsed (sidebarExpanded = true) */
    .p4-sidebar:not(.p4-sidebar-collapsed) {
        transform: translateX(0);
    }

    /* Hide sidebar when collapsed */
    .p4-sidebar.p4-sidebar-collapsed {
        transform: translateX(-100%);
    }
}

/* Tablet: Auto-collapse to icons only */
@media (min-width: 769px) and (max-width: 1024px) {
    .p4-sidebar:not(.p4-sidebar-collapsed) {
        width: 70px;
        min-width: 70px;
    }

    .p4-sidebar:not(.p4-sidebar-collapsed) .p4-nav-text,
    .p4-sidebar:not(.p4-sidebar-collapsed) .p4-nav-badge,
    .p4-sidebar:not(.p4-sidebar-collapsed) .p4-nav-item-label,
    .p4-sidebar:not(.p4-sidebar-collapsed) .p4-sidebar-footer,
    .p4-sidebar:not(.p4-sidebar-collapsed) .p4-nav-search {
        display: none;
    }

    .p4-sidebar:not(.p4-sidebar-collapsed) .p4-nav-item {
        justify-content: center;
        padding: 12px;
    }

    .p4-sidebar:not(.p4-sidebar-collapsed) .p4-nav-group-header {
        display: none;
    }
}

/* ── Content Area ────────────────────────── */

.p4-content-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--p4-surface-variant, #F1F5F9);
}

.p4-content-wrapper {
    width: 100%;
    max-width: 100%;
    padding: 24px;
}

/* ── Dark mode overrides ─────────────────── */

.theme-dark .p4-appbar,
body.e-dark-mode .p4-appbar {
    background: var(--p4-surface, #1E293B);
    border-bottom-color: var(--p4-outline-variant, #334155);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.theme-dark .p4-sidebar,
body.e-dark-mode .p4-sidebar {
    background: var(--p4-sidebar-bg, #1E293B);
    border-right-color: var(--p4-outline-variant, #334155);
}

.theme-dark .p4-appbar-divider,
body.e-dark-mode .p4-appbar-divider {
    background: var(--p4-outline-variant, #334155);
}

.theme-dark .p4-content-area,
body.e-dark-mode .p4-content-area {
    background: var(--p4-surface-variant, #0F172A);
}

.theme-dark .p4-sidebar-footer,
body.e-dark-mode .p4-sidebar-footer {
    border-top-color: var(--p4-outline-variant, #334155);
}


/* ============================================
   FORM GRID
   ============================================ */

.p4-form-grid {
    display: grid;
    gap: 16px;
}

.p4-form-row-full {
    grid-column: 1 / -1;
}


/* ============================================
   FILTER BAR
   ============================================ */

.p4-filter-bar {
    padding: 12px 16px;
    background: var(--p4-surface, #FFFFFF);
    border-radius: var(--p4-shape-large, 8px);
    margin-bottom: 16px;
    box-shadow: var(--p4-elevation-1, 0 1px 2px rgba(0,0,0,0.12));
}


/* ============================================
   TOOLBAR TOGGLE (Show Archived in grid toolbar)
   ============================================ */

.p4-toolbar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
    font-size: 13px;
    color: var(--p4-outline, #94A3B8);
    cursor: pointer;
}

.p4-toolbar-toggle input[type="checkbox"] {
    accent-color: var(--p4-primary, #1976D2);
    cursor: pointer;
}

