/* ============================================================
   HHpro - Base Styles
   ------------------------------------------------------------
   CSS variables, reset, typography, and shared components used
   across every view. All other CSS files build on these.
   ============================================================ */

:root {
    /* ---- Dark mode palette ----
       Surface hierarchy (darkest -> brightest):
         --color-bg-dark  : deep saturated dark (sticky sub-headers,
                            inset wells under cards)
         --color-bg       : page background (default canvas behind cards)
         --color-surface  : cards, modals, table cells, form inputs
       Brand blue is reserved for the top app header + buttons so it
       reads as the action / brand surface, separate from the neutral
       dark page chrome.
    */

    /* Colors - surfaces */
    --color-bg: #0f172a;
    --color-bg-dark: #0a1220;
    --color-surface: #1e293b;
    --color-border: #2a3a52;
    --color-border-strong: #475569;

    /* Colors - text (high contrast on dark surfaces) */
    --color-text: #e6edf3;
    --color-text-muted: #94a3b8;
    --color-text-inverse: #ffffff;

    /* Colors - brand (kept the same brand blue so the favicon/logo
       stay coherent; hover/light variants tuned for dark backgrounds) */
    --color-primary: #0f4c75;
    --color-primary-hover: #1a6090;
    --color-primary-light: #5ba9d8;

    /* Colors - semantic (slightly more vibrant on dark backgrounds) */
    --color-error: #ef4444;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-row-hover: #2a3b54;

    /* Projects compact tile gradient (the colored action card on the
       overview page; product tiles use their JPG, no background color). */
    --tile-projects: #2c3e50;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.5rem;
    --font-size-xxl: 2rem;

    /* Spacing scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-xxl: 48px;

    /* Borders & radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-med: 250ms ease;
}

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

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    /* Disable outer page scroll so each view controls its own scrolling.
       Main view scrolls inside .app-main; product view scrolls inside
       .schedule-wrap (header + filters stay pinned above). */
    overflow: hidden;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#app-root {
    height: 100%;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 600;
    line-height: 1.25;
}

p {
    margin: 0;
}

button {
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    padding: 0;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    /* Dark-mode defaults so native form controls don't fall back to
       the user-agent's white background and dark text. Class-based
       overrides (e.g. transparent inputs on the schedule) win because
       a single class beats an element selector. */
    background-color: var(--color-surface);
    color: var(--color-text);
}

input::placeholder, textarea::placeholder {
    color: var(--color-text-muted);
    opacity: 0.6;
}

/* ============================================================
   Inline icons
   ------------------------------------------------------------
   SVGs returned by HHpro.UI.icon() get .icon. They size to 1em so
   they follow the surrounding font-size automatically; flex-shrink
   keeps them from squashing in tight buttons.
   ============================================================ */
.icon {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    /* Slight optical lift so the stroke baseline aligns with the
       cap-height of adjacent text rather than the descender. */
    vertical-align: -0.125em;
}

/* Shared button component */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: background-color var(--transition-fast),
                transform var(--transition-fast);
    white-space: nowrap;
}

/* Press feedback: tiny scale-down on active for any button that
   isn't using its transform for layout positioning (cart-toggle,
   tile lift, login shake all manage their own transforms). The
   ":not(:disabled)" guard prevents disabled buttons from twitching. */
.btn:active:not(:disabled),
.action-btn:active:not(:disabled),
.modal-btn:active:not(:disabled),
.projects-btn:active:not(:disabled),
.project-card-btn:active:not(:disabled),
.cart-item-btn:active:not(:disabled),
.docs-item-action:active:not(:disabled),
.product-back-btn:active:not(:disabled),
.header-action:active:not(:disabled),
.docs-modal-close:active:not(:disabled),
.cart-panel-close:active:not(:disabled) {
    transform: scale(0.96);
}

/* Buttons that contain an icon + text (or a standalone icon) need
   inline-flex layout so the icon and label align cleanly. This is
   the single rule that unifies the behavior across the app's button
   families instead of repeating it per file. */
.action-btn,
.modal-btn,
.projects-btn,
.project-card-btn,
.cart-item-btn,
.docs-item-action,
.product-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-text-inverse);
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
}

.btn-primary:disabled {
    background-color: var(--color-border-strong);
    cursor: not-allowed;
}

/* App-level header (main view and product view both use this).
   Uses the brand primary color so the top of every page carries the
   HHpro identity; sub-headers (cart panel, files-tree blocks) keep
   the neutral dark surface to stay quieter. */
.app-header {
    background-color: var(--color-primary);
    color: var(--color-text-inverse);
    padding: var(--space-md) var(--space-xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.app-header-brand {
    font-size: var(--font-size-xl);
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* ============================================================
   Brand wordmark
   ------------------------------------------------------------
   Shared between the login title, the main header, and the
   product/projects breadcrumb. Inherits font-size from the
   parent (.app-header-brand, .breadcrumb-link, .login-title)
   so each surface controls its own scale. The "HH" half uses
   currentColor so it picks up white on dark headers and the
   primary blue on the white login card; "pro" stays in the
   lighter brand accent on every surface.
   ============================================================ */
.brand-logo {
    display: inline-flex;
    align-items: baseline;
    /* Tighter than the previous 0.5-1px tracking because wordmarks
       read better when letters sit close together. */
    letter-spacing: -0.01em;
    line-height: 1;
}

.brand-mark {
    color: currentColor;
    font-weight: 700;
}

.brand-accent {
    color: var(--color-primary-light);
    font-weight: 500;
    /* Slight optical correction so "pro" doesn't feel glued to the H */
    margin-left: 0.04em;
}

.header-action {
    color: var(--color-text-inverse);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: background-color var(--transition-fast),
                transform var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.header-action:hover {
    background-color: rgba(255, 255, 255, 0.12);
}

/* Breadcrumb in the header */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.breadcrumb-link {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-text-inverse);
    cursor: pointer;
    transition: opacity var(--transition-fast);
    padding: 4px 0;
    letter-spacing: 0.5px;
}

.breadcrumb-link:hover {
    opacity: 0.85;
}

.breadcrumb-sep {
    color: rgba(255, 255, 255, 0.5);
    font-size: var(--font-size-lg);
}

.breadcrumb-current {
    font-size: var(--font-size-base);
    color: rgba(255, 255, 255, 0.9);
}

/* Main content area - default is "scroll internally if content is tall".
   Individual views can override this if they want to manage scroll differently
   (e.g. product view uses overflow: hidden and puts scrolling on the table). */
.app-main {
    flex: 1;
    padding: var(--space-xl);
    overflow: auto;
    min-height: 0;
}

/* Utility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}