/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Montserrat - self-hosted (latin subset, 400 + 700) */
@font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/montserrat-400.woff2') format('woff2');
}

@font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('fonts/montserrat-700.woff2') format('woff2');
}

html, body {
    font-family: "Montserrat", Arial, sans-serif;
    color: #333;
    background-color: #f5f5f5;
    height: 100%;
}

/* Form controls should inherit the page font, not the UA default */
input, button, select, textarea {
    font-family: inherit;
}

header {
    background-color: white;
    color: #333;
    padding: 15px 0;
    border-bottom: 1px solid #ccc;
}

header .secondary-links {
    background-color: white;
    padding: 8px 20px 0;
    text-align: right;
}

header .secondary-links .menu {
    list-style: none;
    display: flex;
    justify-content: flex-end;
}

/* Bordered "tab" look, matching the old site */
header .secondary-links .menu li {
    border: 1px solid #ccc;
    border-bottom: none;
    margin-left: -1px;
}

header .secondary-links a {
    display: inline-block;
    color: #888;
    text-decoration: none;
    font-size: 11px;
    line-height: 1;
    text-transform: uppercase;
    padding: 8px 18px;
    background: #fff;
}

header .secondary-links a:hover {
    background: #ededed;
}

.l-region--navigation {
    background-color: white;
    padding: 10px 20px;
}

/* Bordered menu bar, matching the old site */
.tb-megamenu-nav {
    list-style: none;
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 50px;
    width: 100%;
    border: 1px solid #ccc;
}

.tb-megamenu-item {
    display: flex;
    align-items: center;
    height: 50px;
}

.tb-megamenu-item a {
    color: #444;
    text-decoration: none;
    font-weight: normal;
    font-size: 14px;
    text-transform: uppercase;
    padding: 14px;
    white-space: nowrap;
}

.tb-megamenu-item a:hover {
    color: #000;
    text-decoration: none;
}

/* ALMD "home" link is the large branded item */
.tb-megamenu-item.menu__item--home a {
    font-size: 30px;
    font-weight: 700;
    padding: 1px;
}

/* Main Content */
.wrapper-public {
    max-width: 1600px;
    margin: 20px auto;
    padding: 0 20px;
}

/* Toolbar */
.well {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 20px;
}

.list-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.calendarTitle {
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

.pull-left {
    float: left;
}

.row {
    display: flex;
    width: 100%;
}

.col-md-12 {
    flex: 1;
}

/* Search Filters */
.search-filters {
    background-color: #f5f5f5;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 0;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 3px;
    font-weight: bold;
    color: #000;
    font-size: 13px;
}

.form-group input.form-control {
    padding: 5px 8px;
    border: 1px solid #999;
    border-radius: 0;
    font-size: 13px;
    font-family: Arial, sans-serif;
    width: 180px;
}

.form-group input.form-control:focus {
    outline: none;
    border-color: #666;
    background-color: #ffffcc;
}

.btn {
    padding: 5px 14px;
    border: 1px solid #999;
    border-radius: 0;
    font-size: 13px;
    cursor: pointer;
    font-weight: normal;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #666;
    color: white;
    border-color: #666;
}

.btn-primary:hover {
    background-color: #555;
    border-color: #555;
}

.btn-secondary {
    background-color: #999;
    color: white;
    border-color: #999;
    margin-left: 10px;
}

.btn-secondary:hover {
    background-color: #888;
    border-color: #888;
}

/* Results Table */
.events-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    table-layout: auto;
}

.events-table thead {
    background-color: #f0f0f0;
    color: #000;
}

.events-table th {
    padding: 6px 8px;
    text-align: left;
    font-weight: bold;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.events-table th:last-child {
    border-right: none;
}

/* Auto layout sizes each column to its content. The short columns get
   width:1% + nowrap: since nowrap stops them shrinking below their content,
   width:1% makes them collapse to EXACTLY their widest value and refuse any
   extra table width - so all the slack from the full-width table flows into
   Title (5) and Description (7), which are allowed to wrap. */
.events-table th:nth-child(1), .events-table td:nth-child(1),  /* Date */
.events-table th:nth-child(2), .events-table td:nth-child(2),  /* Time */
.events-table th:nth-child(3), .events-table td:nth-child(3),  /* Case Number */
.events-table th:nth-child(4), .events-table td:nth-child(4),  /* Judge */
.events-table th:nth-child(6), .events-table td:nth-child(6) { /* Location */
    white-space: nowrap;
    width: 1%;
}

.events-table td {
    padding: 6px 8px;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    word-wrap: break-word;
    font-size: 13px;
    overflow: hidden;
}

.events-table td:last-child {
    border-right: none;
}

.events-table tbody tr {
    background-color: white;
}

.events-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.events-table tbody tr:hover {
    background-color: #f9f9f9;
}

/* Disclaimer modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: #fff;
    width: 90%;
    max-width: 520px;
    border: 1px solid #ccc;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
}

.modal-box-header {
    padding: 12px 20px;
    border-bottom: 1px solid #ddd;
}

.modal-box-header h4 {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.modal-box-body {
    padding: 18px 20px;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

.modal-box-footer {
    padding: 12px 20px;
    border-top: 1px solid #ddd;
    text-align: right;
}

/* Empty Results */
.empty-results {
    background-color: white;
    padding: 20px;
    text-align: center;
    border: 1px solid #ccc;
    color: #666;
    font-size: 13px;
}

.loading {
    background-color: white;
    padding: 20px;
    text-align: center;
    border: 1px solid #ccc;
    color: #666;
    font-size: 13px;
}

.error {
    background-color: #fee;
    padding: 12px;
    color: #c33;
    font-size: 13px;
    border: 1px solid #fcc;
}

/* Footer */
footer {
    margin-top: 40px;
    padding: 20px;
    background-color: #f0f0f0;
    text-align: center;
    color: #666;
    font-size: 12px;
    border-top: 1px solid #ddd;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wrapper-public {
        padding: 0 10px;
    }

    .filter-form {
        grid-template-columns: 1fr;
    }

    .btn-secondary {
        margin-left: 0;
        margin-top: 10px;
    }

    .events-table {
        font-size: 13px;
    }

    .events-table th,
    .events-table td {
        padding: 8px;
    }

    .l-region--navigation {
        padding: 5px 10px;
    }

    .tb-megamenu-item {
        margin: 0 10px;
    }

    .tb-megamenu-item a {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    header {
        padding: 10px 0;
    }

    header .secondary-links {
        padding: 5px 10px;
    }

    header .secondary-links a {
        margin: 0 8px;
        font-size: 11px;
    }

    .calendarTitle {
        font-size: 16px;
    }

    .events-table {
        font-size: 12px;
    }

    .events-table th,
    .events-table td {
        padding: 6px;
    }

    .filter-form {
        gap: 10px;
    }

    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .tb-megamenu-nav {
        flex-wrap: wrap;
    }

    .tb-megamenu-item {
        margin: 5px 10px;
    }

    .tb-megamenu-item a {
        font-size: 12px;
    }
}

/* Print / Save as PDF - strip the chrome and print just the calendar table. */
@media print {
    /* Default to portrait; rows may flow onto the next page, which is fine. */
    @page {
        size: portrait;
        margin: 0.5in;
    }

    header,
    .search-filters,
    footer,
    #btnPrintPdf,
    .modal-overlay {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .wrapper-public {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    /* Keep the title but drop the gray toolbar box around it. */
    .well {
        background: none;
        border: none;
        padding: 0 0 10px 0;
        margin: 0;
    }

    /* Use predictable proportional columns for print instead of the screen's
       content-hugging widths, and let every column wrap so the grid stays even.
       Use SEPARATE borders (not collapsed): Chrome drops every-other shared
       collapsed border at fractional pixel boundaries when printing, so each
       cell instead draws its own top/left border and the table draws the
       outer right/bottom - a clean single-line grid with nothing to drop. */
    .events-table {
        border-collapse: separate;
        border-spacing: 0;
        table-layout: fixed;
        width: 100%;
        border: 1px solid #999;
        border-width: 0 1px 1px 0;
    }

    /* Clip overflow at the cell edge rather than letting long unbreakable
       tokens (dates, case numbers) spill into the next column. Multi-word
       values still wrap; only over-long single tokens get trimmed. */
    .events-table th,
    .events-table td {
        border: 1px solid #999;
        border-width: 1px 0 0 1px;
        white-space: normal;
        overflow: hidden;
        text-overflow: clip;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .events-table th:nth-child(1), .events-table td:nth-child(1) { width: 9%; }   /* Date */
    .events-table th:nth-child(2), .events-table td:nth-child(2) { width: 8%; }   /* Time */
    .events-table th:nth-child(3), .events-table td:nth-child(3) { width: 14%; }  /* Case Number */
    .events-table th:nth-child(4), .events-table td:nth-child(4) { width: 9%; }   /* Judge */
    .events-table th:nth-child(5), .events-table td:nth-child(5) { width: 26%; }  /* Title */
    .events-table th:nth-child(6), .events-table td:nth-child(6) { width: 12%; }  /* Location */
    .events-table th:nth-child(7), .events-table td:nth-child(7) { width: 22%; }  /* Description */

    /* Repeat the header row at the top of each printed page. */
    .events-table thead {
        display: table-header-group;
    }
}
