/**
 * Responsive Table Component - Modern Campus CMS
 * A flexible, accessible table component with multiple responsive modes
 *
 * Version: 1.0.0
 * Author: HCCC Web Development
 *
 * Features:
 * - Three responsive modes: scroll, stack, collapse
 * - Five institutional themes
 * - Multiple header styles
 * - Accessibility compliant (WCAG 2.1 AA)
 * - CSS custom properties for easy theming
 *
 * Table of Contents:
 * 1. CSS Custom Properties
 * 2. Base Container Styles
 * 3. Table Structure
 * 4. Header Styles
 * 5. Body Styles
 * 6. Footer Styles
 * 7. Responsive Mode: Scroll
 * 8. Responsive Mode: Stack
 * 9. Responsive Mode: Collapse
 * 10. Modifier Classes
 * 11. Theme Variations
 * 12. Accessibility
 * 13. Print Styles
 * 14. Animations
 */

/* ==========================================================================
   1. CSS Custom Properties
   ========================================================================== */

:root {
    /* Color Scheme - Default Theme */
    --rt-bg: #ffffff;
    --rt-color: #333333;
    --rt-border-color: #dee2e6;
    --rt-header-bg: #f8f9fa;
    --rt-header-color: #333333;
    --rt-header-border: #dee2e6;
    --rt-row-bg: #ffffff;
    --rt-row-alt-bg: #f8f9fa;
    --rt-row-hover-bg: #e9ecef;
    --rt-footer-bg: #f8f9fa;
    --rt-footer-color: #666666;
    --rt-caption-color: #666666;

    /* HCCC Brand Colors */
    --rt-hccc-teal: #00857a;
    --rt-hccc-teal-dark: #006b62;
    --rt-hccc-blue: #2b3990;
    --rt-hccc-blue-dark: #1d2974;
    --rt-hccc-yellow: #fff200;
    --rt-hccc-black: #1a1a1a;
    --rt-hccc-gold: #d4af37;
    --rt-hccc-gold-dark: #b8962f;

    /* Layout */
    --rt-padding: 12px 16px;
    --rt-padding-compact: 8px 12px;
    --rt-padding-spacious: 16px 24px;
    --rt-border-radius: 8px;
    --rt-border-width: 1px;
    --rt-gap: 1rem;

    /* Typography */
    --rt-font-family: "Montserrat", Arial, Helvetica, sans-serif;
    --rt-font-size: 16px;
    --rt-font-size-small: 14px;
    --rt-font-size-header: 16px;
    --rt-font-weight-normal: 400;
    --rt-font-weight-medium: 500;
    --rt-font-weight-bold: 700;
    --rt-font-weight-header: 700;
    --rt-line-height: 1.5;
    --rt-heading-size: 24px;
    --rt-heading-weight: 800;

    /* Effects */
    --rt-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --rt-shadow-hover: 0 4px 8px rgba(0, 0, 0, 0.15);
    --rt-transition: all 0.3s ease;

    /* Accessibility */
    --rt-focus-color: #0066cc;
    --rt-focus-width: 2px;
    --rt-focus-offset: 2px;

    /* Scroll Hint */
    --rt-scroll-hint-bg: rgba(0, 0, 0, 0.7);
    --rt-scroll-hint-color: #ffffff;
}

/* ==========================================================================
   2. Base Container Styles
   ========================================================================== */

.responsive-table-container {
    font-family: var(--rt-font-family);
    font-size: var(--rt-font-size);
    line-height: var(--rt-line-height);
    color: var(--rt-color);
    margin-bottom: var(--rt-gap);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.responsive-table__header {
    margin-bottom: 1rem;
}

.responsive-table__heading {
    font-size: var(--rt-heading-size);
    font-weight: var(--rt-heading-weight);
    line-height: 1.2;
    margin: 0;
    color: var(--rt-color);
}

.responsive-table__wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--rt-border-radius);
    box-shadow: var(--rt-shadow);
}

/* ==========================================================================
   3. Table Structure
   ========================================================================== */

.responsive-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--rt-bg);
    border-radius: var(--rt-border-radius);
    overflow: hidden;
}

.responsive-table__caption {
    caption-side: top;
    padding: var(--rt-padding);
    font-size: var(--rt-font-size-small);
    color: var(--rt-caption-color);
    text-align: left;
    font-style: italic;
}

/* ==========================================================================
   4. Header Styles
   ========================================================================== */

.responsive-table__thead {
    background: var(--rt-header-bg);
}

.responsive-table__header-row {
    border-bottom: 2px solid var(--rt-header-border);
}

.responsive-table__th {
    padding: var(--rt-padding);
    font-size: var(--rt-font-size-header);
    font-weight: var(--rt-font-weight-header);
    color: var(--rt-header-color);
    text-align: left;
    white-space: nowrap;
    vertical-align: middle;
}

/* Header Alignment */
.responsive-table__th--left {
    text-align: left;
}

.responsive-table__th--center {
    text-align: center;
}

.responsive-table__th--right {
    text-align: right;
}

/* Header Style Variations */
.responsive-table--header-dark .responsive-table__thead {
    background: var(--rt-hccc-black);
}

.responsive-table--header-dark .responsive-table__th {
    color: #ffffff;
}

.responsive-table--header-dark .responsive-table__header-row {
    border-bottom-color: #333333;
}

.responsive-table--header-light .responsive-table__thead {
    background: #ffffff;
}

.responsive-table--header-light .responsive-table__th {
    color: var(--rt-color);
    border-bottom: 2px solid var(--rt-border-color);
}

.responsive-table--header-primary .responsive-table__thead {
    background: var(--rt-hccc-teal);
}

.responsive-table--header-primary .responsive-table__th {
    color: #ffffff;
}

.responsive-table--header-primary .responsive-table__header-row {
    border-bottom-color: var(--rt-hccc-teal-dark);
}

.responsive-table--header-secondary .responsive-table__thead {
    background: var(--rt-hccc-blue);
}

.responsive-table--header-secondary .responsive-table__th {
    color: #ffffff;
}

.responsive-table--header-secondary .responsive-table__header-row {
    border-bottom-color: var(--rt-hccc-blue-dark);
}

/* ==========================================================================
   5. Body Styles
   ========================================================================== */

.responsive-table__tbody {
    background: var(--rt-row-bg);
}

.responsive-table__row {
    border-bottom: var(--rt-border-width) solid var(--rt-border-color);
    transition: var(--rt-transition);
}

.responsive-table__row:last-child {
    border-bottom: none;
}

.responsive-table__td {
    padding: var(--rt-padding);
    font-size: var(--rt-font-size);
    font-weight: var(--rt-font-weight-normal);
    color: var(--rt-color);
    vertical-align: middle;
}

/* Cell Alignment */
.responsive-table__td--left {
    text-align: left;
}

.responsive-table__td--center {
    text-align: center;
}

.responsive-table__td--right {
    text-align: right;
}

/* ==========================================================================
   6. Footer Styles
   ========================================================================== */

.responsive-table__tfoot {
    background: var(--rt-footer-bg);
    border-top: 2px solid var(--rt-border-color);
}

.responsive-table__footer-row {
    /* No additional styles needed */
}

.responsive-table__footer-cell {
    padding: var(--rt-padding);
    font-size: var(--rt-font-size-small);
    color: var(--rt-footer-color);
    font-style: italic;
}

/* ==========================================================================
   7. Responsive Mode: Scroll
   ========================================================================== */

.responsive-table--scroll {
    min-width: 600px;
}

.responsive-table__scroll-hint {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    margin-top: 8px;
    background: var(--rt-scroll-hint-bg);
    color: var(--rt-scroll-hint-color);
    border-radius: 20px;
    font-size: var(--rt-font-size-small);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.responsive-table__scroll-hint i {
    animation: scrollHintPulse 1.5s ease-in-out infinite;
}

/* Show scroll hint on mobile */
@media (max-width: 767px) {
    .responsive-table-container:has(.responsive-table--scroll) .responsive-table__scroll-hint {
        display: flex;
    }
}

/* ==========================================================================
   8. Responsive Mode: Stack
   ========================================================================== */

@media (max-width: 767px) {
    .responsive-table--stack {
        min-width: 0;
    }

    .responsive-table--stack .responsive-table__thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .responsive-table--stack .responsive-table__row {
        display: block;
        margin-bottom: 1rem;
        border: var(--rt-border-width) solid var(--rt-border-color);
        border-radius: var(--rt-border-radius);
        box-shadow: var(--rt-shadow);
    }

    .responsive-table--stack .responsive-table__row:last-child {
        margin-bottom: 0;
        border-bottom: var(--rt-border-width) solid var(--rt-border-color);
    }

    .responsive-table--stack .responsive-table__td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: var(--rt-padding);
        border-bottom: var(--rt-border-width) solid var(--rt-border-color);
        text-align: right;
    }

    .responsive-table--stack .responsive-table__td:last-child {
        border-bottom: none;
    }

    .responsive-table--stack .responsive-table__td::before {
        content: attr(data-label);
        font-weight: var(--rt-font-weight-bold);
        color: var(--rt-header-color);
        text-align: left;
        flex-shrink: 0;
        margin-right: 1rem;
    }

    .responsive-table--stack .responsive-table__td--hide-mobile,
    .responsive-table--stack .responsive-table__cell--hide-mobile {
        display: none;
    }

    /* Stack mode alignment overrides */
    .responsive-table--stack .responsive-table__td--left,
    .responsive-table--stack .responsive-table__td--center,
    .responsive-table--stack .responsive-table__td--right {
        text-align: right;
    }

    /* Stack mode scroll hint hidden */
    .responsive-table-container:has(.responsive-table--stack) .responsive-table__scroll-hint {
        display: none;
    }
}

/* ==========================================================================
   9. Responsive Mode: Collapse
   ========================================================================== */

@media (max-width: 767px) {
    .responsive-table--collapse {
        min-width: 0;
    }

    .responsive-table--collapse .responsive-table__cell--hide-mobile,
    .responsive-table--collapse .responsive-table__th--hide-mobile {
        display: none;
    }

    .responsive-table--collapse .responsive-table__th,
    .responsive-table--collapse .responsive-table__td {
        padding: var(--rt-padding-compact);
        font-size: var(--rt-font-size-small);
    }

    /* Collapse mode scroll hint hidden */
    .responsive-table-container:has(.responsive-table--collapse) .responsive-table__scroll-hint {
        display: none;
    }
}

/* ==========================================================================
   10. Modifier Classes
   ========================================================================== */

/* Striped Rows */
.responsive-table--striped .responsive-table__row:nth-child(even) {
    background: var(--rt-row-alt-bg);
}

/* Hover Effect */
.responsive-table--hover .responsive-table__row:hover {
    background: var(--rt-row-hover-bg);
}

/* Bordered */
.responsive-table--bordered .responsive-table__th,
.responsive-table--bordered .responsive-table__td {
    border: var(--rt-border-width) solid var(--rt-border-color);
}

/* Compact */
.responsive-table--compact .responsive-table__th,
.responsive-table--compact .responsive-table__td {
    padding: var(--rt-padding-compact);
    font-size: var(--rt-font-size-small);
}

/* Spacious */
.responsive-table--spacious .responsive-table__th,
.responsive-table--spacious .responsive-table__td {
    padding: var(--rt-padding-spacious);
}

/* ==========================================================================
   11. Theme Variations
   ========================================================================== */

/* HCCC Primary (Teal) */
.responsive-table--hccc-primary {
    --rt-header-bg: var(--rt-hccc-teal);
    --rt-header-color: #ffffff;
    --rt-header-border: var(--rt-hccc-teal-dark);
    --rt-row-hover-bg: rgba(0, 133, 122, 0.08);
}

.responsive-table--hccc-primary .responsive-table__row:nth-child(even) {
    background: rgba(0, 133, 122, 0.04);
}

.responsive-table--hccc-primary a {
    color: var(--rt-hccc-teal);
}

.responsive-table--hccc-primary a:hover {
    color: var(--rt-hccc-teal-dark);
}

/* HCCC Secondary (Blue) */
.responsive-table--hccc-secondary {
    --rt-header-bg: var(--rt-hccc-blue);
    --rt-header-color: #ffffff;
    --rt-header-border: var(--rt-hccc-blue-dark);
    --rt-row-hover-bg: rgba(43, 57, 144, 0.08);
}

.responsive-table--hccc-secondary .responsive-table__row:nth-child(even) {
    background: rgba(43, 57, 144, 0.04);
}

.responsive-table--hccc-secondary a {
    color: var(--rt-hccc-blue);
}

.responsive-table--hccc-secondary a:hover {
    color: var(--rt-hccc-blue-dark);
}

/* Anniversary (Black & Gold) */
.responsive-table--anniversary {
    --rt-header-bg: var(--rt-hccc-black);
    --rt-header-color: var(--rt-hccc-gold);
    --rt-header-border: #333333;
    --rt-border-color: #333333;
    --rt-row-hover-bg: rgba(212, 175, 55, 0.1);
}

.responsive-table--anniversary .responsive-table__row:nth-child(even) {
    background: rgba(26, 26, 26, 0.03);
}

.responsive-table--anniversary a {
    color: var(--rt-hccc-gold);
}

.responsive-table--anniversary a:hover {
    color: var(--rt-hccc-gold-dark);
}

.responsive-table--anniversary .responsive-table__heading {
    color: var(--rt-hccc-black);
}

/* Anniversary Gold */
.responsive-table--anniversary-gold {
    --rt-header-bg: var(--rt-hccc-gold);
    --rt-header-color: var(--rt-hccc-black);
    --rt-header-border: var(--rt-hccc-gold-dark);
    --rt-row-hover-bg: rgba(212, 175, 55, 0.15);
    --rt-border-color: var(--rt-hccc-gold-dark);
}

.responsive-table--anniversary-gold .responsive-table__row:nth-child(even) {
    background: rgba(212, 175, 55, 0.08);
}

.responsive-table--anniversary-gold a {
    color: var(--rt-hccc-black);
    text-decoration: underline;
}

.responsive-table--anniversary-gold a:hover {
    color: var(--rt-hccc-gold-dark);
}

.responsive-table--anniversary-gold .responsive-table__heading {
    color: var(--rt-hccc-gold-dark);
}

/* ==========================================================================
   12. Accessibility
   ========================================================================== */

/* Focus Indicators */
.responsive-table a:focus,
.responsive-table button:focus {
    outline: var(--rt-focus-width) solid var(--rt-focus-color);
    outline-offset: var(--rt-focus-offset);
}

.responsive-table__row:focus-within {
    outline: var(--rt-focus-width) solid var(--rt-focus-color);
    outline-offset: calc(-1 * var(--rt-focus-width));
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .responsive-table {
        border: 2px solid currentColor;
    }

    .responsive-table__th,
    .responsive-table__td {
        border: 1px solid currentColor;
    }

    .responsive-table__row:hover {
        outline: 2px solid currentColor;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .responsive-table,
    .responsive-table__row,
    .responsive-table__scroll-hint i {
        transition: none;
        animation: none;
    }
}

/* Screen Reader Only */
.responsive-table .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip Link Target */
.responsive-table-container:target {
    outline: var(--rt-focus-width) solid var(--rt-focus-color);
    outline-offset: 4px;
}

/* ==========================================================================
   13. Print Styles
   ========================================================================== */

@media print {
    .responsive-table-container {
        page-break-inside: avoid;
    }

    .responsive-table__wrapper {
        overflow: visible;
        box-shadow: none;
    }

    .responsive-table {
        min-width: 0 !important;
        border: 1px solid #000000;
    }

    .responsive-table__th,
    .responsive-table__td {
        border: 1px solid #000000;
        padding: 8px;
    }

    .responsive-table__thead {
        background: #e0e0e0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .responsive-table__th {
        color: #000000 !important;
    }

    .responsive-table--striped .responsive-table__row:nth-child(even) {
        background: #f5f5f5 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .responsive-table__scroll-hint {
        display: none !important;
    }

    /* Stack mode prints as table */
    .responsive-table--stack .responsive-table__thead {
        position: static;
        width: auto;
        height: auto;
        margin: 0;
        clip: auto;
    }

    .responsive-table--stack .responsive-table__row {
        display: table-row;
        margin: 0;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    .responsive-table--stack .responsive-table__td {
        display: table-cell;
        text-align: left;
    }

    .responsive-table--stack .responsive-table__td::before {
        display: none;
    }

    /* Show hidden columns in print */
    .responsive-table__cell--hide-mobile,
    .responsive-table__th--hide-mobile {
        display: table-cell !important;
    }
}

/* ==========================================================================
   14. Animations
   ========================================================================== */

@keyframes scrollHintPulse {
    0%, 100% {
        transform: translateX(0);
        opacity: 1;
    }
    50% {
        transform: translateX(4px);
        opacity: 0.7;
    }
}

/* Row Fade In (optional enhancement) */
@keyframes rowFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.responsive-table--animated .responsive-table__row {
    animation: rowFadeIn 0.3s ease forwards;
}

.responsive-table--animated .responsive-table__row:nth-child(1) { animation-delay: 0.05s; }
.responsive-table--animated .responsive-table__row:nth-child(2) { animation-delay: 0.1s; }
.responsive-table--animated .responsive-table__row:nth-child(3) { animation-delay: 0.15s; }
.responsive-table--animated .responsive-table__row:nth-child(4) { animation-delay: 0.2s; }
.responsive-table--animated .responsive-table__row:nth-child(5) { animation-delay: 0.25s; }
.responsive-table--animated .responsive-table__row:nth-child(6) { animation-delay: 0.3s; }
.responsive-table--animated .responsive-table__row:nth-child(7) { animation-delay: 0.35s; }
.responsive-table--animated .responsive-table__row:nth-child(8) { animation-delay: 0.4s; }
.responsive-table--animated .responsive-table__row:nth-child(9) { animation-delay: 0.45s; }
.responsive-table--animated .responsive-table__row:nth-child(10) { animation-delay: 0.5s; }

/* ==========================================================================
   15. Responsive Breakpoints - Tablet
   ========================================================================== */

@media (min-width: 768px) {
    :root {
        --rt-heading-size: 28px;
        --rt-font-size: 16px;
        --rt-padding: 14px 18px;
    }

    .responsive-table__scroll-hint {
        display: none;
    }
}

/* ==========================================================================
   16. Responsive Breakpoints - Desktop
   ========================================================================== */

@media (min-width: 1024px) {
    :root {
        --rt-heading-size: 32px;
        --rt-padding: 16px 20px;
    }

    .responsive-table__wrapper {
        overflow: visible;
    }
}

/* ==========================================================================
   17. Dark Mode Support (Future Enhancement)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .responsive-table--auto-dark {
        --rt-bg: #1e1e1e;
        --rt-color: #e0e0e0;
        --rt-border-color: #444444;
        --rt-header-bg: #2d2d2d;
        --rt-header-color: #ffffff;
        --rt-header-border: #444444;
        --rt-row-bg: #1e1e1e;
        --rt-row-alt-bg: #252525;
        --rt-row-hover-bg: #333333;
        --rt-footer-bg: #2d2d2d;
        --rt-footer-color: #aaaaaa;
        --rt-caption-color: #aaaaaa;
        --rt-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
}

/* ==========================================================================
   18. Utility Classes
   ========================================================================== */

/* Text utilities for cell content */
.responsive-table .text-nowrap {
    white-space: nowrap;
}

.responsive-table .text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.responsive-table .text-bold {
    font-weight: var(--rt-font-weight-bold);
}

.responsive-table .text-muted {
    color: var(--rt-caption-color);
}

.responsive-table .text-success {
    color: #28a745;
}

.responsive-table .text-warning {
    color: #ffc107;
}

.responsive-table .text-danger {
    color: #dc3545;
}

.responsive-table .text-info {
    color: var(--rt-hccc-teal);
}

/* Badge utilities */
.responsive-table .badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: var(--rt-font-weight-medium);
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.responsive-table .badge--primary {
    background: var(--rt-hccc-teal);
    color: #ffffff;
}

.responsive-table .badge--secondary {
    background: var(--rt-hccc-blue);
    color: #ffffff;
}

.responsive-table .badge--success {
    background: #28a745;
    color: #ffffff;
}

.responsive-table .badge--warning {
    background: #ffc107;
    color: #000000;
}

.responsive-table .badge--danger {
    background: #dc3545;
    color: #ffffff;
}

/* Icon utilities */
.responsive-table .icon-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.responsive-table .icon-cell i {
    font-size: 1.2em;
    color: var(--rt-hccc-teal);
}

/* Link styles within tables */
.responsive-table a {
    color: var(--rt-hccc-teal);
    font-weight: var(--rt-font-weight-bold);
    text-decoration: none;
    transition: color 0.3s ease;
}

.responsive-table a:hover {
    color: var(--rt-hccc-blue);
    text-decoration: underline;
}

/* Button styles within tables */
.responsive-table .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: var(--rt-font-size-small);
    font-weight: var(--rt-font-weight-medium);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--rt-transition);
}

.responsive-table .btn--primary {
    background: var(--rt-hccc-teal);
    color: #ffffff;
}

.responsive-table .btn--primary:hover {
    background: var(--rt-hccc-teal-dark);
}

.responsive-table .btn--secondary {
    background: var(--rt-hccc-blue);
    color: #ffffff;
}

.responsive-table .btn--secondary:hover {
    background: var(--rt-hccc-blue-dark);
}

.responsive-table .btn--outline {
    background: transparent;
    border: 2px solid var(--rt-hccc-teal);
    color: var(--rt-hccc-teal);
}

.responsive-table .btn--outline:hover {
    background: var(--rt-hccc-teal);
    color: #ffffff;
}

.responsive-table .btn--small {
    padding: 4px 8px;
    font-size: 12px;
}
