html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

a, .btn-link {
    color: #006bb7;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Logo Preview Styles */
.logo-preview-container {
    display: inline-block;
    padding: 16px;
    border-radius: 12px;
    min-width: 220px;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-preview-checkerboard {
    background-image:
        linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
        linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
        linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #f5f5f5;
}

.logo-preview-transparent {
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    border: 1px dashed #bdbdbd;
}

.logo-preview-container img {
    max-width: 200px;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
}

/* Mini Logo Preview para el panel lateral */
.logo-preview-mini {
    max-width: 120px;
    max-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-preview-mini img {
    max-width: 100%;
    max-height: 60px;
    object-fit: contain;
}

/* Logo Header Preview (PDF Simulation) */
.logo-header-container {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.logo-header-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.logo-header-placeholder {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Drawer Styles */
.mud-drawer {
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

/* Dark mode drawer border */
.mud-theme-dark .mud-drawer {
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
}

/* Drawer Header */
.drawer-header {
    background: linear-gradient(135deg, rgba(25, 118, 210, 0.03) 0%, rgba(25, 118, 210, 0.08) 100%);
    border-bottom: 1px solid rgba(25, 118, 210, 0.15);
}

.mud-theme-dark .drawer-header {
    background: linear-gradient(135deg, rgba(25, 118, 210, 0.08) 0%, rgba(25, 118, 210, 0.15) 100%);
    border-bottom: 1px solid rgba(25, 118, 210, 0.25);
}

/* Collapse Button with Animation */
.collapse-button {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    border-radius: 8px !important;
}

.collapse-button:hover {
    background-color: rgba(25, 118, 210, 0.12) !important;
    transform: translateX(-2px) scale(1.05);
}

.collapse-button:active {
    transform: translateX(-2px) scale(0.95);
}

/* Add pulse animation on hover */
@keyframes pulse-shadow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(25, 118, 210, 0.3);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(25, 118, 210, 0);
    }
}

.collapse-button:hover {
    animation: pulse-shadow 1.5s infinite;
}

/* NavMenu Scrollbar Styling */
.mud-navmenu {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom Scrollbar for Drawer */
.mud-navmenu::-webkit-scrollbar {
    width: 6px;
}

.mud-navmenu::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
}

.mud-navmenu::-webkit-scrollbar-thumb {
    background: rgba(25, 118, 210, 0.2);
    border-radius: 3px;
}

.mud-navmenu::-webkit-scrollbar-thumb:hover {
    background: rgba(25, 118, 210, 0.4);
}

.mud-theme-dark .mud-navmenu::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

.mud-theme-dark .mud-navmenu::-webkit-scrollbar-thumb {
    background: rgba(25, 118, 210, 0.3);
}

.mud-theme-dark .mud-navmenu::-webkit-scrollbar-thumb:hover {
    background: rgba(25, 118, 210, 0.5);
}

/* Nav Links Hover Effect */
.mud-nav-link:hover {
    background-color: rgba(25, 118, 210, 0.08) !important;
}

.mud-theme-dark .mud-nav-link:hover {
    background-color: rgba(25, 118, 210, 0.15) !important;
}

/* Active Nav Link */
.mud-nav-link.active {
    background-color: rgba(25, 118, 210, 0.12) !important;
    border-left: 3px solid var(--mud-palette-primary);
}

.mud-theme-dark .mud-nav-link.active {
    background-color: rgba(25, 118, 210, 0.2) !important;
}

/* Drawer FAB Container */
.drawer-fab-container {
    position: fixed;
    left: 20px;
    bottom: 80px;
    z-index: 1400;
    animation: slideInFromLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInFromLeft {
    from {
        transform: translateX(-100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Drawer FAB Button Styles */
.drawer-fab-button {
    box-shadow: 0 6px 16px rgba(25, 118, 210, 0.5) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    animation: fab-pulse 2s ease-in-out infinite;
}

.drawer-fab-button:hover {
    box-shadow: 0 8px 24px rgba(25, 118, 210, 0.7) !important;
    transform: scale(1.15) translateX(6px);
    animation: none; /* Stop pulse on hover */
}

.drawer-fab-button:active {
    transform: scale(0.95) translateX(6px);
}

/* Pulse animation for FAB */
@keyframes fab-pulse {
    0%, 100% {
        box-shadow: 0 6px 16px rgba(25, 118, 210, 0.5);
    }
    50% {
        box-shadow: 0 8px 24px rgba(25, 118, 210, 0.7);
    }
}

/* Drawer and Main Content Smooth Transitions */
.custom-drawer {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s ease !important;
}

.custom-main-content {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Improve drawer elevation when open */
.custom-drawer.mud-drawer-open {
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.08);
}

.mud-theme-dark .custom-drawer.mud-drawer-open {
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.3);
}

/* Gap class utility for older browsers */
.gap-2 {
    gap: 8px;
}

/* Responsive adjustments for mobile */
@media (max-width: 960px) {
    .floating-drawer-toggle {
        left: 12px;
        top: 72px;
    }

    .drawer-fab {
        width: 40px !important;
        height: 40px !important;
    }
}

/* ===============================================
   FACTURACIÓN PAGE - RESPONSIVE STYLES
   =============================================== */

/* Ensure MudSelect dropdowns don't overflow on mobile */
.mud-select-input {
    font-size: 14px !important;
}

.mud-select-item {
    font-size: 13px !important;
    white-space: normal !important;
    line-height: 1.3 !important;
    padding: 8px 12px !important;
}

/* Responsive spacing utilities */
@media (min-width: 600px) {
    .spacing-sm-3 {
        gap: 12px !important;
    }
    .spacing-sm-6 {
        gap: 24px !important;
    }
}

/* Mobile-specific adjustments for Facturacion page */
@media (max-width: 599px) {
    /* Reduce card elevation on mobile for cleaner look */
    .mud-card {
        box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important;
    }

    /* Make helper text smaller on mobile */
    .mud-input-helper-text {
        font-size: 11px !important;
    }

    /* Ensure form labels don't overflow */
    .mud-input-label {
        font-size: 13px !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        line-height: 1.3 !important;
    }

    /* Compact chip sizing */
    .mud-chip-small {
        height: 24px !important;
        font-size: 12px !important;
    }

    /* Optimize button spacing on mobile */
    .mud-button-root {
        font-size: 14px !important;
    }

    /* Better spacing for BrandedHeader text */
    .mud-text {
        word-break: break-word;
        overflow-wrap: break-word;
    }
}

/* Tablet-specific adjustments (600px - 959px) */
@media (min-width: 600px) and (max-width: 959px) {
    /* Wider container for better field width */
    .mud-container-maxwidth-lg {
        max-width: 100% !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    /* Gentler approach: Let MudGrid work naturally, just adjust MudItem widths */
    .mud-grid {
        display: flex !important;
        flex-wrap: wrap !important;
    }

    /* Target MudItem elements specifically (they have classes like mud-grid-item-xs-12) */
    .mud-grid > [class*="mud-grid-item"] {
        padding: 8px !important;
        box-sizing: border-box !important;
    }

    /* Override for Email field - 7th MudItem */
    .mud-grid > [class*="mud-grid-item"]:nth-child(7) {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Override for Submit button - 8th MudItem */
    .mud-grid > [class*="mud-grid-item"]:nth-child(8) {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Don't override input styling - let MudBlazor handle it naturally */

    /* Reduce card content padding to give more space for inputs */
    .mud-card-content.px-3 {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .mud-card-content.px-sm-4 {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    /* FIX: Force MudBlazor components to expand to full width in their grid cells */
    .mud-grid > * > .mud-input-control {
        width: 100% !important;
        display: block !important;
    }

    /* Ensure the input itself takes full width */
    .mud-grid > * > .mud-input-control > .mud-input-control-input-container {
        width: 100% !important;
    }

    /* Make sure outlined inputs expand fully */
    .mud-grid > * .mud-input-outlined {
        width: 100% !important;
    }

    /* Fix for MudSelect specifically - ensure it fills container */
    .mud-grid > * .mud-select {
        width: 100% !important;
    }

    .mud-grid > * .mud-select .mud-input-control {
        width: 100% !important;
    }
}

/* Desktop-specific adjustments (960px+) */
@media (min-width: 960px) {
    /* Center container and distribute fields */
    .mud-container-maxwidth-lg {
        max-width: 1280px !important;
        margin-left: auto !important;
        margin-right: auto !important;
        padding-left: 24px !important;
        padding-right: 24px !important;
    }

    /* Ensure 3 columns layout with proper distribution */
    .mud-grid {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
    }

    .mud-grid-item-md-4 {
        flex-basis: calc(33.333% - 16px) !important;
        max-width: calc(33.333% - 16px) !important;
    }
}


/* Improve MudSelect dropdown positioning on small screens */
@media (max-width: 599px) {
    .mud-popover {
        max-width: calc(100vw - 32px) !important;
        left: 16px !important;
        right: 16px !important;
    }

    .mud-list {
        max-height: 280px !important;
    }
}

/* Prevent horizontal scroll on mobile */
html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
}

/* Ensure containers don't overflow */
.mud-container {
    max-width: 100% !important;
}

/* Better touch targets for mobile */
@media (max-width: 599px) {
    .mud-button-root,
    .mud-icon-button {
        min-height: 44px !important;
        min-width: 44px !important;
    }
}

/* Stack navigation buttons vertically on very small screens */
@media (max-width: 380px) {
    .mud-button-root.mud-button-text {
        font-size: 13px !important;
        padding: 8px 12px !important;
    }
}

/* ===============================================
   PUBLIC LAYOUT - RESPONSIVE STYLES
   =============================================== */

/* AppBar adjustments for mobile */
@media (max-width: 599px) {
    .public-header {
        padding: 0 8px !important;
    }

    /* Reduce AppBar height slightly on mobile */
    .public-header .mud-appbar-content {
        min-height: 56px !important;
        padding: 4px 0 !important;
    }

    /* Compact icon buttons in header */
    .public-header .mud-icon-button {
        width: 40px !important;
        height: 40px !important;
        padding: 8px !important;
    }

    /* Ensure title doesn't overflow */
    .public-header .mud-typography {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 180px;
    }
}

/* Tablet adjustments */
@media (min-width: 600px) and (max-width: 959px) {
    .public-header .mud-typography {
        max-width: 300px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Footer responsive adjustments */
@media (max-width: 599px) {
    .mud-appbar-bottom {
        padding: 0 8px !important;
    }

    .mud-appbar-bottom .mud-container {
        padding: 4px 8px !important;
    }

    .mud-appbar-bottom .mud-typography {
        white-space: nowrap;
    }
}

/* Ensure tooltips work well on mobile */
.mud-tooltip {
    z-index: 1500 !important;
}

/* Improve touch targets in public header */
@media (max-width: 599px) {
    .public-header .mud-button-root,
    .public-header .mud-icon-button {
        min-width: 40px !important;
        min-height: 40px !important;
    }

    /* Reduce margin between header items */
    .public-header .ml-2 {
        margin-left: 4px !important;
    }

    .public-header .mr-3 {
        margin-right: 8px !important;
    }
}

/* Main content padding adjustments */
@media (max-width: 599px) {
    .mud-main-content {
        margin-bottom: 60px !important;
    }
}

/* Prevent layout shift when scrolling on mobile */
.public-header,
.mud-appbar-bottom {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* ===============================================
   BREADCRUMB - APPBAR STYLES
   =============================================== */

/* Breadcrumb styling for better visibility in AppBar */
.breadcrumb-appbar .mud-breadcrumbs-separator {
    color: rgba(255, 255, 255, 0.7) !important;
    margin: 0 8px !important;
}

.breadcrumb-appbar .mud-breadcrumb-item {
    color: rgba(255, 255, 255, 0.9) !important;
}

.breadcrumb-appbar .mud-breadcrumb-item:hover {
    color: rgba(255, 255, 255, 1) !important;
}

.breadcrumb-appbar .mud-breadcrumb-item a {
    color: rgba(255, 255, 255, 0.85) !important;
    text-decoration: none !important;
    transition: color 0.2s ease;
}

.breadcrumb-appbar .mud-breadcrumb-item a:hover {
    color: rgba(255, 255, 255, 1) !important;
    text-decoration: underline !important;
}

/* Current page in breadcrumb (last item) */
.breadcrumb-appbar .mud-breadcrumb-item:last-child {
    color: white !important;
    font-weight: 500 !important;
}

/* Dark mode adjustments */
.mud-theme-dark .breadcrumb-appbar .mud-breadcrumb-item {
    color: rgba(255, 255, 255, 0.95) !important;
}

.mud-theme-dark .breadcrumb-appbar .mud-breadcrumb-separator {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* ===============================================
   FIX: Prevent duplicate labels at any resolution
   =============================================== */

/* Mobile-only and desktop-only visibility classes */
/* Mobile only: visible < 600px, hidden >= 600px */
.mobile-only {
    display: block !important;
}

.desktop-only {
    display: none !important;
}

/* Desktop (>= 600px): hide mobile, show desktop */
@media (min-width: 600px) {
    .mobile-only {
        display: none !important;
    }

    .desktop-only {
        display: block !important;
    }
}

/* Ensure MudHidden works correctly - force display none when needed */
.mud-hidden {
    display: none !important;
}

/* Additional safety: ensure d-block/d-none Bootstrap classes work */
@media (max-width: 599px) {
    .d-sm-block,
    .d-sm-flex,
    .d-md-block,
    .d-md-flex {
        display: none !important;
    }
}

@media (min-width: 600px) and (max-width: 959px) {
    .d-block.d-sm-none,
    .d-flex.d-sm-none {
        display: none !important;
    }

    .d-md-block,
    .d-md-flex {
        display: none !important;
    }
}

@media (min-width: 960px) {
    .d-block.d-sm-none,
    .d-flex.d-sm-none,
    .d-block.d-md-none,
    .d-flex.d-md-none {
        display: none !important;
    }
}