/* ==========================================
   WebTalep - Compact Flat Theme
   ========================================== */

/* Base resets */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    background: #f8fafc;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

/* ==========================================
   Global Border Radius Override
   ========================================== */
.mud-button,
.mud-icon-button,
.mud-fab,
.mud-chip,
.mud-paper,
.mud-card,
.mud-alert,
.mud-snackbar,
.mud-dialog,
.mud-menu,
.mud-popover-paper,
.mud-autocomplete,
.mud-select,
.mud-input,
.mud-input-control,
.mud-picker,
.mud-table,
.mud-tabs,
.mud-expansion-panel,
.mud-avatar,
.mud-badge .mud-badge-content,
.mud-tooltip {
    border-radius: 2px !important;
}

.mud-input-outlined .mud-input-outlined-border {
    border-radius: 2px !important;
}

/* ==========================================
   Compact Spacing
   ========================================== */
.mud-container {
    padding: 6px !important;
}

.mud-paper {
    padding: 6px;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.mud-card {
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    border: 1px solid #e2e8f0;
}

.mud-card-content {
    padding: 8px !important;
}

.mud-card-header {
    padding: 8px 8px 4px 8px !important;
}

.mud-card-actions {
    padding: 4px 8px !important;
}

/* ==========================================
   Compact Form Controls
   ========================================== */
.mud-input-control {
    margin-top: 2px !important;
    margin-bottom: 2px !important;
}

.mud-input {
    font-size: 0.875rem;
}

/* Base input slot - consistent height and vertical centering */
.mud-input-slot {
    font-size: 0.875rem !important;
    min-height: 36px !important;
    height: 36px;
    padding: 0 10px !important;
    display: flex !important;
    align-items: center !important;
    line-height: 1 !important;
}

.mud-input-outlined .mud-input-slot {
    padding: 0 12px !important;
}

/* Input text vertical alignment and full width */
.mud-input-slot input,
.mud-input-slot .mud-input-slot-text {
    line-height: 36px !important;
    height: 36px;
    padding: 0 !important;
    margin: 0 !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

/* Ensure all input container elements fill full width */
.mud-input-control,
.mud-input-root,
.mud-input,
.mud-input-slot,
.mud-input-control-input-container,
.mud-input-outlined,
.mud-input-outlined-border {
    width: 100% !important;
}

/* Fix outlined input background */
.mud-input-outlined .mud-input-slot {
    background: white !important;
}

/* Override browser autofill background colors */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px white inset !important;
    box-shadow: 0 0 0 30px white inset !important;
    -webkit-text-fill-color: inherit !important;
}

.mud-input-outlined input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px white inset !important;
}

/* Select - ensure text is vertically centered */
.mud-select .mud-input-slot {
    min-height: 36px !important;
    height: 36px;
}

.mud-select-input {
    display: flex !important;
    align-items: center !important;
    height: 100% !important;
    line-height: 1 !important;
    font-size: 0.875rem !important;
}

/* Autocomplete alignment */
.mud-autocomplete .mud-input-slot {
    min-height: 36px !important;
    height: 36px;
}

.mud-autocomplete .mud-input-slot input {
    height: 36px;
    line-height: 36px !important;
}

/* Date/Time picker alignment */
.mud-picker .mud-input-slot {
    min-height: 36px !important;
    height: 36px;
}

.mud-picker-input-text {
    display: flex !important;
    align-items: center !important;
    height: 100% !important;
    line-height: 1 !important;
    font-size: 0.875rem !important;
}

/* Numeric field alignment */
.mud-input-root-adorned-start .mud-input-slot,
.mud-input-root-adorned-end .mud-input-slot {
    min-height: 36px !important;
    height: 36px;
}

.mud-shrink {
    font-size: 0.75rem !important;
}

/* Input Labels - Proper positioning for floating labels */
.mud-input-label {
    font-size: 0.8125rem;
}

.mud-input-label:not(.mud-input-label-animated) {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.mud-input-label.mud-input-label-animated.mud-input-label-inputcontrol {
    top: 0;
}

/* Fix for filled variant label */
.mud-input-control-input-container .mud-input-label {
    transform-origin: top left;
}

.mud-input-filled .mud-input-slot {
    padding-top: 20px !important;
}

.mud-input-filled .mud-input-label:not(.mud-shrink) {
    top: 50%;
    transform: translateY(-50%);
}

.mud-input-filled .mud-input-label.mud-shrink {
    top: 8px;
    transform: translateY(0) scale(0.75);
}

/* Fix for outlined variant label */
.mud-input-outlined .mud-input-slot {
    min-height: 40px !important;
    height: auto;
}

.mud-input-outlined .mud-input-label:not(.mud-shrink) {
    top: 50%;
    transform: translateY(-50%);
    left: 12px;
}

.mud-input-outlined .mud-input-label.mud-shrink {
    top: 0;
    transform: translateY(-50%) scale(0.75);
    background: white;
    padding: 0 4px;
}

.mud-input-helper-text {
    font-size: 0.75rem;
    margin-top: 2px;
}

/* Dropdown list items */
.mud-list-item {
    padding: 6px 12px !important;
    min-height: 34px !important;
    font-size: 0.875rem;
}

.mud-list-item-icon {
    min-width: 32px !important;
}

/* ==========================================
   Compact Buttons
   ========================================== */
.mud-button-root {
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    box-shadow: none !important;
}

.mud-button-root:hover {
    box-shadow: none !important;
}

.mud-button-root.mud-button-size-small {
    padding: 4px 10px;
    font-size: 0.8125rem;
    min-width: unset;
}

.mud-button-root.mud-button-size-medium {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.mud-button-root.mud-button-size-large {
    padding: 8px 16px;
    font-size: 0.9375rem;
}

.mud-icon-button {
    padding: 6px;
}

.mud-icon-button.mud-button-size-small {
    padding: 4px;
}

/* Flat button styles */
.mud-button-filled {
    box-shadow: none !important;
}

.mud-button-outlined {
    border-width: 1px;
}

/* ==========================================
   Compact Tables
   ========================================== */
.mud-table {
    box-shadow: none;
    border: 1px solid #e2e8f0;
}

.mud-table-container {
    border-radius: 2px;
}

.mud-table-dense .mud-table-cell {
    padding: 6px 10px !important;
    font-size: 0.875rem;
    line-height: 1.4;
}

.mud-table-dense .mud-table-head .mud-table-cell {
    padding: 8px 10px !important;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.mud-table-row:hover {
    background-color: #f1f5f9 !important;
}

.mud-table-cell {
    border-bottom: 1px solid #f1f5f9;
}

/* Striped tables */
.mud-table-striped .mud-table-body .mud-table-row:nth-child(odd) {
    background-color: #fafbfc;
}

/* ==========================================
   Compact Chips
   ========================================== */
.mud-chip {
    font-size: 0.8125rem;
    height: 24px;
    font-weight: 500;
}

.mud-chip.mud-chip-size-small {
    height: 20px;
    font-size: 0.75rem;
}

.mud-chip-content {
    padding: 0 8px;
}

.mud-chip-icon {
    font-size: 0.875rem !important;
}

.mud-chip-close-button {
    margin-left: 2px;
    margin-right: -2px;
}

/* ==========================================
   Compact Dialogs
   ========================================== */
.mud-dialog {
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.mud-dialog-title {
    padding: 12px 16px !important;
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 1px solid #e2e8f0;
}

.mud-dialog-content {
    padding: 14px 16px !important;
    font-size: 0.875rem;
}

.mud-dialog-actions {
    padding: 10px 16px !important;
    border-top: 1px solid #e2e8f0;
    gap: 8px;
}

/* ==========================================
   Compact Tabs
   ========================================== */
.mud-tabs {
    min-height: unset;
}

.mud-tab {
    min-width: unset;
    padding: 8px 14px;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: none;
    min-height: 40px;
}

.mud-tabs-panels {
    padding: 10px 0;
}

/* ==========================================
   Compact Expansion Panels
   ========================================== */
.mud-expand-panel {
    margin: 0 !important;
    box-shadow: none !important;
    border: 1px solid #e2e8f0;
    border-bottom: none;
}

.mud-expand-panel:last-child {
    border-bottom: 1px solid #e2e8f0;
}

.mud-expand-panel-header {
    padding: 8px 10px !important;
    min-height: 36px !important;
}

.mud-expand-panel-content {
    padding: 8px 10px !important;
}

/* ==========================================
   Compact Alerts & Snackbars
   ========================================== */
.mud-alert {
    padding: 8px 12px;
    font-size: 0.875rem;
}

.mud-alert-icon {
    margin-right: 10px;
}

.mud-snackbar {
    padding: 8px 12px;
    font-size: 0.875rem;
    min-width: unset;
}

/* ==========================================
   Compact Date/Time Pickers
   ========================================== */
.mud-picker-content {
    padding: 8px;
}

.mud-picker-calendar-day {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
}

.mud-picker-calendar-header-day {
    font-size: 0.75rem;
}

/* ==========================================
   Compact Tooltips
   ========================================== */
.mud-tooltip {
    font-size: 0.8125rem;
    padding: 6px 10px;
}

/* ==========================================
   Compact Progress
   ========================================== */
.mud-progress-linear {
    height: 3px;
}

/* ==========================================
   Compact Pagination
   ========================================== */
.mud-pagination .mud-pagination-item {
    min-width: 28px;
    height: 28px;
    font-size: 0.75rem;
}

/* ==========================================
   Utility Classes
   ========================================== */
.cursor-pointer {
    cursor: pointer;
}

.cursor-pointer:hover {
    background-color: #f1f5f9;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: #64748b;
}

.text-small {
    font-size: 0.75rem;
}

.text-xs {
    font-size: 0.6875rem;
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.border-light {
    border: 1px solid #e2e8f0;
}

.bg-subtle {
    background-color: #f8fafc;
}

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* ==========================================
   Status Colors (flat variants)
   ========================================== */
.status-pending {
    background-color: #fef3c7;
    color: #92400e;
}

.status-approved {
    background-color: #dcfce7;
    color: #166534;
}

.status-rejected {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-processing {
    background-color: #dbeafe;
    color: #1e40af;
}

/* ==========================================
   Custom Components
   ========================================== */
.info-item {
    min-width: 70px;
}

.approval-progress {
    padding: 2px 0;
}

.filter-panel .mud-input-control {
    margin: 1px !important;
}

/* ==========================================
   Form Validation
   ========================================== */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #22c55e;
}

.invalid {
    outline: 1px solid #ef4444;
}

.validation-message {
    color: #ef4444;
    font-size: 0.6875rem;
}

/* ==========================================
   Error Boundary
   ========================================== */
.blazor-error-boundary {
    background: #fef2f2;
    border-left: 3px solid #ef4444;
    padding: 8px 12px;
    color: #991b1b;
    font-size: 0.8125rem;
}

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

/* ==========================================
   Fix MudSelect Double Scrollbar
   MudBlazor adds overflow-y-auto on .mud-popover AND on .mud-popover .mud-list,
   causing two nested scrollbars. Remove the outer one and let the list scroll.
   ========================================== */
.mud-popover.overflow-y-auto {
    overflow-y: hidden !important;
}

/* ==========================================
   Scrollbar Styling
   ========================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ==========================================
   Focus States (subtle)
   ========================================== */
h1:focus {
    outline: none;
}

.mud-input-control:focus-within .mud-input-outlined-border {
    border-color: #3b82f6 !important;
    border-width: 1px !important;
}

/* ==========================================
   Data Grid Compact
   ========================================== */
.mud-data-grid .mud-table-cell {
    padding: 6px 10px !important;
    font-size: 0.875rem;
}

.mud-data-grid .mud-table-toolbar {
    padding: 6px 10px;
    min-height: 44px;
}

/* ==========================================
   Menu Compact
   ========================================== */
.mud-menu-list {
    padding: 4px 0;
}

.mud-list-item-text {
    font-size: 0.875rem;
}

/* ==========================================
   Numeric Field Compact
   ========================================== */
.mud-input-adornment {
    font-size: 0.875rem;
}

.mud-input-adornment-start {
    margin-right: 6px;
}

.mud-input-adornment-end {
    margin-left: 6px;
}

/* ==========================================
   Product Group Selector
   ========================================== */
.product-group-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.product-group-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    min-width: 100px;
}

.product-group-item:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}

.product-group-item.selected {
    border-color: #3b82f6;
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.product-group-item img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin-bottom: 8px;
}

.product-group-name {
    font-size: 0.8125rem;
    font-weight: 500;
    text-align: center;
    color: #334155;
}

/* ==========================================
   Product Detail Panel (Sliding)
   ========================================== */
.product-detail-panel {
    position: fixed;
    top: 0;
    right: -75%;
    right: calc(-1 * min(75%, 600px));
    width: 75%;
    max-width: 600px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1300;
    transition: right 250ms cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-radius: 2px 0 0 2px;
}

.product-detail-panel.open {
    right: 0;
}

.product-detail-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}

.product-detail-panel .panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.product-detail-panel .panel-footer {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}

/* Product search popover styling */
.product-search-popover {
    max-height: 400px;
}

.product-search-popover .mud-list {
    max-height: 380px;
    overflow-y: auto;
}

/* ==========================================
   Approval Panel (Sliding)
   ========================================== */
.approval-panel {
    position: fixed;
    top: 0;
    right: -450px;
    width: 450px;
    max-width: 90vw;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1300;
    display: flex;
    flex-direction: column;
    transition: right 0.25s ease-in-out;
    outline: none;
    border-radius: 2px 0 0 2px;
}

.approval-panel.open {
    right: 0;
}

.approval-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}

.approval-panel .panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.approval-panel .history-list {
    max-height: calc(100vh - 450px);
    overflow-y: auto;
}
