/* ============================================================
   ContentViewer document tables — "Refined Amber"
   Palette from the Claude Design handoff (Leave Rules Reader):
   the harsh solid-yellow header is replaced by a dark warm PLATE
   with orange uppercase text + an orange accent line, sitting in
   harmony with the warm orange tinge of the rest of the document.

   Single authoritative source for .ayra-content table styling.
   The injected om.css also sets font-size/padding on
   `table.full-width`, so those use !important here to always win.
   ============================================================ */

.ayra-content table {
    /* ---- Refined Amber tokens (dark) ---- */
    --cvt-accent: #e8912a;        /* primary orange — links, accent */
    --cvt-accent-strong: #f2a23a; /* hover / emphasis */
    --cvt-head-bg: #2a2520;       /* dark warm plate (replaces solid yellow) */
    --cvt-head-text: var(--cvt-accent); /* header text (orange on dark plate) */
    --cvt-head-line: var(--cvt-accent); /* header accent/bottom line */
    --cvt-row-bg: #221f1b;        /* row background */
    --cvt-row-alt: #1f1c18;       /* alternating row */
    --cvt-line: #3a342d;          /* borders / gridlines */
    --cvt-ink: #ece7df;           /* primary cell text */
    --cvt-ink-soft: #b8b0a4;      /* secondary cell text */
    --cvt-row-hover: rgba(232, 145, 42, 0.10);

    /* Force real table layout, full width and centered. !important is required
       to override (a) a legacy `display:block; overflow-x:auto` rule that turned
       the <table> into a block box, and (b) om.css
       `table.auto-width { display:inline-block }` / `.full-width { width:90% }`. */
    display: table !important;
    table-layout: auto;
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    margin: 1.25rem auto !important;

    border-collapse: separate;
    border-spacing: 0;
    background: var(--cvt-row-bg);
    border: 1px solid var(--cvt-line);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
    color: var(--cvt-ink);
    font-size: 0.875rem;
}

/* Let long cell text wrap instead of forcing the table wider than its column */
.ayra-content table th,
.ayra-content table td {
    overflow-wrap: anywhere;
    word-break: normal;
}

/* ---- Dark plate header with orange text + orange accent line ---- */
.ayra-content table thead {
    background: transparent;
}

.ayra-content table th {
    background: var(--cvt-head-bg) !important;
    color: var(--cvt-head-text) !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.8rem !important;
    padding: 0.85rem 0.9rem !important;
    text-align: left;
    border-right: 1px solid var(--cvt-line) !important;
    border-bottom: 2px solid var(--cvt-head-line) !important;
    vertical-align: middle;
}

.ayra-content table th:last-child {
    border-right: none !important;
}

/* ---- Body cells ---- */
.ayra-content table td {
    padding: 0.85rem 0.9rem !important;
    color: var(--cvt-ink-soft) !important;
    border-right: 1px solid var(--cvt-line);
    border-bottom: 1px solid var(--cvt-line);
    vertical-align: top;
    line-height: 1.5;
}

.ayra-content table td:last-child {
    border-right: none;
}

/* Accent the index / serial column in orange */
.ayra-content table tbody td:first-child {
    color: var(--cvt-accent) !important;
    font-weight: 700;
}

.ayra-content table tbody tr {
    transition: background-color 0.2s ease;
}

.ayra-content table tbody tr:nth-child(even) {
    background-color: var(--cvt-row-alt);
}

.ayra-content table tbody tr:hover {
    background-color: var(--cvt-row-hover);
}

.ayra-content table tbody tr:last-child td {
    border-bottom: none;
}

/* Links inside content tables follow the amber accent */
.ayra-content table a {
    color: var(--cvt-accent);
    font-weight: 600;
}

.ayra-content table a:hover {
    color: var(--cvt-accent-strong);
}

/* Caption */
.ayra-content table caption {
    caption-side: top;
    padding: 0.5rem 0;
    font-weight: 700;
    color: var(--cvt-ink);
    font-size: 1rem;
}

/* Numeric helper */
.ayra-content table .numeric {
    text-align: right;
    font-family: 'Roboto Mono', 'Courier New', monospace;
}

/* Width variants emitted in om content */
.ayra-content table.full-width {
    width: 100%;
    margin: 1.25rem auto;
}

.ayra-content table.auto-width {
    width: auto;
    margin: 1.25rem auto;
}

/* Wrapper that processTables() adds around every <table>. It ONLY handles
   horizontal overflow — the <table> itself is the card, so this must stay
   transparent (no border/radius/shadow/bg), otherwise it renders as a second,
   outer "container" around the table. */
.ayra-content .table-container {
    overflow-x: auto;
    max-width: 100%;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    padding: 0;
}

/* ---- Light theme ---- */
[data-theme="light"] .ayra-content table {
    --cvt-accent: #a9761f;        /* Cool Linen gold (serial column / accent) */
    --cvt-accent-strong: #936414;
    --cvt-head-bg: #a9761f;       /* Cool Linen gold header plate */
    --cvt-head-text: #ffffff;     /* white header text */
    --cvt-head-line: rgba(147, 100, 20, 0.55); /* deeper-gold accent line */
    --cvt-row-bg: transparent;    /* base rows transparent */
    --cvt-row-alt: #fafaf8;       /* linen alternating row */
    --cvt-line: var(--border-color);
    --cvt-ink: #272a2c;           /* Cool Linen primary text */
    --cvt-ink-soft: #565b5e;      /* Cool Linen secondary text */
    --cvt-row-hover: rgba(176, 125, 36, 0.08); /* gold-soft hover */
    box-shadow: 0 4px 16px rgba(40, 50, 60, 0.10);
}

/* Light mode only: first (serial) column text in Cool Linen ink */
[data-theme="light"] .ayra-content table tbody td:first-child {
    color: #272a2c !important;
}

/* ---- Content links follow the active theme's EXACT link colour (var(--link-color)).
   `!important` overrides the amber from om.css / the table accent. Covers all
   content links (table links included, since they live inside .ayra-content),
   in every theme/palette (Cool Linen, Warm Paper, Sand & Ink, Dark, Oak, Slate, Espresso). ---- */
.ayra-content a {
    color: var(--link-color) !important;
}

.ayra-content a:hover {
    color: var(--link-color) !important;
    text-decoration: underline;
}

/* ---- Table reveal animation ---- */
@keyframes tableSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .ayra-content table {
        font-size: 0.8rem;
    }

    .ayra-content table th,
    .ayra-content table td {
        padding: 0.6rem 0.55rem !important;
    }

    .ayra-content table th {
        font-size: 0.72rem !important;
    }
}

@media (max-width: 480px) {
    .ayra-content table {
        font-size: 0.75rem;
    }

    .ayra-content table th,
    .ayra-content table td {
        padding: 0.5rem 0.4rem !important;
    }
}
