/* XMedical Design System */

:root {
    --xm-radius: 0.75rem;
    --xm-shadow: 0 1px 3px hsl(var(--bc) / 0.08), 0 8px 24px hsl(var(--bc) / 0.06);
    --xm-sidebar-width: 18rem;
}

.xm-body {
    background-color: hsl(var(--b2));
    color: hsl(var(--bc));
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.xm-container {
    max-width: 80rem;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 640px) {
    .xm-container { padding-left: 1.5rem; padding-right: 1.5rem; }
}

@media (min-width: 1024px) {
    .xm-container { padding-left: 2rem; padding-right: 2rem; }
}

.xm-main { background-color: hsl(var(--b2)); }

.xm-page {
    max-width: 80rem;
    margin: 0 auto;
    padding: 1.5rem 1rem 2rem;
}

@media (min-width: 1024px) {
    .xm-page { padding: 2rem; }
}

/* Brand */
.xm-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.xm-brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    font-weight: 700;
    font-size: 0.875rem;
    background: linear-gradient(135deg, hsl(var(--p)), hsl(var(--p) / 0.85));
    color: hsl(var(--pc));
    box-shadow: var(--xm-shadow);
}

.xm-brand-text {
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: -0.02em;
}

/* Sidebar */
.xm-sidebar {
    box-shadow: var(--xm-shadow);
}

.xm-nav-section {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    opacity: 0.5;
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.xm-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 0.5rem;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
}

.xm-nav-item:hover {
    background-color: hsl(var(--b2));
}

.xm-nav-item--active {
    background-color: hsl(var(--p) / 0.1);
    color: hsl(var(--p));
    font-weight: 600;
}

.xm-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    opacity: 0.7;
}

.xm-nav-item--active .xm-icon { opacity: 1; }

/* Avatar */
.xm-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    flex-shrink: 0;
    background: hsl(var(--p) / 0.15);
    color: hsl(var(--p));
}

.xm-avatar--sm {
    width: 2rem;
    height: 2rem;
    font-size: 0.75rem;
}

/* Topbar */
.xm-topbar {
    box-shadow: 0 1px 0 hsl(var(--bc) / 0.06);
}

/* Page header */
.xm-page-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 1024px) {
    .xm-page-header {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
    }
}

.xm-page-header__subtitle {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--p));
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.xm-page-header__title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-top: 0.25rem;
}

@media (min-width: 1024px) {
    .xm-page-header__title { font-size: 2rem; }
}

.xm-page-header__desc {
    font-size: 0.875rem;
    opacity: 0.7;
    margin-top: 0.5rem;
    max-width: 42rem;
}

.xm-page-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Breadcrumbs */
.xm-breadcrumbs ul {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    opacity: 0.7;
    background: hsl(var(--b1));
    border-bottom: 1px solid hsl(var(--b3));
}

@media (min-width: 1024px) {
    .xm-breadcrumbs ul { padding-left: 2rem; padding-right: 2rem; }
}

.xm-breadcrumbs li:not(:last-child)::after {
    content: "/";
    margin-left: 0.5rem;
    opacity: 0.4;
}

/* Cards */
.xm-card {
    background: hsl(var(--b1));
    border-radius: var(--xm-radius);
    border: 1px solid hsl(var(--b3) / 0.6);
    box-shadow: var(--xm-shadow);
}

.xm-stat-card {
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.xm-stat-card--primary {
    border-color: hsl(var(--p) / 0.2);
    background: hsl(var(--p) / 0.05);
}

.xm-stat-card--warning {
    border-color: hsl(var(--wa) / 0.2);
    background: hsl(var(--wa) / 0.05);
}

.xm-stat-card--success {
    border-color: hsl(var(--su) / 0.2);
    background: hsl(var(--su) / 0.05);
}

.xm-stat-card__label {
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0.7;
}

.xm-stat-card__value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-top: 0.25rem;
}

.xm-stat-card__hint {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: 0.25rem;
}

/* Tables */
.xm-table-wrap {
    overflow-x: auto;
    border-radius: var(--xm-radius);
    border: 1px solid hsl(var(--b3) / 0.6);
    background: hsl(var(--b1));
    box-shadow: var(--xm-shadow);
}

.xm-table-wrap .table thead {
    background: hsl(var(--b2) / 0.8);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.xm-table-wrap .table th {
    font-weight: 600;
    opacity: 0.8;
}

/* Forms */
.xm-form { display: grid; gap: 1rem; }

.xm-field--error .input,
.xm-field--error .select,
.xm-field--error .textarea {
    border-color: hsl(var(--er));
}

input, select, textarea { width: 100%; }

form p { margin-bottom: 0.75rem; }

form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

form input, form select, form textarea {
    border: 1px solid hsl(var(--bc) / 0.15);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    background: hsl(var(--b1));
    transition: border-color 0.15s, box-shadow 0.15s;
}

form input:focus, form select:focus, form textarea:focus {
    outline: none;
    border-color: hsl(var(--p));
    box-shadow: 0 0 0 3px hsl(var(--p) / 0.15);
}

textarea { min-height: 9rem; }

/* Toasts */
.xm-toasts {
    position: fixed;
    top: 5rem;
    right: 1rem;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 24rem;
}

.xm-alert { font-size: 0.875rem; }

/* Empty state */
.xm-empty { text-align: center; padding: 3rem 1.5rem; }
.xm-empty__icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.5; }
.xm-empty__title { font-size: 1.125rem; font-weight: 600; }
.xm-empty__message {
    font-size: 0.875rem;
    opacity: 0.7;
    margin-top: 0.5rem;
    max-width: 28rem;
    margin-left: auto;
    margin-right: auto;
}

/* Public */
.xm-public-header {
    background: hsl(var(--b1) / 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid hsl(var(--b3));
    position: sticky;
    top: 0;
    z-index: 30;
}

.xm-hero {
    max-width: 80rem;
    margin: 0 auto;
    padding: 4rem 1rem;
}

@media (min-width: 1024px) {
    .xm-hero { padding: 6rem 2rem; }
}

.xm-hero__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    background: hsl(var(--p) / 0.1);
    color: hsl(var(--p));
    margin-bottom: 1rem;
}

.xm-hero__title {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

@media (min-width: 1024px) {
    .xm-hero__title { font-size: 3.75rem; }
}

.xm-hero__subtitle {
    font-size: 1.125rem;
    opacity: 0.75;
    margin-top: 1rem;
    max-width: 42rem;
    line-height: 1.6;
}

.xm-feature-grid {
    display: grid;
    gap: 1.5rem;
    margin-top: 4rem;
}

@media (min-width: 768px) {
    .xm-feature-grid { grid-template-columns: repeat(3, 1fr); }
}

.xm-feature-card {
    transition: box-shadow 0.2s;
}

.xm-feature-card:hover {
    box-shadow: 0 4px 20px hsl(var(--bc) / 0.1);
}

/* Portal */
.xm-portal-header { position: sticky; top: 0; z-index: 30; }

.xm-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: hsl(var(--b1));
    border-top: 1px solid hsl(var(--b3));
    z-index: 30;
}

.xm-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    opacity: 0.6;
    padding: 0.5rem 0;
    text-decoration: none;
    color: inherit;
}

.xm-bottom-nav-item--active {
    opacity: 1;
    color: hsl(var(--p));
    font-weight: 600;
}

.xm-portal .xm-page { padding-bottom: 5rem; }

@media (min-width: 1024px) {
    .xm-portal .xm-page { padding-bottom: 2rem; }
}

/* Auth */
.xm-auth-card {
    max-width: 28rem;
    margin: 2rem auto 0;
}

@media (min-width: 1024px) {
    .xm-auth-card { margin-top: 3rem; }
}

.xm-auth-card .card-body { padding: 2rem; }

/* Footer */
.xm-footer {
    border-top: 1px solid hsl(var(--b3));
    background: hsl(var(--b1));
}

/* Wizard */
.xm-wizard-steps {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.xm-wizard-step {
    flex: 1;
    min-width: 4rem;
    text-align: center;
    padding: 0.5rem 0.25rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0.5;
    background: hsl(var(--b3) / 0.3);
    border: 1px solid transparent;
}

.xm-wizard-step--active {
    opacity: 1;
    background: hsl(var(--p) / 0.1);
    border-color: hsl(var(--p) / 0.3);
    color: hsl(var(--p));
    font-weight: 600;
}

.xm-wizard-step--done {
    opacity: 0.85;
    background: hsl(var(--su) / 0.08);
    color: hsl(var(--su));
}

/* Legacy compatibility — unifica plantillas aún no migradas */
.card.bg-base-100.shadow,
.card.bg-base-100.shadow-xl,
.xm-card {
    border-radius: var(--xm-radius);
    border: 1px solid hsl(var(--b3) / 0.6);
    box-shadow: var(--xm-shadow);
    background: hsl(var(--b1));
}

.stat.rounded-box {
    border-radius: var(--xm-radius);
    border: 1px solid hsl(var(--b3) / 0.4);
    box-shadow: var(--xm-shadow);
    background: hsl(var(--b1));
    padding: 1rem;
}

.card .table thead,
.xm-table-wrap .table thead {
    background: hsl(var(--b2) / 0.8);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.card .overflow-x-auto {
    border-radius: calc(var(--xm-radius) - 2px);
}

@media (max-width: 1023px) {
    .xm-sidebar { width: min(85vw, var(--xm-sidebar-width)); }
}
