/* ==========================================================================
   EYWA DESIGN SYSTEM — Enterprise SaaS UI Tokens & Base Primitives
   ========================================================================== */

:root {
    --eywa-primary: #4f46e5;
    --eywa-primary-hover: #4338ca;
    --eywa-primary-soft: #eef2ff;
    --eywa-primary-text: #3730a3;

    --eywa-accent: #0891b2;
    --eywa-accent-hover: #0e7490;
    --eywa-accent-soft: #ecfeff;

    --eywa-bg: #f8fafc;
    --eywa-surface: #ffffff;
    --eywa-surface-subtle: #f1f5f9;
    --eywa-border: #e2e8f0;
    --eywa-border-strong: #cbd5e1;

    --eywa-fg: #0f172a;
    --eywa-fg-secondary: #475569;
    --eywa-fg-muted: #64748b;

    --eywa-success: #059669;
    --eywa-success-soft: #ecfdf5;
    --eywa-warning: #d97706;
    --eywa-warning-soft: #fffbeb;
    --eywa-danger: #dc2626;
    --eywa-danger-soft: #fef2f2;
    --eywa-info: #0284c7;
    --eywa-info-soft: #f0f9ff;

    --eywa-radius-sm: 0.375rem;
    --eywa-radius-md: 0.5rem;
    --eywa-radius-lg: 0.75rem;
    --eywa-radius-xl: 1rem;

    --eywa-shadow-2xs: 0 1px 1px 0 rgb(15 23 42 / 0.03);
    --eywa-shadow-xs: 0 1px 2px 0 rgb(15 23 42 / 0.04), 0 0 0 1px rgb(15 23 42 / 0.015);
    --eywa-shadow-sm: 0 1px 3px 0 rgb(15 23 42 / 0.06), 0 1px 2px -1px rgb(15 23 42 / 0.04);
    --eywa-shadow-md: 0 6px 16px -3px rgb(15 23 42 / 0.08), 0 2px 6px -2px rgb(15 23 42 / 0.04);
    --eywa-shadow-lg: 0 14px 32px -6px rgb(15 23 42 / 0.12), 0 4px 10px -4px rgb(15 23 42 / 0.05);

    --eywa-font-sans: 'Plus Jakarta Sans', 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --eywa-font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Alpine cloak fix */
[x-cloak] {
    display: none !important;
}

/* Tailwind v4 Utility Shims for v3 Play CDN compatibility */
.shadow-2xs {
    box-shadow: var(--eywa-shadow-2xs);
}

.shadow-xs {
    box-shadow: var(--eywa-shadow-xs);
}

.backdrop-blur-xs {
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

/* Base Typography & Selection */
html {
    font-family: var(--eywa-font-sans);
    color: var(--eywa-fg);
    background-color: var(--eywa-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--eywa-font-sans);
}

::selection {
    background-color: #e0e7ff;
    color: #1e1b4b;
}

:where(h1, h2, h3, h4) {
    letter-spacing: -0.02em;
}

code, pre, .font-mono {
    font-family: var(--eywa-font-mono);
}

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* Focus Accessibility */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--eywa-primary);
    outline-offset: 2px;
}

/* Zero-specificity Form Control Normalization (replaces missing @tailwindcss/forms on CDN) */
:where(
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="url"],
    input[type="tel"],
    input[type="search"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="time"],
    input:not([type]),
    select,
    textarea
) {
    appearance: none;
    background-color: #ffffff;
    border: 1px solid var(--eywa-border-strong);
    border-radius: var(--eywa-radius-md);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.375rem;
    color: var(--eywa-fg);
    box-shadow: var(--eywa-shadow-2xs);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

:where(
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="url"],
    input[type="tel"],
    input[type="search"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="time"],
    input:not([type]),
    select,
    textarea
):hover:not(:disabled):not(:focus) {
    border-color: #94a3b8;
}

:where(select:not([multiple])) {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.6rem center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
    padding-right: 2.25rem;
}

:where(input, select, textarea)::placeholder {
    color: #94a3b8;
}

:where(
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="url"],
    input[type="tel"],
    input[type="search"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="time"],
    input:not([type]),
    select,
    textarea
):focus {
    outline: none;
    border-color: var(--eywa-primary);
    box-shadow: 0 0 0 3px rgb(79 70 229 / 0.14);
}

:where(input[type="checkbox"], input[type="radio"]) {
    accent-color: var(--eywa-primary);
    cursor: pointer;
}

:where(button, [role="button"], a[href], select, summary) {
    cursor: pointer;
}

:where(button:disabled, input:disabled, select:disabled, textarea:disabled) {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Eywa Component Primitives */
.eywa-card {
    background-color: var(--eywa-surface);
    border: 1px solid var(--eywa-border);
    border-radius: var(--eywa-radius-xl);
    box-shadow: var(--eywa-shadow-xs);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.eywa-card-interactive {
    background-color: var(--eywa-surface);
    border: 1px solid var(--eywa-border);
    border-radius: var(--eywa-radius-xl);
    box-shadow: var(--eywa-shadow-xs);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.eywa-card-interactive:hover {
    border-color: #cbd5e1;
    box-shadow: var(--eywa-shadow-md);
    transform: translateY(-1px);
}

.eywa-card-elevated {
    background-color: var(--eywa-surface);
    border: 1px solid var(--eywa-border);
    border-radius: var(--eywa-radius-xl);
    box-shadow: var(--eywa-shadow-sm);
}

.eywa-card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfd 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.eywa-card-body {
    padding: 1.5rem;
}

.eywa-card-footer {
    padding: 1rem 1.5rem;
    background-color: #f8fafc;
    border-top: 1px solid var(--eywa-border);
    border-bottom-left-radius: var(--eywa-radius-xl);
    border-bottom-right-radius: var(--eywa-radius-xl);
}

/* Standardized Buttons */
.eywa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.375rem;
    padding: 0.5rem 1rem;
    border-radius: var(--eywa-radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    letter-spacing: -0.005em;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}

.eywa-btn:active:not(:disabled) {
    transform: translateY(0.5px);
}

.eywa-btn-sm {
    min-height: 2rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.eywa-btn-primary {
    background: linear-gradient(180deg, #5850ec 0%, #4f46e5 100%);
    color: #ffffff;
    border: 1px solid #4338ca;
    box-shadow: 0 1px 2px 0 rgb(79 70 229 / 0.22), inset 0 1px 0 0 rgb(255 255 255 / 0.16);
}

.eywa-btn-primary:hover:not(:disabled) {
    background: linear-gradient(180deg, #4f46e5 0%, #4338ca 100%);
    border-color: #3730a3;
    box-shadow: 0 3px 8px -1px rgb(79 70 229 / 0.28), inset 0 1px 0 0 rgb(255 255 255 / 0.16);
}

.eywa-btn-secondary {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    color: #334155;
    border: 1px solid var(--eywa-border-strong);
    box-shadow: var(--eywa-shadow-2xs);
}

.eywa-btn-secondary:hover:not(:disabled) {
    background: #f8fafc;
    color: #0f172a;
    border-color: #94a3b8;
    box-shadow: var(--eywa-shadow-xs);
}

.eywa-btn-danger {
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    border: 1px solid #b91c1c;
    box-shadow: 0 1px 2px 0 rgb(220 38 38 / 0.22), inset 0 1px 0 0 rgb(255 255 255 / 0.16);
}

.eywa-btn-danger:hover:not(:disabled) {
    background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%);
}

.eywa-btn-ghost {
    background-color: transparent;
    color: var(--eywa-fg-secondary);
    border: 1px solid transparent;
}

.eywa-btn-ghost:hover:not(:disabled) {
    background-color: var(--eywa-surface-subtle);
    color: var(--eywa-fg);
}

/* Standardized Tables */
.eywa-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.eywa-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.eywa-table thead {
    background-color: #f8fafc;
    border-bottom: 1px solid var(--eywa-border);
}

.eywa-table th {
    padding: 0.75rem 1.25rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.055em;
    color: var(--eywa-fg-muted);
    white-space: nowrap;
}

.eywa-table td {
    padding: 0.875rem 1.25rem;
    font-size: 0.875rem;
    color: var(--eywa-fg);
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.eywa-table tbody tr {
    transition: background-color 0.12s ease;
}

.eywa-table tbody tr:last-child td {
    border-bottom: none;
}

.eywa-table tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.eywa-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.1875rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.125rem;
    border: 1px solid transparent;
    white-space: nowrap;
}

.eywa-badge-primary {
    background-color: #eef2ff;
    color: #3730a3;
    border-color: #c7d2fe;
}

.eywa-badge-success {
    background-color: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.eywa-badge-warning {
    background-color: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

.eywa-badge-danger {
    background-color: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.eywa-badge-info {
    background-color: #f0f9ff;
    color: #075985;
    border-color: #bae6fd;
}

.eywa-badge-neutral {
    background-color: #f1f5f9;
    color: #475569;
    border-color: #e2e8f0;
}

/* Sidebar Navigation */
.eywa-nav-section {
    padding: 1.125rem 0.75rem 0.375rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.065em;
    text-transform: uppercase;
    color: #94a3b8;
}

.eywa-nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5625rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
    border: 1px solid transparent;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
}

.eywa-nav-link:hover {
    background-color: #f8fafc;
    color: #0f172a;
}

.eywa-nav-link.active {
    background: linear-gradient(90deg, #eef2ff 0%, #f5f7ff 100%);
    color: #312e81;
    border-color: #e0e7ff;
    font-weight: 600;
    box-shadow: 0 1px 2px 0 rgb(79 70 229 / 0.04);
}

.eywa-nav-link.active::before {
    content: "";
    position: absolute;
    left: -0.75rem;
    top: 0.375rem;
    bottom: 0.375rem;
    width: 3px;
    border-top-right-radius: 9999px;
    border-bottom-right-radius: 9999px;
    background-color: #4f46e5;
}

.eywa-nav-link .eywa-nav-icon {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    color: #64748b;
    transition: color 0.15s ease;
}

.eywa-nav-link:hover .eywa-nav-icon {
    color: #0f172a;
}

.eywa-nav-link.active .eywa-nav-icon {
    color: #4f46e5;
}

/* Decorative Grid Backdrop for Auth & Hero */
.eywa-bg-grid {
    background-color: #f8fafc;
    background-image:
        radial-gradient(at 50% 0%, rgb(79 70 229 / 0.07) 0px, transparent 55%),
        radial-gradient(at 85% 15%, rgb(8 145 178 / 0.06) 0px, transparent 50%),
        linear-gradient(to right, rgb(226 232 240 / 0.55) 1px, transparent 1px),
        linear-gradient(to bottom, rgb(226 232 240 / 0.55) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
}

/* Official Brand Wordmark (exact colors approved by Eywa board: #22d3ee -> #a5b4fc) */
.eywa-wordmark,
.texto-degradado {
    background: linear-gradient(to right, #22d3ee, #a5b4fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* Subtle Custom Scrollbars */
.eywa-scroll::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.eywa-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.eywa-scroll::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 9999px;
}

.eywa-scroll::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

/* Reduced Motion Respect */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
