/* =========================================================================
   AtlasPortal — shared design tokens & base component styles.

   Contains only tokens and primitives that belong to the product layer.
   Project-specific styling (feature pages, branded imagery, vendor-specific
   widgets) lives in the consuming project layer.
   ========================================================================= */

:root {
    /* Brand tokens */
    --ap-primary: #2563eb;
    --ap-primary-dark: #1d4ed8;
    --ap-secondary: #64748b;
    --ap-success: #059669;
    --ap-warning: #d97706;
    --ap-error: #dc2626;

    /* Surfaces */
    --ap-background: #f8fafc;
    --ap-surface: #ffffff;

    /* Text */
    --ap-text-primary: #1e293b;
    --ap-text-secondary: #64748b;

    /* Structure */
    --ap-border: #e2e8f0;
    --ap-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);

    /* Focus ring meets WCAG 2.2 Focus Appearance (1.4.11 / 2.4.11). */
    --ap-focus-outline: 3px solid #1d4ed8;
    --ap-focus-offset: 2px;
}

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

html {
    font-size: 90%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--ap-background);
    color: var(--ap-text-primary);
}

/* ---------- Accessibility ---------------------------------------------- */

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

/* Skip-link: WCAG 2.4.1 Bypass Blocks (A). */
.atlas-skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--ap-primary);
    color: #fff;
    padding: 8px 16px;
    text-decoration: none;
    font-weight: 600;
    z-index: 10000;
    border-bottom-right-radius: 6px;
}

.atlas-skip-link:focus {
    top: 0;
}

/* Focus indicator baseline — WCAG 2.4.7 (AA) & 2.4.11 (2.2 AA). */
:focus-visible {
    outline: var(--ap-focus-outline);
    outline-offset: var(--ap-focus-offset);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- Loading / spinner ----------------------------------------- */

.atlas-loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background-color: var(--ap-background);
}

.atlas-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--ap-border);
    border-top: 4px solid var(--ap-primary);
    border-radius: 50%;
    animation: atlas-spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes atlas-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ---------- Buttons --------------------------------------------------- */

.atlas-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px; /* WCAG 2.5.5 target size (AAA) / 2.2 2.5.8 AA */
    min-width: 44px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.atlas-btn-primary {
    background-color: var(--ap-primary);
    color: #fff;
}

.atlas-btn-primary:hover:not(:disabled) {
    background-color: var(--ap-primary-dark);
}

.atlas-btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ---------- Modal overlay (session timeout / logout confirm) ---------- */

.atlas-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.atlas-modal-overlay .modal-content {
    background: var(--ap-surface);
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.atlas-modal-overlay .modal-header,
.atlas-modal-overlay .modal-body,
.atlas-modal-overlay .modal-footer {
    padding: 16px 24px;
}

.atlas-modal-overlay .modal-header {
    border-bottom: 1px solid var(--ap-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.atlas-modal-overlay .modal-footer {
    border-top: 1px solid var(--ap-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ---------- Blazor error UI ------------------------------------------- */

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ---------- Responsive helpers --------------------------------------- */

@media (max-width: 768px) {
    .atlas-hide-on-mobile { display: none !important; }
    html { font-size: 87.5%; }
}
