/* ==========================================================================
   AtomFive Platform - Basic Elements Design System (basic-elements.css)
   Clean code, semantic, modular foundation for all UI primitives.
   Strictly consumes canonical tokens from themes.css.
   ========================================================================== */

@import url('./css-components/primitives.css');

/* ==========================================================================
   1. Global Box-Sizing & Universal Resets
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    border: none !important;
    outline: none !important;
}

/* Canonical Slot Elements: zero layout perturbation */
a5-slot {
    display: contents;
}

iframe,
embed,
object {
    outline: none;
    border: none;
}

/* ==========================================================================
   2. Custom Scrollbars
   ========================================================================== */
::-webkit-scrollbar {
    height: 10px;
    width: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-full, 999px);
}

::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--scrollbar-thumb) 80%, white);
}

/* ==========================================================================
   3. Typography & Semantic Elements
   ========================================================================== */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 0.5rem 0;
    font-family: inherit;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.25;
}

h1 {
    font-size: var(--fs-title-page);
}

h2 {
    font-size: var(--fs-title-section);
}

h3 {
    font-size: 1.15rem;
}

h4 {
    font-size: 1rem;
}

h5 {
    font-size: var(--fs-caption);
}

h6 {
    font-size: var(--fs-meta);
}

p {
    margin: 0 0 0.75rem 0;
    color: var(--color-text-muted);
    line-height: 1.5;
}

span {
    color: var(--color-text);
}

a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--anim-fast) ease;
}

a:hover {
    color: var(--color-brand);
}

strong,
b {
    color: var(--color-brand);
    font-weight: 600;
}

small {
    font-size: var(--fs-meta);
    color: var(--color-text-muted);
}

ul,
ol {
    margin: 0 0 0.75rem 0;
    padding-left: 1.25rem;
    color: var(--color-text-muted);
}

li {
    margin: 4px 0;
}

code,
kbd,
samp,
pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875em;
}

code {
    padding: 2px 6px;
    background: var(--color-surface-alt);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm, 4px);
    color: var(--color-brand);
}

pre {
    padding: 12px 16px;
    background: var(--color-surface-alt);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    overflow-x: auto;
    color: var(--color-text);
}

blockquote {
    margin: 0 0 1rem 0;
    padding: 8px 16px;
    border-left: 3px solid var(--color-brand);
    background: var(--color-surface-alt);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--color-text-muted);
}

hr {
    border: none;
    border-top: 1px solid var(--border-faint);
    margin: 1.5rem 0;
}

/* ==========================================================================
   4. Form Controls, Labels & Inputs
   ========================================================================== */
fieldset {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 10px 0;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    transition: background-color var(--anim-fast) ease, border-color var(--anim-fast) ease;
}

legend {
    font-size: var(--fs-caption);
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 0 6px;
    margin-left: -4px;
}

label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-caption, 13px);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--color-text-muted);
    user-select: none;
    cursor: pointer;
    margin-bottom: 6px;
    transition: color var(--anim-fast) ease;
}

label:hover {
    color: var(--color-text);
}

/* Text Fields, Selects & Textareas */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    padding: 11px 16px;
    font-family: inherit;
    font-size: var(--fs-body, 14px);
    line-height: 1.5;
    color: var(--color-text);
    background-color: var(--color-surface-transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md, 12px);
    outline: none;
    box-sizing: border-box;
    /*box-shadow: 0 4px 18px var(--color-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);*/
    transition: all var(--anim-fast) cubic-bezier(0.16, 1, 0.3, 1);
}

/* Single-line text fields ellipsis clipping */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

input:hover,
select:hover,
textarea:hover {
    background-color: var(--overlay-hover);
    border-color: var(--color-brand-border);
    box-shadow: 0 6px 24px var(--color-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

input:focus,
select:focus,
textarea:focus {
    background-color: var(--color-surface-alt);
    border-color: var(--color-brand);
    box-shadow: var(--focus-ring), 0 6px 24px var(--color-shadow);
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-muted);
    opacity: 0.55;
    font-size: var(--fs-caption, 13px);
    font-weight: 400;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

textarea {
    min-height: 80px;
    resize: vertical;
}

/* Custom Select Styling */
select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px 16px;
    padding-right: 40px;
    cursor: pointer;
}

select option {
    background-color: var(--color-surface-block);
    color: var(--color-text);
    padding: 10px;
}

/* Universal WebKit Autofill Reset */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--color-text) !important;
    -webkit-box-shadow: 0 0 0px 1000px var(--color-surface-block) inset !important;
    box-shadow: 0 0 0px 1000px var(--color-surface-block) inset !important;
    caret-color: var(--color-text) !important;
    border-radius: inherit !important;
    transition: background-color 5000s ease-in-out 0s !important;
}

/* Custom Checkbox */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    margin: 0;
    color: var(--color-brand);
    width: 1.25em;
    height: 1.25em;
    border: 1.5px solid var(--border-strong, var(--color-text-muted));
    border-radius: var(--radius-sm, 6px);
    display: grid;
    place-content: center;
    cursor: pointer;
    transition: all var(--anim-fast) ease;
    flex-shrink: 0;
}

input[type="checkbox"]::before {
    content: '✓';
    font-size: 1.05em;
    font-weight: bold;
    transform: scale(0);
    transform-origin: center;
    transition: transform var(--anim-fast) ease;
    color: var(--color-brand);
}

input[type="checkbox"]:checked {
    border-color: var(--color-brand);
    background-color: var(--color-brand-soft);
}

input[type="checkbox"]:checked::before {
    transform: scale(1);
}

input[type="checkbox"]:not(:checked):hover {
    border-color: var(--color-brand-border);
}

input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Custom Radio Button */
input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    margin: 0;
    width: 1.25em;
    height: 1.25em;
    border: 1.5px solid var(--border-strong, var(--color-text-muted));
    border-radius: var(--radius-full, 50%);
    display: grid;
    place-content: center;
    cursor: pointer;
    transition: all var(--anim-fast) ease;
    flex-shrink: 0;
}

input[type="radio"]::before {
    content: '';
    width: 0.55em;
    height: 0.55em;
    border-radius: 50%;
    background-color: var(--color-brand);
    transform: scale(0);
    transition: transform var(--anim-fast) ease;
}

input[type="radio"]:checked {
    border-color: var(--color-brand);
    background-color: var(--color-brand-soft);
}

input[type="radio"]:checked::before {
    transform: scale(1);
}

input[type="radio"]:not(:checked):hover {
    border-color: var(--color-brand-border);
}

input[type="radio"]:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Disabled Form State */
input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* Form Group Utilities */
.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
    width: 100%;
}

.form-row {
    display: flex;
    gap: 1rem;
    width: 100%;
    align-items: center;
}

.form-hint {
    font-size: var(--fs-meta);
    color: var(--color-text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: var(--fs-meta);
    color: var(--color-danger);
    margin-top: 4px;
}

/* ==========================================================================
   5. Buttons & Interactive Controls (button, .btn)
   ========================================================================== */
button,
.btn {
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 14px;
    border-radius: var(--radius);
    cursor: pointer;
    background-color: var(--color-surface-alt);
    border: 1px solid var(--border-soft);
    color: var(--color-text);
    font-family: inherit;
    font-size: var(--fs-caption, 13px);
    font-weight: 500;
    line-height: 1;
    position: relative;
    user-select: none;
    text-decoration: none;
    transition: background-color var(--anim-fast) ease,
        border-color var(--anim-fast) ease,
        color var(--anim-fast) ease,
        transform var(--anim-fast) ease,
        box-shadow var(--anim-fast) ease;
}

button:hover,
.btn:hover {
    background-color: var(--color-surface);
    border-color: var(--color-text-muted);
    color: var(--color-text);
}

button:active,
.btn:active {
    transform: scale(0.98);
}

button:focus-visible,
.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Button Variants */
.btn-primary {
    background-color: var(--color-brand);
    border-color: var(--color-brand);
    color: #ffffff;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--color-brand) 30%, transparent);
}

.btn-primary:hover {
    background-color: color-mix(in srgb, var(--color-brand) 85%, white);
    border-color: color-mix(in srgb, var(--color-brand) 85%, white);
    color: #ffffff;
    box-shadow: 0 4px 14px color-mix(in srgb, var(--color-brand) 45%, transparent);
}

.btn-secondary {
    background-color: var(--color-surface-alt);
    border-color: var(--border-soft);
    color: var(--color-text);
}

.btn-secondary:hover {
    background-color: var(--color-surface);
    border-color: var(--border-strong);
}

.btn-success {
    background-color: var(--color-success);
    border-color: var(--color-success);
    color: #ffffff;
}

.btn-success:hover {
    background-color: color-mix(in srgb, var(--color-success) 85%, white);
    border-color: color-mix(in srgb, var(--color-success) 85%, white);
}

.btn-danger {
    background-color: var(--color-danger);
    border-color: var(--color-danger);
    color: #ffffff;
}

.btn-danger:hover {
    background-color: color-mix(in srgb, var(--color-danger) 85%, white);
    border-color: color-mix(in srgb, var(--color-danger) 85%, white);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--color-text-muted);
}

.btn-ghost:hover {
    background-color: var(--overlay-hover);
    border-color: transparent;
    color: var(--color-text);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-soft);
    color: var(--color-text);
}

.btn-outline:hover {
    background-color: var(--overlay-hover);
    border-color: var(--color-brand);
    color: var(--color-brand);
}

/* Icon Button */
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    border-radius: var(--radius);
}

/* Button Sizes */
.btn-sm {
    height: 28px;
    padding: 0 10px;
    font-size: var(--fs-meta);
    border-radius: var(--radius-sm, 6px);
}

.btn-lg {
    height: 44px;
    padding: 0 20px;
    font-size: var(--fs-body);
    border-radius: var(--radius-md, 10px);
}

/* Status Dot indicator inside buttons */
.btn .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-accent) 20%, transparent);
    flex-shrink: 0;
}

/* ==========================================================================
   6. Tables & Data Display
   ========================================================================== */
table,
.table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    margin: 1rem 0;
    font-size: var(--fs-caption, 13px);
    color: var(--color-text);
    text-align: left;
}

thead th,
.table thead th {
    background-color: var(--color-surface-alt);
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: var(--fs-meta, 12px);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
}

tbody td,
.table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-faint);
    color: var(--color-text);
    transition: background-color var(--anim-fast) ease;
}

tfoot td,
.table tfoot td {
    padding: 10px 14px;
    border-top: 1px solid var(--border-soft);
    font-weight: 600;
    color: var(--color-text-muted);
}

/* Striped Table */
.table-striped tbody tr:nth-of-type(odd) {
    background-color: color-mix(in srgb, var(--color-surface-alt) 40%, transparent);
}

/* Hoverable Table */
.table-hover tbody tr:hover,
tbody tr:hover {
    background-color: var(--overlay-hover);
}

/* Bordered Table */
.table-bordered {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-bordered th,
.table-bordered td {
    border: 1px solid var(--border-faint);
}

/* Compact Table */
.table-compact th,
.table-compact td {
    padding: 6px 10px;
    font-size: var(--fs-meta);
}

/* Responsive Table Wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: var(--radius);
}

/* ==========================================================================
   7. Badges, Tags & Chips
   ========================================================================== */
.badge,
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: var(--fs-meta, 11px);
    font-weight: 600;
    line-height: 1;
    border-radius: var(--radius-full, 999px);
    background-color: var(--color-surface-alt);
    border: 1px solid var(--border-soft);
    color: var(--color-text-muted);
    white-space: nowrap;
}

.badge-primary {
    background-color: var(--color-brand-soft);
    border-color: var(--color-brand-border);
    color: var(--color-brand);
}

.badge-success {
    background-color: color-mix(in srgb, var(--color-success) 15%, transparent);
    border-color: color-mix(in srgb, var(--color-success) 30%, transparent);
    color: var(--color-success);
}

.badge-warning {
    background-color: color-mix(in srgb, var(--color-accent) 15%, transparent);
    border-color: color-mix(in srgb, var(--color-accent) 30%, transparent);
    color: var(--color-accent);
}

.badge-danger {
    background-color: color-mix(in srgb, var(--color-danger) 15%, transparent);
    border-color: color-mix(in srgb, var(--color-danger) 30%, transparent);
    color: var(--color-danger);
}

.badge-muted {
    background-color: var(--color-surface-alt);
    border-color: var(--border-faint);
    color: var(--color-text-muted);
}

/* ==========================================================================
   8. Cards & Surface Containers
   ========================================================================== */
.card {
    background-color: var(--color-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md, 12px);
    box-shadow: 0 4px 20px var(--color-shadow);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: border-color var(--anim-fast) ease, box-shadow var(--anim-fast) ease;
}

.card:hover {
    border-color: var(--border-strong);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-faint);
}

.card-body {
    width: 100%;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-faint);
}

.divider {
    height: 1px;
    background-color: var(--border-faint);
    margin: 1rem 0;
    width: 100%;
}

/* ==========================================================================
   9. Global State & Visibility Utilities
   ========================================================================== */
.is-hidden {
    display: none !important;
}

/* Local Authentication Components (Disabled - Microsoft SSO Only) */
.auth-local-only,
#auth-login-form,
#auth-register-form,
#auth-forgot-form,
.auth-divider,
#brandBtnCreateAccount,
#login-link-forgot,
#login-link-register,
#reg-link-login {
    display: none !important;
}