/* Site-wide mobile-friendly layout for Dogz on Deck */

/* --- Touch-friendly controls --- */
@media (max-width: 767px) {
    .form-control,
    select.form-control,
    .input-group .form-control {
        min-height: 44px;
        font-size: 16px;
    }

    .btn,
    .btn-sm {
        min-height: 44px;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .section-heading h5,
    .sub-header {
        font-size: 1.1rem;
        line-height: 1.35;
        word-break: break-word;
    }

    .dogz-disclaimer {
        font-size: 0.95rem;
        line-height: 1.5;
        color: #555;
        margin-top: 1.25rem;
    }
}

/* --- Status legend (running order, my dog, etc.) --- */
.status-legend,
.mydog-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.status-legend .label,
.mydog-legend .label {
    display: inline-block;
    font-size: 0.85rem;
    padding: 0.45em 0.75em;
    white-space: normal;
    line-height: 1.3;
}

/* --- Splash list on home / index --- */
.splash-nav {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
}

.splash-nav li {
    margin-bottom: 0.5rem;
}

.splash-nav a {
    display: block;
    padding: 0.85rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
    color: #333;
    text-decoration: none;
    font-size: 1rem;
    line-height: 1.35;
    word-break: break-word;
}

.splash-nav a:hover,
.splash-nav a:focus {
    background: #eee;
    text-decoration: none;
}

/* --- Card-style tables on small screens --- */
@media (max-width: 767px) {
    .table-cards {
        border: 0;
    }

    .table-cards thead {
        display: none;
    }

    .table-cards tbody tr {
        display: block;
        margin-bottom: 0.75rem;
        border: 1px solid #ddd;
        border-radius: 4px;
        overflow: hidden;
        background: #fff;
    }

    .table-cards tbody tr.default {
        opacity: 0.75;
    }

    .table-cards tbody td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.6rem 0.85rem;
        border: 0;
        border-bottom: 1px solid #eee;
        text-align: right;
        word-break: break-word;
    }

    .table-cards tbody td:last-child {
        border-bottom: 0;
    }

    .table-cards tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        text-align: left;
        flex: 0 0 42%;
        color: #333;
    }

    .table-cards tbody td[data-label="Running Order"],
    .table-cards tbody td[data-label="#"] {
        font-size: 1.15rem;
        font-weight: 700;
    }

    .table-responsive {
        border: 0;
        margin-bottom: 0;
        -webkit-overflow-scrolling: touch;
    }
}

/* --- Dog block header (my dog, wasatch) --- */
.dog-block {
    margin-bottom: 2rem;
}

.dog-block-header {
    padding: 0.75rem 1rem;
    margin-bottom: 0;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-bottom: 0;
    border-radius: 4px 4px 0 0;
    font-size: 1rem;
    line-height: 1.4;
    word-break: break-word;
}

@media (max-width: 767px) {
    .dog-block-header {
        border-radius: 4px;
        border-bottom: 1px solid #ddd;
        margin-bottom: 0.75rem;
    }
}

/* --- Public running order page --- */
.ro-public-page {
    padding-bottom: 2rem;
}

.ro-public-page .ro-public-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0 0 1rem;
    font-size: 1.1rem;
    line-height: 1.35;
    word-break: break-word;
}

.ro-public-page .pool-sponsor-logo,
.pool-sponsor-logo {
    height: 1.5em;
    width: auto;
    max-width: 80px;
    object-fit: contain;
    vertical-align: middle;
}

.pool-sponsor-name {
    font-size: inherit;
    font-weight: inherit;
}

.ro-public-line {
    font-size: 0.95rem;
    color: #444;
}

.ro-public-dog {
    font-weight: 700;
    color: #222;
}

.ro-public-est-time {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.ro-public-sep {
    color: #888;
}

.ro-public-meta {
    color: #555;
}

.ro-public-order > tbody > tr.ro-my-dog > td,
.ro-public-order.table-striped > tbody > tr.ro-my-dog > td,
.ro-public-order.table-hover > tbody > tr.ro-my-dog:hover > td {
    background-color: #c8eec0 !important;
}

@media (max-width: 767px) {
    .ro-public-page.container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .ro-public-page .ro-public-table-wrap {
        border: 0;
        overflow: visible;
    }

    .ro-public-order.table-bordered,
    .ro-public-order.table-bordered > tbody > tr > td,
    .ro-public-order.table-bordered > thead > tr > th {
        border: 0 !important;
    }

    .ro-public-order.table-striped > tbody > tr:nth-of-type(odd) > td,
    .ro-public-order.table-striped > tbody > tr:nth-of-type(even) > td {
        background-color: transparent !important;
    }

    .ro-public-order.table-hover > tbody > tr:hover > td {
        background-color: transparent !important;
    }

    .ro-public-order,
    .ro-public-order tbody {
        display: block;
    }

    .ro-public-order {
        border: 0;
    }

    .ro-public-order thead {
        display: none;
    }

    .ro-public-order tbody tr {
        display: block;
        padding: 0.75rem 1rem;
        margin-bottom: 0.5rem;
        border: 1px solid #ddd;
        border-radius: 6px;
        background: #fff;
        line-height: 1.45;
    }

    .ro-public-order tbody tr.info {
        background: #d9edf7;
        border-color: #bce8f1;
    }

    .ro-public-order tbody tr.success {
        background: #dff0d8;
        border-color: #d6e9c6;
    }

    .ro-public-order tbody tr.danger {
        background: #f2dede;
        border-color: #ebccd1;
    }

    .ro-public-order tbody tr.warning {
        background: #fcf8e3;
        border-color: #faebcc;
    }

    .ro-public-order tbody tr.complete {
        opacity: 0.7;
    }

    .ro-public-order tbody tr.ro-my-dog {
        background: #c8eec0;
        border-color: #40863E;
        opacity: 1;
    }

    .ro-public-order tbody td {
        display: block;
        padding: 0 !important;
        border: 0 !important;
        text-align: left;
        white-space: normal;
        word-break: break-word;
        background: transparent !important;
    }

    .ro-public-order tbody td::before {
        content: none;
        display: none;
    }

    .ro-public-line {
        font-size: 0.95rem;
    }

    .ro-public-dog {
        font-size: 1.05rem;
    }
}

/* --- Footer --- */
footer .img-responsive {
    max-width: 120px;
    width: 40%;
    height: auto;
}

@media (max-width: 767px) {
    footer .credits {
        padding: 1rem 0.5rem;
        font-size: 0.9rem;
    }
}

/* --- Kiosk displays --- */
@media (max-width: 767px) {
    body.kiosk {
        padding: 0.75rem;
    }

    .kiosk-header h1 {
        font-size: 1.5rem;
    }

    .kiosk-header h2 {
        font-size: 1.15rem;
    }

    .kiosk-table {
        font-size: 1.05rem;
    }

    .kiosk-pools-table td {
        font-size: 1.15rem;
    }

    .kiosk-next,
    .kiosk-empty {
        font-size: 1rem;
    }

    .kiosk-legend .label {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }

    .kiosk-breaking-news-inner {
        align-items: center;
        gap: 0.65rem;
        padding: 0.7rem 0.85rem;
    }

    .kiosk-breaking-news.is-scrolling .kiosk-breaking-news-inner {
        padding-right: 0;
    }

    .kiosk-breaking-news-label {
        font-size: 0.95rem;
    }

    .kiosk-breaking-news-message {
        font-size: 1.15rem;
    }

    .kiosk-footer img {
        height: 72px;
        width: auto;
    }
}

/* --- Public: keep page content below the fixed navbar --- */
body.has-fixed-public-nav {
    padding-top: var(--public-nav-offset, calc(5rem + env(safe-area-inset-top, 0px)));
}

@media (max-width: 767px) {
    body.has-fixed-public-nav {
        padding-top: var(--public-nav-offset, calc(4.5rem + env(safe-area-inset-top, 0px)));
    }
}

@media print {
    body.has-fixed-public-nav {
        padding-top: 0 !important;
    }
}

/* Tighten leftover theme spacing (100px headings, 60/90px page padding) */
.section-heading {
    margin-top: 0;
    margin-bottom: 0.75rem;
}

.section-heading:empty {
    display: none;
    margin: 0;
}

.section-heading h3,
.section-heading h4,
.section-heading h5 {
    margin-top: 0;
    margin-bottom: 0.35rem;
}

.section-heading p {
    margin-top: 0;
    margin-bottom: 0.35rem;
}

section,
section.pages,
section.pages.no-padding {
    padding-top: 0.5rem;
    padding-bottom: 1.25rem;
}

section.pages.no-padding {
    padding-top: 0.5rem !important;
    padding-bottom: 1.25rem !important;
}

/* --- Admin: login --- */
.dogz-login-form {
    width: 450px;
    max-width: 100%;
}

@media (max-width: 767px) {
    .dogz-login-section .container {
        min-height: auto !important;
        padding-top: 5rem;
        padding-bottom: 2rem;
    }

    .dogz-login-form {
        width: 100%;
    }
}

/* --- Admin: toolbars & forms --- */
@media (max-width: 767px) {
    .admin-toolbar {
        display: flex;
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    .admin-toolbar .btn {
        width: 100%;
    }

    .form-inline.admin-filter-form {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .form-inline.admin-filter-form label,
    .form-inline.admin-filter-form select,
    .form-inline.admin-filter-form .btn,
    .form-inline.admin-filter-form a.btn {
        width: 100%;
        margin-left: 0 !important;
    }

    .admin-bulk-actions .btn {
        display: block;
        width: 100%;
        margin: 0 0 0.5rem !important;
    }

    .admin-bulk-actions .text-muted {
        display: block;
        margin: 0.5rem 0 0 !important;
    }

    .center-btns .btn,
    .center-btns button {
        display: block;
        width: 100%;
        margin-bottom: 0.75rem;
        min-height: 44px;
    }

    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    .admin-data-table .form-control {
        min-width: 0;
        font-size: 16px;
    }

    .admin-data-table:not(.table-cards) td,
    .admin-data-table:not(.table-cards) th {
        white-space: nowrap;
    }
}

/* --- Admin: pool drag-and-drop layout --- */
@media (max-width: 991px) {
    .pool-admin-layout > table,
    .pool-admin-layout > table > tbody,
    .pool-admin-layout > table > tbody > tr,
    .pool-admin-layout > table > tbody > tr > td {
        display: block;
        width: 100%;
    }

    .pool-admin-layout > table > tbody > tr > td[width] {
        display: none;
    }

    .pool-admin-layout .pool {
        margin-bottom: 1.25rem;
        min-height: 3rem;
        padding: 0.5rem;
        border: 1px solid #ccc;
        border-radius: 4px;
        background: #fafafa;
    }

    .pool-admin-layout .pool .title {
        margin: 0 0 0.5rem;
        font-size: 1rem;
        font-weight: 700;
    }

    .pool-admin-layout .splash {
        padding: 0.65rem 0.75rem;
        margin-bottom: 0.35rem;
        border: 1px solid #ddd;
        border-radius: 4px;
        background: #fff;
        font-size: 0.95rem;
        line-height: 1.35;
        cursor: grab;
        touch-action: none;
    }
}

/* --- Admin: splash nav collapse buttons --- */
@media (max-width: 767px) {
    section .btn[data-toggle="collapse"] {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
        min-height: 44px;
        white-space: normal;
        text-align: left;
    }
}

/* --- Navbar dropdowns on phones --- */
@media (max-width: 767px) {
    .navbar-nav .open .dropdown-menu {
        position: static;
        float: none;
        width: 100%;
        margin-top: 0;
        background-color: rgba(0, 0, 0, 0.05);
        border: 0;
        box-shadow: none;
    }

    .navbar-nav .dropdown-menu > li > a {
        padding: 0.75rem 1.25rem;
        min-height: 44px;
        line-height: 1.4;
    }

    .navbar-toggle {
        min-height: 44px;
        min-width: 44px;
        padding: 0.65rem 0.75rem;
    }
}

/* --- Safe area insets (iPhone notch, home indicator) --- */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .navbar-fixed-top {
        padding-top: env(safe-area-inset-top);
    }

    .mobile-event-header {
        padding-top: max(0.85rem, env(safe-area-inset-top));
    }

    footer {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* --- Mobile event header (replaces navbar + jumbotron on phones) --- */
.mobile-event-header {
    display: none;
}

@media (max-width: 767px) {
    .jumbotron {
        display: none !important;
    }

    .mobile-event-header {
        display: block;
        position: sticky;
        top: 52px;
        z-index: 1020;
        margin: 52px 0 0;
        padding: 0.65rem 1rem;
        padding-top: max(0.65rem, env(safe-area-inset-top, 0px));
        background-color: #40863E;
        color: #fff;
        text-align: center;
        border-bottom: 1px solid rgba(0, 0, 0, 0.12);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    }

    .mobile-event-header-title {
        margin: 0;
        font-size: 1.05rem;
        line-height: 1.35;
        font-weight: 700;
        word-break: break-word;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .jumbo-heading h1 {
        font-size: 1.75rem;
    }
}

/* --- Pool overview list (home / pools.php) --- */
.pool-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
}

.pool-list li {
    margin-bottom: 0.5rem;
}

.pool-list a {
    display: block;
    padding: 0.85rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
    color: #333;
    text-decoration: none;
    font-size: 1rem;
    line-height: 1.35;
    word-break: break-word;
}

.pool-list a:hover,
.pool-list a:focus {
    background: #eee;
    text-decoration: none;
}

.pool-list .pool-num {
    font-weight: 700;
    margin-right: 0.35rem;
}

.pool-list-empty {
    display: block;
    padding: 0.85rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
    color: #666;
    font-size: 1rem;
    line-height: 1.35;
}

/* --- Schedule table (PoolSchedule) --- */
.schedule-table tbody tr.pool-header td {
    background: #f5f5f5;
    font-weight: 700;
}

@media (max-width: 767px) {
    .schedule-table {
        border: 0;
    }

    .schedule-table thead {
        display: none;
    }

    .schedule-table tbody tr:not(.pool-header) {
        display: flex;
        align-items: baseline;
        gap: 0.75rem;
        padding: 0.65rem 0.85rem;
        margin-bottom: 0.35rem;
        border: 1px solid #eee;
        border-radius: 4px;
        background: #fff;
    }

    .schedule-table tbody tr.pool-header {
        display: block;
        margin: 1rem 0 0.35rem;
        border: 0;
    }

    .schedule-table tbody tr.pool-header td {
        display: block;
        padding: 0.5rem 0;
        border: 0;
        background: transparent;
    }

    .schedule-table tbody td {
        display: inline;
        padding: 0;
        border: 0;
    }

    .schedule-table tbody td[data-label="Time"] {
        font-weight: 600;
        white-space: nowrap;
    }

    .schedule-table tbody td[data-label="Time"]::after {
        content: " · ";
        font-weight: 400;
        color: #666;
    }
}

/* --- Admin data tables: card layout on phones --- */
@media (max-width: 767px) {
    .admin-data-table.table-cards {
        border: 0;
    }

    .admin-data-table.table-cards thead {
        display: none;
    }

    .admin-data-table.table-cards tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #ddd;
        border-radius: 6px;
        overflow: hidden;
        background: #fff;
    }

    .admin-data-table.table-cards tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.65rem 0.85rem;
        border: 0;
        border-bottom: 1px solid #eee;
        text-align: right;
        white-space: normal;
        word-break: break-word;
    }

    .admin-data-table.table-cards tbody td:last-child {
        border-bottom: 0;
    }

    .admin-data-table.table-cards tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        text-align: left;
        flex: 0 0 38%;
        color: #333;
    }

    .admin-data-table.table-cards tbody td[data-label=""]::before,
    .admin-data-table.table-cards tbody td:not([data-label])::before {
        content: none;
    }

    .admin-data-table.table-cards tbody td .form-control {
        flex: 1;
        min-width: 0;
        max-width: 58%;
    }

    .admin-data-table.table-cards tbody td.text-center {
        justify-content: space-between;
    }

    .admin-data-table.table-cards tbody td .btn {
        margin: 0.15rem 0;
    }

    .admin-data-table.table-cards tbody td[data-label="Actions"] {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-data-table.table-cards tbody td[data-label="Actions"]::before {
        margin-bottom: 0.25rem;
    }

    .admin-data-table.table-cards tbody td[data-label="Actions"] .btn {
        display: block;
        width: 100%;
        min-height: 44px;
    }

    .admin-data-table.table-cards tbody td[data-label="Actions"] form {
        display: block;
        width: 100%;
        margin-top: 0.35rem;
    }
}

/* --- Admin home (legacy admin.php) --- */
.admin-home-form select,
.admin-home-form input[type="text"] {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    margin-bottom: 0.75rem;
    font-size: 16px;
}

.admin-home-form .clear {
    margin: 0.5rem 0;
    text-align: center;
    font-weight: 600;
    color: #666;
}

@media (max-width: 767px) {
    .admin-home-form .formSection h5 {
        margin-top: 1.25rem;
    }
}

/* --- Data export links --- */
.export-link-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    max-width: 20rem;
}

.export-link-list li {
    margin-bottom: 0.5rem;
}

.export-link-list a {
    display: block;
    padding: 0.75rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
    color: #333;
    text-decoration: none;
    font-size: 1rem;
    text-align: center;
}

.export-link-list a:hover,
.export-link-list a:focus {
    background: #eee;
    text-decoration: none;
}

/* --- Add-event / well forms --- */
@media (max-width: 767px) {
    .well {
        max-width: none !important;
        margin-left: 0;
        margin-right: 0;
    }

    .section-heading h3 {
        font-size: 1.35rem;
        word-break: break-word;
    }

    .section-heading p {
        font-size: 0.95rem;
        line-height: 1.45;
    }
}

/* --- Legacy Manage Pools drag-and-drop --- */
@media (max-width: 991px) {
    .manage-pools-page .li_containers,
    .manage-pools-page [id^="droppable"] {
        float: none;
        width: 100% !important;
        height: auto !important;
        min-height: 8rem;
        margin: 0 0 1rem;
    }

    .manage-pools-page .listitems {
        float: none;
        width: 100%;
        height: auto;
        min-height: 4rem;
        margin: 0.5rem 0;
    }
}

/* --- Tablet tweaks (iPad portrait/landscape) --- */
@media (min-width: 768px) and (max-width: 991px) {
    .container {
        padding-left: 20px;
        padding-right: 20px;
    }

    .ro-pool-nav a {
        min-width: 3.75rem;
        min-height: 2.75rem;
    }

    .splash-nav a,
    .pool-list a {
        font-size: 1.05rem;
    }
}
