/**
 * ============================================
 * Dashboard Components
 * Cards, Buttons, Tables, Modals, Utilities
 * ============================================
 */

/* === CARDS === */
.card {
    background: var(--md-white);
    border: 1px solid var(--md-border);
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-header {
    background: var(--md-gray-50);
    border-bottom: 1px solid var(--md-border);
    padding: 15px 20px;
    font-weight: 600;
    color: var(--md-text);
}

.card-body {
    padding: 20px;
}

/* === BUTTONS === */
.btn-primary {
    background-color: var(--btn-primary, var(--md-blue));
    border-color: var(--btn-primary, var(--md-blue));
    color: #ffffff;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background-color: var(--md-blue-hover);
    border-color: var(--md-blue-hover);
    box-shadow: 0 2px 8px rgba(15, 120, 165, 0.25);
}

.btn-secondary {
    background-color: var(--btn-secondary, var(--md-gray-500));
    border-color: var(--btn-secondary, var(--md-gray-500));
    color: #ffffff;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    opacity: 0.9;
}

.btn-outline-primary {
    background-color: transparent;
    border: 1px solid var(--btn-primary, var(--md-blue));
    color: var(--btn-primary, var(--md-blue));
}

.btn-outline-primary:hover {
    background-color: var(--btn-primary, var(--md-blue));
    color: #ffffff;
}

/* Smooth transitions for all interactive elements */
a, button, .btn {
    transition: all 0.2s ease;
}

/* Better focus visibility for accessibility */
a:focus-visible, button:focus-visible {
    outline: 2px solid var(--md-blue);
    outline-offset: 2px;
}

/* === TABLES === */
.table {
    color: var(--md-text);
    background: var(--md-white);
}

.table thead th {
    background-color: var(--md-gray-50);
    border-color: var(--md-border);
    color: var(--md-text);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background-color: rgba(15, 120, 165, 0.04);
}

.table tbody td a {
    color: var(--md-blue);
}

.table tbody td a:hover {
    color: var(--md-blue-hover);
    text-decoration: underline;
}

/* === STICKY TABLE HEADERS === */
.table-sticky-wrapper {
    position: relative;
    overflow-x: auto;
    max-height: calc(100vh - 200px);
}

.table-sticky-header thead {
    /* Keep thead normal; we stick per-row to support multi-row headers (filters, headings) */
    position: static;
}

.table-sticky-header thead tr:first-child th {
    position: sticky;
    top: var(--md-fixed-header-height, 110px);
    background: var(--md-gray-50);
    border-bottom: 2px solid var(--md-border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 101;
}

.table-sticky-header thead tr.filters th {
    position: sticky;
    top: calc(var(--md-fixed-header-height, 110px) + var(--md-sticky-table-header-row-height, 48px));
    background: var(--md-white);
    border-bottom: 2px solid var(--md-border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 100;
    padding: 8px;
}

/* Support tables where the 2nd header row is not named ".filters" (e.g. rooms headings row) */
.table-sticky-header thead tr:nth-child(2) th {
    position: sticky;
    top: calc(var(--md-fixed-header-height, 110px) + var(--md-sticky-table-header-row-height, 48px));
    z-index: 100;
}

.table-sticky-header thead tr.filters th input,
.table-sticky-header thead tr.filters th select {
    background: var(--md-white);
    border: 1px solid var(--md-border);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 12px;
    width: 100%;
}

.table-sticky-header thead tr.filters th input:focus,
.table-sticky-header thead tr.filters th select:focus {
    outline: none;
    border-color: var(--md-blue);
    box-shadow: 0 0 0 3px rgba(15, 120, 165, 0.1);
}

/* === DATATABLES SCROLLER OVERRIDE ===
 * When DataTables uses scrollY/Scroller, it handles headers in a separate container.
 * Sticky positioning MUST be disabled to prevent a large white gap.
 */
.dataTables_scrollHead table.table-sticky-header thead th,
.dataTables_scrollBody table.table-sticky-header thead th,
.dataTables_scrollHead table.table-sticky-header thead tr:first-child th,
.dataTables_scrollBody table.table-sticky-header thead tr:first-child th,
.dataTables_scrollHead table.table-sticky-header thead tr:nth-child(2) th,
.dataTables_scrollBody table.table-sticky-header thead tr:nth-child(2) th,
.dataTables_scrollHead table.table-sticky-header thead tr.filters th,
.dataTables_scrollBody table.table-sticky-header thead tr.filters th {
    position: static !important;
    top: auto !important;
    box-shadow: none !important;
}

/* === MODAL STYLES === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    display: none;
    width: 100%;
    height: 100%;
    overflow: hidden;
    outline: 0;
}

.modal.fade {
    transition: opacity 0.15s linear;
}

.modal.fade:not(.show) {
    opacity: 0;
}

.modal.show {
    display: block;
}

.modal-dialog {
    position: relative;
    width: auto;
    margin: 1.75rem auto;
    max-width: 500px;
    pointer-events: none;
}

.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
    transform: translate(0, -50px);
}

.modal.show .modal-dialog {
    transform: none;
}

.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background-color: var(--md-white);
    background-clip: padding-box;
    border: 1px solid var(--md-border);
    border-radius: 0.3rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    outline: 0;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: 100vw;
    height: 100vh;
    background-color: #000;
}

.modal-backdrop.fade {
    opacity: 0;
}

.modal-backdrop.show {
    opacity: 0.5;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--md-border);
    border-top-left-radius: calc(0.3rem - 1px);
    border-top-right-radius: calc(0.3rem - 1px);
}

.modal-header .close {
    padding: 1rem;
    margin: -1rem -1rem -1rem auto;
}

.modal-title {
    margin-bottom: 0;
    line-height: 1.5;
}

.modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1rem;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 1rem;
    border-top: 1px solid var(--md-border);
    border-bottom-right-radius: calc(0.3rem - 1px);
    border-bottom-left-radius: calc(0.3rem - 1px);
}

.modal-footer > :not(:first-child) {
    margin-left: 0.25rem;
}

.modal-footer > :not(:last-child) {
    margin-right: 0.25rem;
}

@media (min-width: 576px) {
    .modal-dialog {
        max-width: 500px;
        margin: 1.75rem auto;
    }
}

.modal-lg {
    max-width: 800px;
}

.modal-xl {
    max-width: 1140px;
}

/* === FOOTER === */
.es_footer {
    background: var(--md-white);
    border-top: 1px solid var(--md-border);
    padding: 20px;
    margin-top: 40px;
    text-align: center;
    color: var(--md-text-light);
    font-size: 12px;
}

.es_footer a {
    color: var(--md-blue);
    text-decoration: none;
}

.es_footer a:hover {
    color: var(--md-blue-hover);
    text-decoration: underline;
}

/* === SHARED UTILITY STYLES === */
.badge-lg {
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
}

.border-left-primary {
    border-left: 4px solid #4e73df !important;
}

.border-left-info {
    border-left: 4px solid #36b9cc !important;
}

