/*
 * P4 Utility Layer
 * ================
 * Low-level reusable utility classes only.
 * New generic spacing/layout/text helpers belong here, not in p4-design-system.css.
 */

/* ============================================
   SPACING UTILITIES
   ============================================ */

.p4-mt-0 { margin-top: 0; }
.p4-mt-1 { margin-top: 4px; }
.p4-mt-2 { margin-top: 8px; }
.p4-mt-3 { margin-top: 12px; }
.p4-mt-4 { margin-top: 16px; }
.p4-mt-5 { margin-top: 20px; }
.p4-mt-6 { margin-top: 24px; }
.p4-mt-8 { margin-top: 32px; }

.p4-mb-0 { margin-bottom: 0; }
.p4-mb-1 { margin-bottom: 4px; }
.p4-mb-2 { margin-bottom: 8px; }
.p4-mb-3 { margin-bottom: 12px; }
.p4-mb-4 { margin-bottom: 16px; }
.p4-mb-5 { margin-bottom: 20px; }
.p4-mb-6 { margin-bottom: 24px; }
.p4-mb-8 { margin-bottom: 32px; }

.p4-ml-0 { margin-left: 0; }
.p4-ml-1 { margin-left: 4px; }
.p4-ml-2 { margin-left: 8px; }
.p4-ml-3 { margin-left: 12px; }
.p4-ml-4 { margin-left: 16px; }
.p4-ml-auto { margin-left: auto; }

.p4-mr-0 { margin-right: 0; }
.p4-mr-1 { margin-right: 4px; }
.p4-mr-2 { margin-right: 8px; }
.p4-mr-3 { margin-right: 12px; }
.p4-mr-4 { margin-right: 16px; }
.p4-mr-auto { margin-right: auto; }

.p4-p-0 { padding: 0 !important; }
.p4-p-1 { padding: 4px !important; }
.p4-p-2 { padding: 8px !important; }
.p4-p-3 { padding: 12px !important; }
.p4-p-4 { padding: 16px !important; }
.p4-p-5 { padding: 20px !important; }
.p4-p-6 { padding: 24px !important; }

.p4-py-1 { padding-top: 4px !important;  padding-bottom: 4px !important; }
.p4-py-2 { padding-top: 8px !important;  padding-bottom: 8px !important; }
.p4-py-3 { padding-top: 12px !important; padding-bottom: 12px !important; }
.p4-py-4 { padding-top: 16px !important; padding-bottom: 16px !important; }
.p4-py-6 { padding-top: 24px !important; padding-bottom: 24px !important; }

.p4-px-4 { padding-left: 16px !important; padding-right: 16px !important; }

/* ============================================
   LAYOUT UTILITIES
   ============================================ */

.p4-flex { display: flex; }
.p4-inline-flex { display: inline-flex; }
.p4-flex-col { flex-direction: column; }
.p4-flex-row { flex-direction: row; }
.p4-flex-wrap { flex-wrap: wrap; }
.p4-flex-1 { flex: 1; }
.p4-flex-shrink-0 { flex-shrink: 0; }

.p4-items-start { align-items: flex-start; }
.p4-items-center { align-items: center; }
.p4-items-end { align-items: flex-end; }
.p4-items-stretch { align-items: stretch; }

.p4-justify-start { justify-content: flex-start; }
.p4-justify-center { justify-content: center; }
.p4-justify-end { justify-content: flex-end; }
.p4-justify-between { justify-content: space-between; }

.p4-gap-0 { gap: 0; }
.p4-gap-1 { gap: 4px; }
.p4-gap-2 { gap: 8px; }
.p4-gap-3 { gap: 12px; }
.p4-gap-4 { gap: 16px; }
.p4-gap-5 { gap: 20px; }
.p4-gap-6 { gap: 24px; }

.p4-grid { display: grid; }
.p4-grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.p4-grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.p4-grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.p4-grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.p4-grid > * { min-width: 0; }

.p4-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.p4-w-full { width: 100%; }
.p4-w-auto { width: auto; }
.p4-max-w-sm { max-width: 384px; }
.p4-max-w-md { max-width: 448px; }
.p4-max-w-lg { max-width: 512px; }
.p4-max-w-xl { max-width: 640px; }

/* ============================================
   TEXT UTILITIES
   ============================================ */

.p4-text-left { text-align: left; }
.p4-text-center { text-align: center; }
.p4-text-right { text-align: right; }

.p4-truncate,
.p4-text-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.p4-v-mid { vertical-align: middle; }
.p4-whitespace-nowrap { white-space: nowrap; }
.p4-break-words { word-wrap: break-word; }

.p4-text-xs { font-size: 11px; }
.p4-text-sm { font-size: 12px; }
.p4-text-base { font-size: 14px; }
.p4-text-lg { font-size: 16px; }
.p4-text-xl { font-size: 18px; }
.p4-text-2xl { font-size: 24px; }

.p4-font-normal { font-weight: 400; }
.p4-font-medium { font-weight: 500; }
.p4-font-semibold { font-weight: 600; }
.p4-font-bold { font-weight: 700; }

/* ============================================
   COLOR UTILITIES
   ============================================ */

.p4-text-primary { color: var(--p4-on-surface); }
.p4-text-secondary { color: var(--p4-on-surface-variant); }
.p4-text-muted { color: var(--p4-outline); }
.p4-text-subtle { color: var(--p4-outline, #94A3B8); font-weight: 400; }
.p4-text-caption { color: var(--p4-text-caption, #A0AEC0); }
.p4-text-link { color: var(--p4-primary); }
.p4-text-success { color: var(--p4-success); }
.p4-text-warning { color: var(--p4-warning); }
.p4-text-danger { color: var(--p4-error); }
.p4-text-white { color: #FFFFFF; }

.p4-bg-white { background-color: var(--p4-surface); }
.p4-bg-light { background-color: var(--p4-surface-variant); }
.p4-bg-primary { background-color: var(--p4-primary); }
.p4-bg-success { background-color: var(--p4-success); }
.p4-bg-warning { background-color: var(--p4-warning); }
.p4-bg-danger { background-color: var(--p4-error); }

/* ============================================
   BORDER / SHADOW / DISPLAY UTILITIES
   ============================================ */

.p4-border { border: 1px solid var(--p4-outline-variant); }
.p4-border-0 { border: none; }
.p4-border-t { border-top: 1px solid var(--p4-outline-variant); }
.p4-border-b { border-bottom: 1px solid var(--p4-outline-variant); }
.p4-border-l { border-left: 1px solid var(--p4-outline-variant); }
.p4-border-r { border-right: 1px solid var(--p4-outline-variant); }

.p4-rounded { border-radius: var(--p4-shape-extra-small); }
.p4-rounded-md { border-radius: var(--p4-shape-extra-small); }
.p4-rounded-lg { border-radius: var(--p4-shape-small); }
.p4-rounded-xl { border-radius: var(--p4-shape-large); }
.p4-rounded-full { border-radius: var(--p4-shape-full); }

.p4-shadow-none { box-shadow: none; }
.p4-shadow-sm { box-shadow: var(--shadow-sm); }
.p4-shadow { box-shadow: var(--p4-elevation-1); }
.p4-shadow-md { box-shadow: var(--p4-elevation-2); }
.p4-shadow-lg { box-shadow: var(--p4-elevation-3); }

.p4-hidden { display: none; }
.p4-block { display: block; }
.p4-inline { display: inline; }
.p4-inline-block { display: inline-block; }

.p4-visible { visibility: visible; }
.p4-invisible { visibility: hidden; }

.p4-opacity-0 { opacity: 0; }
.p4-opacity-50 { opacity: 0.5; }
.p4-opacity-100 { opacity: 1; }

.p4-cursor-pointer { cursor: pointer; }
.p4-cursor-default { cursor: default; }
.p4-cursor-not-allowed { cursor: not-allowed; }

/* ============================================
   SHARED LOW-LEVEL HELPERS
   ============================================ */

.p4-table-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.p4-divider {
    border: none;
    border-top: 1px solid var(--p4-outline-variant);
    margin: 0;
}

.p4-divider-vertical {
    width: 1px;
    height: 100%;
    background-color: var(--p4-outline-variant);
    margin: 0 12px;
}

@media (max-width: 640px) {
    .p4-form-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   MIGRATED FROM p4-design-system.css (2026-04-02)
   CSS layer cleanup: each section now lives in its
   correct ownership layer per CLAUDE.md rules.
   ============================================ */
/* ============================================
   18. ICON SIZES
   ============================================ */

.p4-icon-xs { font-size: 14px; }
.p4-icon-sm { font-size: 16px; }
.p4-icon-md { font-size: 20px; }
.p4-icon-lg { font-size: 24px; }
.p4-icon-xl { font-size: 48px; }

/* ============================================
   33. ANIMATION UTILITIES
   ============================================ */

.p4-animate-spin {
    animation: p4-spin 1s linear infinite;
}

.p4-animate-pulse {
    animation: p4-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.p4-animate-fade-in {
    animation: p4-fade-in 0.3s ease-out;
}

@keyframes p4-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes p4-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   36. MARGIN UTILITY
   ============================================ */

.p4-my-4 {
    margin-top: 16px;
    margin-bottom: 16px;
}

/* ============================================
   37. TYPOGRAPHY SYSTEM
   ============================================

   Consistent text styles across the application.
   Use these classes for headings, body text, and captions.
*/

/* Page Title - headline-large */
.p4-title-page {
    font-size: var(--p4-headline-large);
    font-weight: 600;
    color: var(--p4-text-primary, #1A202C);
    margin: 0;
    line-height: 1.3;
}

/* Section Title - title-large */
.p4-title-section {
    font-size: var(--p4-title-large);
    font-weight: 600;
    color: var(--p4-text-primary, #1A202C);
    margin: 0;
    line-height: 1.4;
}

/* Card Title - title-medium */
.p4-title-card {
    font-size: var(--p4-title-medium);
    font-weight: 600;
    color: var(--p4-text-primary, #1A202C);
    margin: 0;
    line-height: 1.4;
}

/* Body Text - body-medium */
.p4-text-body {
    font-size: var(--p4-body-medium);
    font-weight: 400;
    color: var(--p4-text-secondary, #4A5568);
    line-height: 1.5;
}

/* Small Text - body-small */
.p4-text-small {
    font-size: var(--p4-body-small);
    font-weight: 400;
    color: var(--p4-text-secondary, #4A5568);
    line-height: 1.5;
}

/* Caption - label-medium, uppercase */
.p4-text-caption {
    font-size: var(--p4-label-medium);
    font-weight: 500;
    color: var(--p4-text-muted, #A0AEC0);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Description - used under titles */
.p4-description {
    font-size: 14px;
    color: var(--p4-text-muted, #718096);
    margin: 0;
}

/* ============================================
   38. CONTAINER SYSTEM
   ============================================ */

/* Page Container - max width with padding */
.p4-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Content Container - card-like wrapper */
.p4-content {
    background: var(--p4-surface);
    border: 1px solid var(--p4-outline-variant);
    border-radius: var(--p4-shape-large);
    box-shadow: var(--p4-elevation-1);
}

/* Section - grouped content area */
.p4-section {
    padding: 24px;
}

.p4-section + .p4-section {
    border-top: 1px solid var(--p4-border-gray, #E2E8F0);
}

/* ============================================
   42. ICON SIZES (Syncfusion e-icons)
   ============================================ */

.p4-icon-sm .e-icons,
.e-icons.p4-icon-sm {
    font-size: 18px;
}

.p4-icon-lg .e-icons,
.e-icons.p4-icon-lg {
    font-size: 28px;
}

.p4-icon-xl .e-icons,
.e-icons.p4-icon-xl {
    font-size: 48px;
}

/* ============================================
   STATIC VALUE / READONLY DISPLAY
   ============================================ */

.p4-static-value {
    font-size: 14px;
    color: var(--p4-on-surface, #1E293B);
    line-height: 1.5;
}

/* Read-only inline value displayed in place of an input field — used inside
   <P4FormField> when the value is not editable. min-height matches Syncfusion
   input height so the row aligns with adjacent SfTextBox/SfDropDownList. */
.p4-form-static {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    font-size: 14px;
    color: var(--ds-on-surface, #1E293B);
    line-height: 1.5;
}

/* ── Input states: Readonly (gray shadow) vs Editable (blue shadow) ── */

/* Readonly inputs: gray background + gray shadow */
.p4-input-readonly {
    opacity: 0.85;
}
.p4-input-readonly.e-input-group,
.p4-input-readonly.e-control-wrapper {
    background-color: var(--ds-surface-variant, #f1f5f9) !important;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Locked (set-once) fields: light blue background, full-opacity black text */
.p4-input-locked.e-control-wrapper,
.p4-input-locked.e-input-group,
.p4-input-locked.e-date-wrapper {
    background-color: rgba(26, 86, 219, 0.06) !important;
    border-color: rgba(26, 86, 219, 0.28) !important;
    opacity: 1 !important;
}
.p4-input-locked input.e-input,
.p4-input-locked span.e-input-value {
    color: var(--ds-on-surface, #111827) !important;
    -webkit-text-fill-color: var(--ds-on-surface, #111827) !important;
    background-color: transparent !important;
}
.p4-input-locked .e-input-group-icon {
    opacity: 0.45;
}
.p4-input-readonly > input.e-input {
    background-color: transparent !important;
    cursor: default;
}


/* Link field — entity reference shown as clickable link (no input box) */
.p4-link-field {
    display: flex;
    align-items: center;
    min-height: 32px;
    gap: 8px;
}

/* Sub-item rows in totals (e.g., tax breakdown) */
.p4-totals-sub {
    font-size: 13px;
    color: var(--p4-outline, #64748B);
    padding: 0 0 0 4px;
}

/* ============================================
   CHECKBOX ACCENT
   ============================================ */

.p4-checkbox {
    accent-color: var(--p4-primary, #1976D2);
}

/* ============================================
   FONT UTILITIES (mono, medium)
   ============================================ */

.p4-font-mono {
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
    font-size: 13px;
}

/* ============================================
   VISIBILITY UTILITIES
   ============================================ */

/* Hide a native <input type="file"> so a styled Browse button can trigger it via JS. */
.hidden-file-input {
    display: none;
}

