/* ── Self-hosted Nunito (fallback body font) ─────── */
@font-face {
    font-family: 'Nunito';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('fonts/nunito-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329;
}
@font-face {
    font-family: 'Nunito';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('fonts/nunito-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+FEFF, U+FFFD;
}

/* ── Design tokens ─────────────────────────────────── */
:root {
    --color-primary:        #5FA8B8;
    --color-primary-dark:   #4A95A6;
    --color-primary-light:  #A8D5DF;
    --color-dark-blue:      #3A6F8F;
    --color-aqua:           #7ED1C6;
    --color-beige:          #F2E4CC;
    --color-bg:             #EDF5F8;
    --color-surface:        #FFFFFF;
    --color-border:         #C8E6EE;
    --color-text:           #2D3748;
    --color-text-muted:     #718096;
    --color-drawer:         #3A6F8F;
    --color-drawer-text:    #FFFFFF;
    --color-error:          #E53E3E;
    --radius-sm:            8px;
    --radius-md:            12px;
    --radius-lg:            16px;
    --radius-xl:            20px;
    --shadow-card:          0 2px 12px rgba(58,111,143,0.10);
    --shadow-card-hover:    0 6px 24px rgba(58,111,143,0.18);
    --shadow-lg:            0 16px 48px rgba(58,111,143,0.20);
}

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

html, body {
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: 'DM Sans', 'Nunito', sans-serif;
}

/* ── Typography ──────────────────────────────────────── */
.font-poppins { font-family: 'Poppins', sans-serif !important; }

h1, h2, h3, h4, h5, h6 {
    font-family: 'Poppins', sans-serif;
    color: var(--color-dark-blue);
}

/* ── MudBlazor overrides ────────────────────────────── */
.mud-layout {
    height: 100vh !important;
    overflow: hidden !important;
}

.mud-appbar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1201 !important;
}

/* Main content — reactive margin owned by AppDrawer <style> tag,
   this fallback applies before hydration */
.mud-main-content {
    padding-top: 64px !important;
    margin-left: var(--nav-margin-left, 56px) !important;
    height: 100vh !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
    background: var(--color-bg) !important;
}

.mud-drawer { height: 100vh !important; }
.mud-drawer-content {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Tables */
.mud-table-cell { color: var(--color-text) !important; }
.mud-table-row:hover .mud-table-cell { background: rgba(95,168,184,0.06) !important; }
.mud-table-pagination { background: var(--color-surface) !important; border-top: 1px solid var(--color-border) !important; }
.mud-table-pagination .mud-typography,
.mud-table-pagination p { color: var(--color-text-muted) !important; }
.mud-table-pagination .mud-icon-button { color: var(--color-text-muted) !important; }
.mud-table-pagination .mud-icon-button:not([disabled]):hover { color: var(--color-primary) !important; }
.mud-table-pagination .mud-icon-button[disabled] { opacity: 0.3 !important; }

/* Nav links (on dark blue drawer bg) */
.mud-nav-link { border-radius: var(--radius-sm) !important; margin: 2px 8px !important; }
.mud-nav-link:hover { background: rgba(255,255,255,0.12) !important; }
.mud-nav-link.active { background: rgba(255,255,255,0.22) !important; }
.mud-nav-link.active .mud-nav-link-text { color: #FFFFFF !important; font-weight: 600 !important; }

/* Inputs */
.mud-input-label { color: var(--color-text-muted) !important; }
.mud-input-outlined .mud-notched-outline { border-color: var(--color-border) !important; border-radius: var(--radius-md) !important; }
.mud-input-outlined:hover .mud-notched-outline { border-color: var(--color-primary) !important; }
.mud-input-outlined.mud-focused .mud-notched-outline { border-color: var(--color-primary) !important; }
.mud-input { color: var(--color-text) !important; }
.mud-select-input { color: var(--color-text) !important; }

/* Cards */
.mud-card { border-radius: var(--radius-lg) !important; box-shadow: var(--shadow-card) !important; }
.mud-paper { border-radius: var(--radius-md) !important; }

/* Buttons */
.mud-button-root { border-radius: var(--radius-md) !important; }
.mud-icon-button { border-radius: var(--radius-sm) !important; }

/* ── Page layout ──────────────────────────────────── */
.page-content {
    padding: clamp(12px, 2.5vw, 24px);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Card utility ──────────────────────────────────── */
.card-light {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 16px;
}

/* Keep .card-dark as alias so existing pages don't break */
.card-dark {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 16px;
}

/* ── Sales dock ─────────────────────────────────────── */
.sales-layout {
    display: flex;
    height: calc(100vh - 120px);
    gap: 12px;
    overflow: hidden;
}

.sales-products {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.sales-cart {
    width: clamp(240px, 28vw, 320px);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

@media (max-width: 767px) {
    .sales-layout {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    .sales-cart { width: 100%; }
    .page-header { margin-bottom: 16px; }
}

/* ── Login page ─────────────────────────────────────── */
.login-bg {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 25% 65%, #A8D5DF 0%, #5FA8B8 45%, #3A6F8F 100%);
}

/* Blur overlay between background and card */
.login-blur-layer {
    position: fixed;
    inset: 0;
    backdrop-filter: blur(2px);
    z-index: 0;
    pointer-events: none;
}

.login-card {
    position: relative;
    z-index: 2;
    overflow: visible;
    background: rgba(255, 255, 255, 0.90);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(95, 168, 184, 0.25);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

@keyframes logoFloat {
    0%   { opacity: 0; transform: translateY(-24px) scale(0.92); }
    60%  { opacity: 1; transform: translateY(4px) scale(1.02); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes logoPulse {
    0%, 100% { filter: drop-shadow(0 0 12px rgba(95,168,184,0.50)); }
    50%       { filter: drop-shadow(0 0 22px rgba(95,168,184,0.80)); }
}
.login-logo {
    animation: logoFloat 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               logoPulse 3s ease-in-out 1s infinite;
}

/* ── Product cards (Sales Point) ────────────────────── */
.product-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    min-height: clamp(130px, 18vw, 160px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 2vw, 14px) 8px;
    text-align: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.product-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-1px);
}
.product-card:active { transform: scale(0.97); }
.product-card.in-cart {
    border-color: var(--color-primary);
    background: rgba(168,213,223,0.18);
    box-shadow: 0 0 0 2px rgba(95,168,184,0.3);
}

/* ── Production counter ─────────────────────────────── */
.production-counter {
    font-family: 'Poppins', sans-serif;
    font-size: clamp(4rem, 12vw, 8rem);
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
    text-shadow: 0 0 40px rgba(95,168,184,0.30);
}

/* ── Generic helpers ────────────────────────────────── */
.text-danger { color: var(--color-error); }

/* ── Blazor error boundary ──────────────────────────── */
.blazor-error-boundary {
    background: var(--color-error);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: var(--radius-md);
}
.blazor-error-boundary::after { content: "Ha ocurrido un error." }

#blazor-error-ui {
    background: var(--color-error);
    bottom: 0;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: white;
}
#blazor-error-ui .dismiss { cursor: pointer; color: white; float: right; font-weight: bold; }
#blazor-error-ui .reload  { color: white; text-decoration: underline; cursor: pointer; }

h1:focus { outline: none; }
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--color-aqua); }
.invalid { outline: 1px solid var(--color-error); }
.validation-message { color: var(--color-error); }
