/* T-Factory — Apple Engine Base Styles */

:root {
    /* Glassmorphism Variables */
    --glass-bg: var(--mud-palette-surface, rgba(26, 26, 26, 0.9));
    --glass-border: 1px solid var(--mud-palette-divider, rgba(255, 255, 255, 0.1));
    --glass-blur: blur(24px);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-radius: 12px;

    /* Interactive Elements */
    --accent-color: #0A84FF;
    /* iOS Blue */
    --accent-hover: #007AFF;

    /* WindowStack Variables */
    --stack-dim: rgba(0, 0, 0, 0.4);
}

/* Animations for Layer Navigation */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOutOverlay {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

body {
    background-color: var(--mud-palette-background, #000000);
    color: var(--mud-palette-text-primary, #F5F5F7);
    font-family: 'Roboto Flex', Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
}

/* Base Blazor styles */
h1:focus {
    outline: none;
}

code {
    color: #c9d1d9;
}

.blazor-error-boundary {
    background: #161B22;
    padding: 1rem 1rem 1rem 3.7rem;
    color: #F85149;
    border-radius: 8px;
    margin: 8px;
}

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

/* =========================================================================
   Global ErpField — Style 16 (Hybrid: Underline + Floating Label + Neumorphic)
   Copied 1:1 from FieldPlayground.razor, adapted for global use.
   Works with both dark and light themes via var(--mud-palette-*)
   ========================================================================= */

.var-hybrid {
    position: relative;
    margin-top: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.hybrid-underline {
    border-bottom: 1px solid rgba(127, 127, 127, 0.25);
    transition: border-color 0.3s ease;
    padding-bottom: 4px;
    position: relative;
}

.var-hybrid:hover .hybrid-underline {
    border-bottom-color: var(--mud-palette-primary);
    border-bottom-width: 2px;
}

.hybrid-label {
    position: absolute;
    left: 0;
    top: 2px;
    color: var(--mud-palette-text-secondary);
    font-size: 14px;
    font-weight: 400;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    padding: 0;
    border-radius: 4px;
    background: transparent;
    box-shadow: none;
    z-index: 2;
}

/* Filled state or hover state: label floats up AND gets neumorphic inset effect! */
.var-hybrid.group-filled .hybrid-label,
.var-hybrid:hover .hybrid-label {
    transform: translateY(-24px);
    left: 0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    opacity: 1;
    /* Neumorphic Inset Effect (адаптивний під обидві теми) */
    background: var(--mud-palette-background);
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.15), inset -2px -2px 5px rgba(255, 255, 255, 0.03);
    padding: 2px 8px;
}

.var-hybrid:hover .hybrid-label {
    color: var(--mud-palette-primary);
}

.hybrid-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 24px;
    position: relative;
    z-index: 1;
}

.hybrid-text {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--mud-palette-text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
}

.hybrid-text.placeholder {
    color: transparent;
}

/* Action buttons — appear on hover */
.hybrid-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.var-hybrid:hover .hybrid-actions,
.var-hybrid:focus-within .hybrid-actions {
    opacity: 1;
}

.hybrid-actions button {
    background: transparent;
    border: 1px solid transparent;
    color: var(--mud-palette-text-secondary);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease-out;
    padding: 0;
}

.hybrid-actions button:hover {
    background: var(--mud-palette-primary);
    color: white;
    transform: scale(1.1);
}

/* Plain HTML input inside hybrid — styled exactly like .hybrid-text */
.hybrid-input {
    background: transparent;
    border: none;
    outline: none;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--mud-palette-text-primary);
    flex: 1;
    min-width: 0;
    padding: 0;
    margin: 0;
    width: 100%;
    font-family: inherit;
}

.hybrid-input::-webkit-outer-spin-button,
.hybrid-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.hybrid-input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.hybrid-input::placeholder {
    color: var(--mud-palette-text-secondary);
    opacity: 0.5;
}

.hybrid-input:read-only {
    cursor: default;
}

/* =========================================================================
   Global ErpField — Style 2 (1C Classic)
   Compact, Gray Border, Square Buttons right attached
   ========================================================================= */

.var-1c-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    font-family: inherit;
    font-size: 13px;
    padding-bottom: 2px;
}

.var-1c-label {
    color: var(--mud-palette-text-primary);
    width: 150px;
    min-width: 150px;
    text-align: right;
    white-space: normal;
    padding-right: 8px;
    line-height: 1.1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.var-1c-input-group {
    display: flex;
    background: var(--mud-palette-surface);
    border: 1px solid #7f9db9;
    flex: 1;
    min-height: 24px;
    position: relative;
    border-radius: 2px;
}

.var-1c-input-group.input-number {
    flex: 0 0 auto;
    width: 120px;
}

.var-1c-input-group.input-date {
    flex: 0 0 auto;
    width: 110px;
}

.var-1c-wrapper-bool {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.var-1c-input-group input {
    border: none;
    padding: 2px 4px;
    flex: 1;
    outline: none;
    font-size: 13px;
    color: var(--mud-palette-text-primary);
    background: transparent;
    width: 100%;
    min-width: 0;
}

.var-1c-input-group button {
    border: none;
    border-left: 1px solid #7f9db9;
    background: #e3e3e3;
    cursor: pointer;
    padding: 0 6px;
    font-size: 12px;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s;
    height: 100%;
    min-height: 24px;
}

.var-1c-input-group button:hover {
    background: #d0d0d0;
}

/* =========================================================================
   Style 2 (1C Classic) Layout Overrides
   Applied to .erp-document-card and .erp-directory-card when ActiveFieldStyle == 2
   ========================================================================= */

.style-1c-card {
    background-color: #f2f2f2 !important;
    /* Classic 1C unified light grey background */
    border-radius: 0 !important;
    border: 1px solid #cccccc !important;
    padding: 8px !important;
    font-family: Arial, sans-serif !important;
}

.style-1c-card .mud-card-content {
    padding: 0 !important;
}

/* Force white background for all 1C inputs against the grey form */
.style-1c-card .var-1c-input-group {
    background-color: #ffffff !important;
    border: 1px solid #7f9db9 !important;
}

.style-1c-card .var-1c-input-group input {
    background-color: #ffffff !important;
    color: #000000 !important;
}

/* Remove excessive spacing and dark bands from expansion panels/headers */
.style-1c-card .mud-expand-panel {
    background-color: transparent !important;
    border: none !important;
    margin-bottom: 4px !important;
    box-shadow: none !important;
}

.style-1c-card .mud-expand-panel-header {
    padding: 4px 8px !important;
    min-height: 24px !important;
    border-bottom: 1px solid #e0e0e0 !important;
    background-color: #e8e8e8 !important;
    /* Slightly darker grey for category header */
}

.style-1c-card .mud-expand-panel-content {
    padding: 8px 0 0 0 !important;
}

/* Compact headers and titles */
.style-1c-card .mud-typography-h6 {
    font-size: 14px !important;
    font-weight: bold !important;
    color: #333333 !important;
}

/* Tabs simplification for 1C style */
.style-1c-card .mud-tabs-toolbar {
    background-color: #e8e8e8 !important;
    min-height: 32px !important;
    border-bottom: 1px solid #cccccc !important;
}

.style-1c-card .mud-tab {
    min-width: 80px !important;
    padding: 4px 12px !important;
    font-size: 12px !important;
    text-transform: none !important;
    color: #333333 !important;
}

.style-1c-card .mud-tab-active {
    background-color: #f2f2f2 !important;
    border-top: 2px solid #0078d7 !important;
    border-left: 1px solid #cccccc !important;
    border-right: 1px solid #cccccc !important;
    border-bottom: 1px solid #f2f2f2 !important;
    margin-bottom: -1px !important;
}

.style-1c-card .mud-tabs-panels {
    background-color: #f2f2f2 !important;
    padding: 8px 0 !important;
}

/* ═══ AGGRESSIVE BACKGROUND STRIPPING FOR 1C STYLE ═══ */
.style-1c-card .doc-actions-bar,
.style-1c-card .doc-header-wrapper,
.style-1c-card .doc-number-row,
.style-1c-card .doc-primary-grid,
.style-1c-card .doc-header-toggle,
.style-1c-card .tab-content-flex,
.style-1c-card .doc-table-header,
.style-1c-card .doc-secondary-grid,
.style-1c-card .directory-hero,
.style-1c-card .directory-field-group,
.style-1c-card .mud-card-content,
.style-1c-card .erp-tabs,
.style-1c-card .mud-tabs,
.style-1c-card .mud-tabs-panels {
    background-color: transparent !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* ═══ 1C TABLE STYLE ═══ */
/* Ensure the table itself has no background initially, letting the card's grey show */
.style-1c-card .mud-table {
    background: transparent !important;
}

.style-1c-card .mud-table-container {
    background: transparent !important;
}

/* Make table headers dark grey 1C style */
.style-1c-card .mud-table-head {
    background-color: #e8e8e8 !important;
    border-bottom: 1px solid #7f9db9 !important;
    border-top: 1px solid #7f9db9 !important;
}

.style-1c-card .mud-table-head th {
    color: #333333 !important;
    font-weight: bold !important;
    font-size: 12px !important;
    text-transform: none !important;
    padding: 4px 8px !important;
    border-right: 1px solid #cccccc !important;
}

/* Table rows should be white */
.style-1c-card .mud-table-body tr {
    background-color: #ffffff !important;
}

.style-1c-card .mud-table-body td {
    border-bottom: 1px solid #cccccc !important;
    border-right: 1px solid #cccccc !important;
    padding: 2px 4px !important;
    color: #000000 !important;
}

/* ═══ INPUT OVERRIDES FOR TABS & IN-CARD COMPONENTS ═══ */
.style-1c-card input[type="text"],
.style-1c-card input[type="number"] {
    background-color: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #7f9db9 !important;
}

/* ═══ REMOVE ALL ROUNDING (1C is square) ═══ */
.style-1c-card * {
    border-radius: 0 !important;
}

/* ═══ FIX HEADER/TABS HEIGHTS & PADDINGS FOR MAXIMUM COMPACTNESS ═══ */
.style-1c-card .doc-actions-bar {
    padding: 2px 4px !important;
    min-height: 28px !important;
    border-bottom: 1px solid #7f9db9 !important;
    background-color: #e8e8e8 !important;
    /* Action bar same as header */
}

.style-1c-card .doc-number-row {
    padding: 2px 4px !important;
    background-color: #e8e8e8 !important;
    border-bottom: 1px solid #7f9db9 !important;
}

.style-1c-card .doc-primary-grid {
    padding: 4px 4px 8px 4px !important;
    background-color: #f2f2f2 !important;
}

.style-1c-card .mud-button {
    font-size: 11px !important;
    padding: 2px 8px !important;
    min-height: 20px !important;
    border: 1px solid #a0a0a0 !important;
    background-color: #e3e3e3 !important;
    color: #000000 !important;
}

.style-1c-card .mud-button:hover {
    background-color: #d0d0d0 !important;
}

/* Specific fix for Primary/Success buttons to maintain some color but flat */
.style-1c-card .mud-button-filled-primary {
    background-color: #0078d7 !important;
    color: #ffffff !important;
    border-color: #005a9e !important;
}

.style-1c-card .mud-button-filled-success {
    background-color: #107c10 !important;
    color: #ffffff !important;
    border-color: #0b5a0b !important;
}

/* Fix for tab background */
.style-1c-card .mud-tabs {
    background-color: #f2f2f2 !important;
}

/* Directory Card Hero Overrides for 1C */
.style-1c-card .directory-hero {
    padding: 4px 8px !important;
    margin-bottom: 2px !important;
    background-color: #e8e8e8 !important;
    border-bottom: 1px solid #7f9db9 !important;
}

.style-1c-card .directory-hero>div {
    gap: 8px !important;
}

.style-1c-card .directory-hero div[style*="width: 64px"] {
    width: 24px !important;
    height: 24px !important;
    background: transparent !important;
    border-radius: 0 !important;
}

.style-1c-card .directory-hero .mud-typography-h5 {
    font-size: 14px !important;
    color: #333333 !important;
}

.style-1c-card .directory-hero .mud-input-root {
    font-size: 14px !important;
}

.style-1c-card .directory-hero .mud-chip {
    height: 20px !important;
    font-size: 10px !important;
}

/* Make category blocks in DirectoryCard seamlessly blend into the light grey */
.style-1c-card .directory-field-group {
    background-color: #f2f2f2 !important;
    border: none !important;
    padding: 0 !important;
}

.style-1c-card .directory-field-group .mud-grid {
    margin: 0 !important;
    width: 100% !important;
    padding: 4px !important;
}

.style-1c-card .directory-field-group .mud-grid-item {
    padding: 0 !important;
}