/* ==========================================================================
   VX Portal Foundation CSS
   Minimal overrides for Web Awesome + Frappe integration
   ========================================================================== */

/* Reset Frappe body styles - portal uses its own shell layout */
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Skip Link (Accessibility) */
.vx-skip-link {
    position: absolute;
    left: -9999px;
    z-index: 999;
    padding: 1rem;
    background: var(--sl-color-primary-600);
    color: white;
    text-decoration: none;
    font-weight: 600;
}

.vx-skip-link:focus {
    left: 1rem;
    top: 1rem;
}

/* Portal Shell Layout */
.vx-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.vx-shell__header {
    background: var(--sl-color-neutral-0);
    border-bottom: 1px solid var(--sl-color-neutral-200);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.vx-shell__header-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1rem;
}

.vx-shell__body {
    flex: 1;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
}

.vx-shell__layout {
    display: flex;
    gap: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1rem;
    transition: max-width 0.3s ease;
    flex: 1;
    min-height: 0;
}

/* Increase max-width when sidebar is collapsed (more space for content) */
.vx-shell__sidebar.is-collapsed~.vx-shell__main {
    max-width: calc(100vw - 64px - 4rem);
}

.vx-shell__sidebar {
    width: 240px;
    min-width: 240px;
    max-width: 240px;
    flex-shrink: 0;
    background: #ffffff !important;
    background: var(--sl-color-neutral-0) !important;
    border-right: 1px solid #e5e7eb;
    border-right: 1px solid var(--sl-color-neutral-200);
    transition: all 0.3s ease;
    padding: 0.5rem;
    opacity: 1;
    z-index: 10;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Collapsed sidebar (icons only) */
.vx-shell__sidebar.is-collapsed {
    width: 64px !important;
    min-width: 64px !important;
    max-width: 64px !important;
    padding: 0.5rem 0.25rem;
}

.vx-shell__sidebar.is-collapsed sl-menu-item::part(base) {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.vx-shell__sidebar.is-collapsed sl-menu-item::part(label) {
    display: none;
}

.vx-shell__sidebar.is-collapsed sl-menu-item::part(prefix) {
    margin-right: 0;
}

/* Show tooltips on collapsed sidebar menu items */
.vx-shell__sidebar.is-collapsed sl-menu-item {
    position: relative;
}

.vx-shell__main {
    flex: 1;
    min-width: 0;
    transition: margin-left 0.3s ease;
    /* Prevent overflow */
}

/* Brand / Logo */
.vx-brand {
    flex: 1;
}

.vx-brand__link {
    text-decoration: none;
    color: inherit;
    font-weight: 600;
    font-size: 1.25rem;
}

/* User Actions */
.vx-user-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.vx-user-name {
    display: none;
}

/* Sidebar Navigation */
.vx-sidebar-header {
    padding: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
    border-bottom: 1px solid var(--sl-color-neutral-200);
    display: flex;
    justify-content: flex-end;
}

.vx-sidebar-collapse-toggle {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.vx-sidebar-collapse-toggle:hover {
    opacity: 1;
}

/* Hide collapsed arrow by default (shown when sidebar is collapsed) */
.vx-sidebar-collapse-toggle .when-collapsed {
    display: none;
}

/* Hide collapse toggle on mobile */
@media (max-width: 900px) {
    .vx-sidebar-header {
        display: none;
    }
}

/* Collapsed sidebar hides text labels */
.vx-shell__sidebar.is-collapsed .vx-sidebar-collapse-toggle .when-expanded {
    display: none;
}

.vx-shell__sidebar.is-collapsed .vx-sidebar-collapse-toggle .when-collapsed {
    display: inline-flex;
}

.vx-sidebar-nav sl-menu {
    --sl-menu-border-width: 0;
    width: 100%;
    overflow-x: hidden;
}

/* Menu items - ensure proper layout */
.vx-sidebar-nav sl-menu-item {
    width: 100%;
    max-width: 100%;
}

.vx-sidebar-nav sl-menu-item.is-active {
    --sl-menu-item-background-color-hover: var(--sl-color-primary-100);
    --sl-menu-item-color-hover: var(--sl-color-primary-700);
    font-weight: 600;
}

/* Fallback styles if Shoelace doesn't load */
.vx-sidebar-nav sl-menu,
.vx-sidebar-nav sl-menu-item {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

sl-icon {
    display: inline-block !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
}

/* Mobile Sidebar Toggle */
.vx-sidebar-toggle {
    display: none;
    /* Hidden on desktop */
}

/* Page Header */
.vx-page-header {
    margin-bottom: 2rem;
}

.vx-page-header__title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0;
    color: var(--sl-color-neutral-900);
}

.vx-page-header__subtitle {
    color: var(--sl-color-neutral-600);
    margin: 0.5rem 0 1rem;
}

.vx-page-header__eyebrow {
    color: var(--sl-color-neutral-500);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.vx-page-header__actions {
    margin-top: 1rem;
}

/* Breadcrumb */
.vx-breadcrumb {
    margin-bottom: 1rem;
}

.vx-breadcrumb__list {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.875rem;
    color: var(--sl-color-neutral-600);
}

.vx-breadcrumb__item:not(:last-child)::after {
    content: '/';
    margin-left: 0.5rem;
    color: var(--sl-color-neutral-400);
}

.vx-breadcrumb__item a {
    color: var(--sl-color-neutral-600);
    text-decoration: none;
}

.vx-breadcrumb__item a:hover {
    color: var(--sl-color-primary-600);
    text-decoration: underline;
}

/* Content Area */
.vx-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Card Enhancements */
.vx-card {
    margin-bottom: 1.5rem;
}

.vx-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.vx-card-header__title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

/* Section */
.vx-section {
    padding: 1rem 0;
}

.vx-section:first-child {
    padding-top: 0;
}

.vx-section__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    color: var(--sl-color-neutral-800);
}

.vx-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

/* Stack Layout (vertical spacing) */
.vx-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Force single column for conditions list */
#conditions-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem !important;
    flex-wrap: nowrap !important;
}

/* Ensure sl-card elements also stack vertically */
#conditions-list>* {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
}

/* Target Shoelace card components directly */
#conditions-list sl-card {
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
}

/* Definition List */
.vx-definition-list {
    display: grid;
    gap: 0.75rem;
}

.vx-definition-list__item {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 1rem;
}

.vx-definition-list__item dt {
    font-weight: 600;
    color: var(--sl-color-neutral-700);
}

.vx-definition-list__item dd {
    margin: 0;
    color: var(--sl-color-neutral-900);
}

/* Simple List */
.vx-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.vx-list__item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--sl-color-neutral-100);
}

.vx-list__item:last-child {
    border-bottom: none;
}

/* Editor (inline edit sections) */
.vx-editor {
    padding: 1rem;
    background: var(--sl-color-neutral-50);
    border-radius: var(--sl-border-radius-medium);
}

/* Button Group */
.vx-button-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Muted Text */
.vx-muted {
    color: var(--sl-color-neutral-500);
    font-size: 0.875rem;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 900px) {
    .vx-shell__layout {
        flex-direction: column;
    }

    .vx-shell__sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        background: #ffffff;
        background: var(--sl-color-neutral-0);
        border-right: 1px solid #e5e7eb;
        border-right: 1px solid var(--sl-color-neutral-200);
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        padding: 1rem;
    }

    .vx-shell__sidebar.is-open {
        transform: translateX(0);
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    }

    /* Collapsed state not applicable on mobile */
    .vx-shell__sidebar.is-collapsed {
        width: 280px;
    }

    .vx-sidebar-toggle {
        display: inline-flex;
    }

    .vx-user-name {
        display: inline;
    }

    .vx-brand__link {
        font-size: 1rem;
    }

    .vx-page-header__title {
        font-size: 1.5rem;
    }

    .vx-definition-list__item {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
}

@media (max-width: 600px) {
    .vx-shell__header-inner {
        padding: 0 0.75rem;
    }

    .vx-shell__body {
        padding: 1rem 0;
    }

    .vx-shell__layout {
        padding: 0 0.75rem;
    }

    .vx-page-header__title {
        font-size: 1.25rem;
    }

    .vx-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .vx-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .vx-button-group {
        flex-direction: column;
        width: 100%;
    }

    .vx-button-group wa-button {
        width: 100%;
    }
}