/**
 * Structra Utility Classes
 * ========================
 *
 * This file provides utility classes for common styling needs.
 * These utilities follow a consistent naming convention and can be
 * composed to build complex layouts without writing custom CSS.
 *
 * Naming Convention:
 * - .structra-{property}-{value}
 * - .structra-{property}-{breakpoint}-{value} (responsive)
 *
 * Breakpoints:
 * - sm: 640px
 * - md: 768px
 * - lg: 1024px
 * - xl: 1280px
 */

/* ==========================================================================
   DISPLAY UTILITIES
   ========================================================================== */

.structra-hidden { display: none !important; }
.structra-block { display: block !important; }
.structra-inline { display: inline !important; }
.structra-inline-block { display: inline-block !important; }
.structra-flex { display: flex !important; }
.structra-inline-flex { display: inline-flex !important; }
.structra-grid { display: grid !important; }

/* Responsive display */
@media (min-width: 640px) {
    .structra-sm-hidden { display: none !important; }
    .structra-sm-block { display: block !important; }
    .structra-sm-flex { display: flex !important; }
    .structra-sm-grid { display: grid !important; }
}

@media (min-width: 768px) {
    .structra-md-hidden { display: none !important; }
    .structra-md-block { display: block !important; }
    .structra-md-flex { display: flex !important; }
    .structra-md-grid { display: grid !important; }
}

@media (min-width: 1024px) {
    .structra-lg-hidden { display: none !important; }
    .structra-lg-block { display: block !important; }
    .structra-lg-flex { display: flex !important; }
    .structra-lg-grid { display: grid !important; }
}

/* ==========================================================================
   FLEXBOX UTILITIES
   ========================================================================== */

/* Flex direction */
.structra-flex-row { flex-direction: row !important; }
.structra-flex-col { flex-direction: column !important; }
.structra-flex-row-reverse { flex-direction: row-reverse !important; }
.structra-flex-col-reverse { flex-direction: column-reverse !important; }

/* Flex wrap */
.structra-flex-wrap { flex-wrap: wrap !important; }
.structra-flex-nowrap { flex-wrap: nowrap !important; }

/* Justify content */
.structra-justify-start { justify-content: flex-start !important; }
.structra-justify-end { justify-content: flex-end !important; }
.structra-justify-center { justify-content: center !important; }
.structra-justify-between { justify-content: space-between !important; }
.structra-justify-around { justify-content: space-around !important; }
.structra-justify-evenly { justify-content: space-evenly !important; }

/* Align items */
.structra-items-start { align-items: flex-start !important; }
.structra-items-end { align-items: flex-end !important; }
.structra-items-center { align-items: center !important; }
.structra-items-baseline { align-items: baseline !important; }
.structra-items-stretch { align-items: stretch !important; }

/* Align self */
.structra-self-start { align-self: flex-start !important; }
.structra-self-end { align-self: flex-end !important; }
.structra-self-center { align-self: center !important; }
.structra-self-stretch { align-self: stretch !important; }

/* Flex grow/shrink */
.structra-flex-1 { flex: 1 1 0% !important; }
.structra-flex-auto { flex: 1 1 auto !important; }
.structra-flex-none { flex: none !important; }
.structra-grow { flex-grow: 1 !important; }
.structra-grow-0 { flex-grow: 0 !important; }
.structra-shrink { flex-shrink: 1 !important; }
.structra-shrink-0 { flex-shrink: 0 !important; }

/* ==========================================================================
   GRID UTILITIES
   ========================================================================== */

.structra-grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)) !important; }
.structra-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
.structra-grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
.structra-grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
.structra-grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; }
.structra-grid-cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)) !important; }

/* Column span */
.structra-col-span-1 { grid-column: span 1 / span 1 !important; }
.structra-col-span-2 { grid-column: span 2 / span 2 !important; }
.structra-col-span-3 { grid-column: span 3 / span 3 !important; }
.structra-col-span-4 { grid-column: span 4 / span 4 !important; }
.structra-col-span-6 { grid-column: span 6 / span 6 !important; }
.structra-col-span-full { grid-column: 1 / -1 !important; }

/* Responsive grid */
@media (min-width: 768px) {
    .structra-md-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .structra-md-grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    .structra-md-grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
}

@media (min-width: 1024px) {
    .structra-lg-grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    .structra-lg-grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
    .structra-lg-grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; }
}

/* ==========================================================================
   GAP UTILITIES
   ========================================================================== */

.structra-gap-0 { gap: 0 !important; }
.structra-gap-1 { gap: var(--structra-spacing-1) !important; }
.structra-gap-2 { gap: var(--structra-spacing-2) !important; }
.structra-gap-3 { gap: var(--structra-spacing-3) !important; }
.structra-gap-4 { gap: var(--structra-spacing-4) !important; }
.structra-gap-5 { gap: var(--structra-spacing-5) !important; }
.structra-gap-6 { gap: var(--structra-spacing-6) !important; }
.structra-gap-8 { gap: var(--structra-spacing-8) !important; }

.structra-gap-x-4 { column-gap: var(--structra-spacing-4) !important; }
.structra-gap-y-4 { row-gap: var(--structra-spacing-4) !important; }

/* ==========================================================================
   SPACING UTILITIES
   ========================================================================== */

/* Margin */
.structra-m-0 { margin: 0 !important; }
.structra-m-1 { margin: var(--structra-spacing-1) !important; }
.structra-m-2 { margin: var(--structra-spacing-2) !important; }
.structra-m-3 { margin: var(--structra-spacing-3) !important; }
.structra-m-4 { margin: var(--structra-spacing-4) !important; }
.structra-m-6 { margin: var(--structra-spacing-6) !important; }
.structra-m-8 { margin: var(--structra-spacing-8) !important; }
.structra-m-auto { margin: auto !important; }

.structra-mx-auto { margin-left: auto !important; margin-right: auto !important; }
.structra-my-4 { margin-top: var(--structra-spacing-4) !important; margin-bottom: var(--structra-spacing-4) !important; }
.structra-my-6 { margin-top: var(--structra-spacing-6) !important; margin-bottom: var(--structra-spacing-6) !important; }

.structra-mt-0 { margin-top: 0 !important; }
.structra-mt-1 { margin-top: var(--structra-spacing-1) !important; }
.structra-mt-2 { margin-top: var(--structra-spacing-2) !important; }
.structra-mt-3 { margin-top: var(--structra-spacing-3) !important; }
.structra-mt-4 { margin-top: var(--structra-spacing-4) !important; }
.structra-mt-6 { margin-top: var(--structra-spacing-6) !important; }
.structra-mt-8 { margin-top: var(--structra-spacing-8) !important; }

.structra-mb-0 { margin-bottom: 0 !important; }
.structra-mb-1 { margin-bottom: var(--structra-spacing-1) !important; }
.structra-mb-2 { margin-bottom: var(--structra-spacing-2) !important; }
.structra-mb-3 { margin-bottom: var(--structra-spacing-3) !important; }
.structra-mb-4 { margin-bottom: var(--structra-spacing-4) !important; }
.structra-mb-6 { margin-bottom: var(--structra-spacing-6) !important; }
.structra-mb-8 { margin-bottom: var(--structra-spacing-8) !important; }

.structra-ml-auto { margin-left: auto !important; }
.structra-mr-auto { margin-right: auto !important; }

/* Padding */
.structra-p-0 { padding: 0 !important; }
.structra-p-1 { padding: var(--structra-spacing-1) !important; }
.structra-p-2 { padding: var(--structra-spacing-2) !important; }
.structra-p-3 { padding: var(--structra-spacing-3) !important; }
.structra-p-4 { padding: var(--structra-spacing-4) !important; }
.structra-p-6 { padding: var(--structra-spacing-6) !important; }
.structra-p-8 { padding: var(--structra-spacing-8) !important; }

.structra-px-4 { padding-left: var(--structra-spacing-4) !important; padding-right: var(--structra-spacing-4) !important; }
.structra-px-6 { padding-left: var(--structra-spacing-6) !important; padding-right: var(--structra-spacing-6) !important; }
.structra-py-2 { padding-top: var(--structra-spacing-2) !important; padding-bottom: var(--structra-spacing-2) !important; }
.structra-py-4 { padding-top: var(--structra-spacing-4) !important; padding-bottom: var(--structra-spacing-4) !important; }
.structra-py-6 { padding-top: var(--structra-spacing-6) !important; padding-bottom: var(--structra-spacing-6) !important; }

/* ==========================================================================
   SIZING UTILITIES
   ========================================================================== */

.structra-w-full { width: 100% !important; }
.structra-w-auto { width: auto !important; }
.structra-w-1\/2 { width: 50% !important; }
.structra-w-1\/3 { width: 33.333333% !important; }
.structra-w-2\/3 { width: 66.666667% !important; }

.structra-h-full { height: 100% !important; }
.structra-h-screen { height: 100vh !important; }
.structra-h-auto { height: auto !important; }

.structra-min-h-screen { min-height: 100vh !important; }
.structra-min-w-0 { min-width: 0 !important; }

.structra-max-w-sm { max-width: var(--structra-container-sm) !important; }
.structra-max-w-md { max-width: var(--structra-container-md) !important; }
.structra-max-w-lg { max-width: var(--structra-container-lg) !important; }
.structra-max-w-xl { max-width: var(--structra-container-xl) !important; }
.structra-max-w-full { max-width: 100% !important; }

/* ==========================================================================
   TYPOGRAPHY UTILITIES
   ========================================================================== */

/* Text alignment */
.structra-text-left { text-align: left !important; }
.structra-text-center { text-align: center !important; }
.structra-text-right { text-align: right !important; }

/* Font size */
.structra-text-xs { font-size: var(--structra-font-size-xs) !important; }
.structra-text-sm { font-size: var(--structra-font-size-sm) !important; }
.structra-text-base { font-size: var(--structra-font-size-base) !important; }
.structra-text-lg { font-size: var(--structra-font-size-lg) !important; }
.structra-text-xl { font-size: var(--structra-font-size-xl) !important; }
.structra-text-2xl { font-size: var(--structra-font-size-2xl) !important; }
.structra-text-3xl { font-size: var(--structra-font-size-3xl) !important; }

/* Font weight */
.structra-font-light { font-weight: var(--structra-font-weight-light) !important; }
.structra-font-normal { font-weight: var(--structra-font-weight-regular) !important; }
.structra-font-medium { font-weight: var(--structra-font-weight-medium) !important; }
.structra-font-semibold { font-weight: var(--structra-font-weight-semibold) !important; }
.structra-font-bold { font-weight: var(--structra-font-weight-bold) !important; }

/* Text color */
.structra-text-primary { color: var(--structra-text-primary) !important; }
.structra-text-secondary { color: var(--structra-text-secondary) !important; }
.structra-text-tertiary { color: var(--structra-text-tertiary) !important; }
.structra-text-disabled { color: var(--structra-text-disabled) !important; }
.structra-text-link { color: var(--structra-text-link) !important; }
.structra-text-success { color: var(--structra-success) !important; }
.structra-text-warning { color: var(--structra-warning) !important; }
.structra-text-error { color: var(--structra-error) !important; }
.structra-text-info { color: var(--structra-info) !important; }

/* Text decoration */
.structra-underline { text-decoration: underline !important; }
.structra-no-underline { text-decoration: none !important; }
.structra-line-through { text-decoration: line-through !important; }

/* Text transform */
.structra-uppercase { text-transform: uppercase !important; }
.structra-lowercase { text-transform: lowercase !important; }
.structra-capitalize { text-transform: capitalize !important; }
.structra-normal-case { text-transform: none !important; }

/* Text overflow */
.structra-truncate {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.structra-line-clamp-2 {
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden !important;
}

.structra-line-clamp-3 {
    display: -webkit-box !important;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden !important;
}

/* White space */
.structra-whitespace-nowrap { white-space: nowrap !important; }
.structra-whitespace-normal { white-space: normal !important; }

/* ==========================================================================
   BACKGROUND UTILITIES
   ========================================================================== */

.structra-bg-body { background-color: var(--structra-bg-body) !important; }
.structra-bg-surface { background-color: var(--structra-bg-surface) !important; }
.structra-bg-muted { background-color: var(--structra-bg-muted) !important; }
.structra-bg-subtle { background-color: var(--structra-bg-subtle) !important; }
.structra-bg-primary { background-color: var(--structra-primary-500) !important; }
.structra-bg-success { background-color: var(--structra-success-light) !important; }
.structra-bg-warning { background-color: var(--structra-warning-light) !important; }
.structra-bg-error { background-color: var(--structra-error-light) !important; }
.structra-bg-transparent { background-color: transparent !important; }

/* ==========================================================================
   BORDER UTILITIES
   ========================================================================== */

.structra-border { border: 1px solid var(--structra-border-default) !important; }
.structra-border-0 { border: 0 !important; }
.structra-border-t { border-top: 1px solid var(--structra-border-default) !important; }
.structra-border-b { border-bottom: 1px solid var(--structra-border-default) !important; }
.structra-border-l { border-left: 1px solid var(--structra-border-default) !important; }
.structra-border-r { border-right: 1px solid var(--structra-border-default) !important; }

.structra-border-subtle { border-color: var(--structra-border-subtle) !important; }
.structra-border-strong { border-color: var(--structra-border-strong) !important; }
.structra-border-primary { border-color: var(--structra-primary-500) !important; }

/* Border radius */
.structra-rounded-none { border-radius: 0 !important; }
.structra-rounded-sm { border-radius: var(--structra-radius-sm) !important; }
.structra-rounded { border-radius: var(--structra-radius-base) !important; }
.structra-rounded-md { border-radius: var(--structra-radius-md) !important; }
.structra-rounded-lg { border-radius: var(--structra-radius-lg) !important; }
.structra-rounded-xl { border-radius: var(--structra-radius-xl) !important; }
.structra-rounded-full { border-radius: var(--structra-radius-full) !important; }

/* ==========================================================================
   SHADOW UTILITIES
   ========================================================================== */

.structra-shadow-none { box-shadow: none !important; }
.structra-shadow-sm { box-shadow: var(--structra-shadow-sm) !important; }
.structra-shadow { box-shadow: var(--structra-shadow-base) !important; }
.structra-shadow-md { box-shadow: var(--structra-shadow-md) !important; }
.structra-shadow-lg { box-shadow: var(--structra-shadow-lg) !important; }

/* ==========================================================================
   POSITION UTILITIES
   ========================================================================== */

.structra-relative { position: relative !important; }
.structra-absolute { position: absolute !important; }
.structra-fixed { position: fixed !important; }
.structra-sticky { position: sticky !important; }
.structra-static { position: static !important; }

.structra-inset-0 { inset: 0 !important; }
.structra-top-0 { top: 0 !important; }
.structra-right-0 { right: 0 !important; }
.structra-bottom-0 { bottom: 0 !important; }
.structra-left-0 { left: 0 !important; }

/* ==========================================================================
   OVERFLOW UTILITIES
   ========================================================================== */

.structra-overflow-auto { overflow: auto !important; }
.structra-overflow-hidden { overflow: hidden !important; }
.structra-overflow-visible { overflow: visible !important; }
.structra-overflow-scroll { overflow: scroll !important; }
.structra-overflow-x-auto { overflow-x: auto !important; }
.structra-overflow-y-auto { overflow-y: auto !important; }

/* ==========================================================================
   VISIBILITY UTILITIES
   ========================================================================== */

.structra-visible { visibility: visible !important; }
.structra-invisible { visibility: hidden !important; }
.structra-opacity-0 { opacity: 0 !important; }
.structra-opacity-50 { opacity: 0.5 !important; }
.structra-opacity-100 { opacity: 1 !important; }

/* ==========================================================================
   CURSOR UTILITIES
   ========================================================================== */

.structra-cursor-pointer { cursor: pointer !important; }
.structra-cursor-default { cursor: default !important; }
.structra-cursor-not-allowed { cursor: not-allowed !important; }
.structra-cursor-wait { cursor: wait !important; }

/* ==========================================================================
   INTERACTION UTILITIES
   ========================================================================== */

.structra-select-none { user-select: none !important; }
.structra-select-text { user-select: text !important; }
.structra-select-all { user-select: all !important; }

.structra-pointer-events-none { pointer-events: none !important; }
.structra-pointer-events-auto { pointer-events: auto !important; }

/* ==========================================================================
   TRANSITION UTILITIES
   ========================================================================== */

.structra-transition { transition: var(--structra-transition-all) !important; }
.structra-transition-colors { transition: var(--structra-transition-colors) !important; }
.structra-transition-opacity { transition: var(--structra-transition-opacity) !important; }
.structra-transition-transform { transition: var(--structra-transition-transform) !important; }
.structra-transition-none { transition: none !important; }

/* ==========================================================================
   SCREEN READER UTILITIES
   ========================================================================== */

.structra-sr-only {
    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;
}

.structra-not-sr-only {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* ==========================================================================
   AUTHENTICATION PAGE STYLES
   ========================================================================== */

/**
 * Auth Layout - Full viewport centered container
 * Used by AuthLayout.razor for login, forgot password, etc.
 */
.auth-layout {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100vh !important;
    width: 100% !important;
    padding: var(--structra-spacing-4) !important;
    background-color: var(--structra-bg-body) !important;
    box-sizing: border-box !important;
}

/**
 * Auth Centered - Container for auth content
 * Removes conflicting min-height from child
 */
.auth-centered {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    background-color: transparent !important;
}

/**
 * Auth Centered Card - The actual login form card
 * Constrained width, centered, with shadow
 */
.auth-centered-card {
    width: 100% !important;
    max-width: 400px !important;
    padding: var(--structra-spacing-8) !important;
    background-color: var(--structra-bg-surface) !important;
    border: 1px solid var(--structra-border-default) !important;
    border-radius: var(--structra-radius-xl) !important;
    box-shadow: var(--structra-shadow-lg) !important;
    text-align: center !important;
    box-sizing: border-box !important;
}

/**
 * Auth Logo Container - Shows ONLY one logo based on theme
 */
.auth-logo-container {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin-bottom: var(--structra-spacing-6) !important;
}

.auth-logo-img {
    max-width: 200px !important;
    max-height: 60px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
}

/* Default: show light logo, hide dark logo */
.auth-logo-img--light {
    display: block !important;
}

.auth-logo-img--dark {
    display: none !important;
}

/* Dark mode: show dark logo, hide light logo */
[data-theme="dark"] .auth-logo-img--light {
    display: none !important;
}

[data-theme="dark"] .auth-logo-img--dark {
    display: block !important;
}

/**
 * Auth Form Elements - Constrained within card
 */
.auth-centered-card .auth-header--compact {
    margin-bottom: var(--structra-spacing-6) !important;
    text-align: center !important;
}

.auth-centered-card .auth-title--compact {
    font-size: var(--structra-font-size-2xl) !important;
    font-weight: var(--structra-font-weight-bold) !important;
    color: var(--structra-text-primary) !important;
    margin: 0 0 var(--structra-spacing-2) !important;
}

.auth-centered-card .auth-subtitle {
    font-size: var(--structra-font-size-base) !important;
    color: var(--structra-text-secondary) !important;
    margin: 0 !important;
}

.auth-centered-card .auth-form--compact {
    width: 100% !important;
    max-width: 100% !important;
    text-align: left !important;
}

.auth-centered-card .structra-form,
.auth-centered-card .structra-form--compact {
    width: 100% !important;
    max-width: 100% !important;
}

/* Ensure all form inputs stay within the card */
.auth-centered-card .structra-form-group,
.auth-centered-card .e-input-group,
.auth-centered-card .e-float-input,
.auth-centered-card input,
.auth-centered-card .e-textbox {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Auth password group styling */
.auth-password-group {
    position: relative !important;
}

.auth-forgot-link {
    position: absolute !important;
    right: 0 !important;
    top: 0 !important;
    font-size: var(--structra-font-size-xs) !important;
    color: var(--structra-text-link) !important;
    text-decoration: none !important;
}

.auth-forgot-link:hover {
    color: var(--structra-text-link-hover) !important;
    text-decoration: underline !important;
}

/* Auth options (remember me checkbox) */
.auth-options--compact {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    margin: var(--structra-spacing-2) 0 var(--structra-spacing-4) 0 !important;
}

.auth-checkbox {
    display: flex !important;
    align-items: center !important;
    gap: var(--structra-spacing-2) !important;
    font-size: var(--structra-font-size-sm) !important;
    color: var(--structra-text-secondary) !important;
    cursor: pointer !important;
}

/* Auth footer */
.auth-centered-card .auth-footer--compact {
    margin-top: var(--structra-spacing-6) !important;
    padding-top: var(--structra-spacing-4) !important;
    border-top: 1px solid var(--structra-border-subtle) !important;
    text-align: center !important;
}

.auth-centered-card .auth-footer--compact p {
    font-size: var(--structra-font-size-sm) !important;
    color: var(--structra-text-secondary) !important;
    margin: 0 !important;
}

.auth-link {
    color: var(--structra-text-link) !important;
    text-decoration: none !important;
}

.auth-link:hover {
    color: var(--structra-text-link-hover) !important;
    text-decoration: underline !important;
}

/* Responsive adjustments for auth pages */
@media (max-width: 480px) {
    .auth-layout {
        padding: var(--structra-spacing-4) !important;
    }

    .auth-centered-card {
        padding: var(--structra-spacing-6) !important;
        border-radius: var(--structra-radius-lg) !important;
    }

    .auth-logo-img {
        max-width: 160px !important;
    }

    .auth-forgot-link {
        position: relative !important;
        display: block !important;
        margin-top: var(--structra-spacing-2) !important;
        text-align: right !important;
    }
}
