/* ==================================================================
   WMS Design System — Global tokens, glass, motion, tooltips
   Load AFTER vendor CSS, BEFORE custom.css
   ================================================================== */

/* ---- Fallback tokens (overridden by theme-vars.blade.php) -------- */
:root {
    --brand-primary: #5C9E84;
    --brand-primary-rgb: 92, 158, 132;
    --brand-primary-600: #4A8770;
    --brand-primary-700: #3D7260;
    --brand-primary-soft: #E8F3EE;
    --brand-secondary: #7BB5A0;
    --brand-secondary-rgb: 123, 181, 160;
    --brand-secondary-600: #6AA894;
    --brand-secondary-soft: #E8F3EE;
    --brand-ink: #2f3a44;
    --brand-ink-soft: #5a6672;
    --brand-surface: rgba(255, 255, 255, 0.72);
    --brand-surface-soft: rgba(255, 255, 255, 0.45);
    /* Soft mint page wash (sampled from brand surface reference) */
    --brand-page-bg-soft: #F0F9F0;
    --brand-page-bg-mint: #E3F5E7;
    --brand-page-gradient: linear-gradient(90deg, #F0F9F0 0%, #EEF7EF 45%, #E3F5E7 100%);
    --brand-radius-lg: 24px;
    --brand-radius-md: 16px;
    --brand-radius-sm: 12px;
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.75);
    --glass-blur: 20px;
    --glass-shadow: 0 20px 50px -28px rgba(31, 41, 55, 0.28);
    --ds-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ds-duration: 0.35s;
    --bs-primary: var(--brand-primary);
    --bs-primary-rgb: var(--brand-primary-rgb);
}

/* ---- Bootstrap bridge (primary follows brand) -------------------- */
.btn-primary,
.bg-primary {
    background-color: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
}
.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--brand-primary-600) !important;
    border-color: var(--brand-primary-600) !important;
}
.text-primary { color: var(--brand-primary) !important; }
.border-primary { border-color: var(--brand-primary) !important; }
.bg-label-primary {
    background-color: rgba(var(--brand-primary-rgb), 0.12) !important;
    color: var(--brand-primary-700) !important;
}
.form-check-input:checked {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}
.form-control:focus,
.form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--brand-primary-rgb), 0.15);
}

/* ---- Glass surfaces (opt-in) ----------------------------------- */
.surface-glass {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
    backdrop-filter: blur(var(--glass-blur)) saturate(140%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--brand-radius-md);
}

/* Global glass mode — soft mint wash, keeps tables readable */
body.app-glass-enabled {
    background: var(--brand-page-gradient) !important;
}

body.app-glass-enabled .layout-page,
body.app-glass-enabled .content-wrapper,
body.app-glass-enabled .content-footer {
    background: transparent !important;
}

body.app-glass-enabled .card:not(.card-datatable):not(.card-action) {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(12px) saturate(130%);
    backdrop-filter: blur(12px) saturate(130%);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: 0 12px 32px -24px rgba(31, 41, 55, 0.22);
    transition: box-shadow var(--ds-duration) var(--ds-ease), transform var(--ds-duration) var(--ds-ease);
}

body.app-glass-enabled .card:not(.card-datatable):not(.card-action):hover {
    box-shadow: 0 16px 40px -22px rgba(31, 41, 55, 0.28);
}

body.app-glass-enabled .bg-menu-theme,
body.app-glass-enabled .bg-navbar-theme {
    background: rgba(255, 255, 255, 0.82) !important;
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
    border-color: rgba(255, 255, 255, 0.6) !important;
}

body.app-glass-enabled .auth-card,
body.app-glass-enabled .login-card {
    background: var(--glass-bg) !important;
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
    backdrop-filter: blur(var(--glass-blur)) saturate(140%);
}

/* ---- Motion (subtle luxury transitions) -------------------------- */
body.app-motion-enabled .btn,
body.app-motion-enabled .card,
body.app-motion-enabled .menu-link,
body.app-motion-enabled .dropdown-item,
body.app-motion-enabled .form-control,
body.app-motion-enabled .form-select,
body.app-motion-enabled .nav-link,
body.app-motion-enabled .badge {
    transition:
        color var(--ds-duration) var(--ds-ease),
        background-color var(--ds-duration) var(--ds-ease),
        border-color var(--ds-duration) var(--ds-ease),
        box-shadow var(--ds-duration) var(--ds-ease),
        transform 0.2s var(--ds-ease),
        opacity var(--ds-duration) var(--ds-ease);
}

body.app-motion-enabled .btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
}

body.app-motion-enabled .ds-reveal {
    opacity: 0;
    transform: translateY(10px);
    animation: ds-reveal-in 0.55s var(--ds-ease) forwards;
}

@keyframes ds-reveal-in {
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Info tooltip (global) --------------------------------------- */
.info-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: rgba(var(--brand-primary-rgb), 0.12);
    color: var(--brand-primary-700);
    font-size: 10px;
    font-weight: 700;
    cursor: help;
    border: none;
    padding: 0;
    flex: 0 0 auto;
    vertical-align: middle;
    line-height: 1;
    transition: background 0.2s ease, transform 0.2s ease;
}

.info-tip:hover,
.info-tip:focus-visible {
    background: rgba(var(--brand-primary-rgb), 0.22);
    outline: none;
    transform: scale(1.08);
}

.info-tip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    width: max-content;
    max-width: 240px;
    padding: 0.5rem 0.65rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 400;
    line-height: 1.4;
    text-align: left;
    color: #fff;
    background: rgba(29, 35, 42, 0.94);
    box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 1080;
}

.info-tip::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(29, 35, 42, 0.94);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1080;
}

.info-tip:hover::after,
.info-tip:focus-visible::after,
.info-tip:hover::before,
.info-tip:focus-visible::before {
    opacity: 1;
    visibility: visible;
}

.info-tip:hover::after,
.info-tip:focus-visible::after {
    transform: translateX(-50%) translateY(0);
}

/* ---- Theme settings preview panel -------------------------------- */
.theme-preview-panel {
    border-radius: var(--brand-radius-md);
    padding: 1.25rem;
    min-height: 200px;
    background:
        radial-gradient(80% 60% at 100% 0%, rgba(var(--brand-primary-rgb), 0.15), transparent),
        radial-gradient(70% 50% at 0% 100%, rgba(var(--brand-secondary-rgb), 0.12), transparent),
        #f4f6f9;
}

.theme-preview-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--brand-radius-sm);
    padding: 1rem;
    box-shadow: var(--glass-shadow);
}

/* ---- Modal ------------------------------------------------------- */
.modal-content {
    border: none;
    border-radius: var(--brand-radius-md);
    box-shadow: 0 24px 48px -12px rgba(31, 41, 55, 0.22);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: transparent;
}

.modal-title {
    flex: 1;
    margin: 0;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--brand-ink);
}

.modal-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--brand-ink-soft);
    cursor: pointer;
    flex-shrink: 0;
    transition:
        background-color var(--ds-duration) var(--ds-ease),
        color var(--ds-duration) var(--ds-ease),
        transform 0.2s var(--ds-ease);
}

.modal-close-btn .ti {
    font-size: 1.125rem;
    line-height: 1;
}

.modal-close-btn:hover,
.modal-close-btn:focus-visible {
    background: rgba(47, 58, 68, 0.08);
    color: var(--brand-ink);
    outline: none;
}

body.app-motion-enabled .modal-close-btn:hover {
    transform: scale(1.05);
}

.modal-body {
    padding: 1.25rem 1.5rem;
    color: var(--brand-ink-soft);
}

.modal-footer {
    padding: 0.875rem 1.5rem 1.25rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: transparent;
    gap: 0.5rem;
}

body.app-glass-enabled .modal-content {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
    backdrop-filter: blur(var(--glass-blur)) saturate(140%);
    border: 1px solid var(--glass-border);
}

/* ---- Reduced motion ---------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    body.app-motion-enabled *,
    body.app-motion-enabled *::before,
    body.app-motion-enabled *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
