/* assets/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --bg-main: #f3f4f6;
    --bg-card: #ffffff;
    --mobile-bottom-bar-h: 0px; /* overridden at mobile breakpoint for admin */
}

*,
*::before,
*::after {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh; /* dynamic viewport height for mobile browsers */
    -webkit-text-size-adjust: 100%;
}

/* Push footer to bottom */
.main-content {
    flex: 1;
}

/* ── Navbar ───────────────────────────────────────────────────── */
.navbar {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--primary-color) !important;
}

.navbar-toggler {
    border: none;
    padding: 0.5rem;
}

.navbar-toggler:focus {
    box-shadow: none;
}

/* Animate mobile menu open/close */
.navbar-collapse {
    transition: max-height 0.3s ease;
}

/* ── Hero Section ─────────────────────────────────────────────── */
.hero-section {
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.6), rgba(59, 130, 246, 0.5)), url('../../../PICTURES/BANNER.png') center/cover no-repeat;
    color: white;
    padding: 6rem 0;
    text-align: center;
    border-bottom-left-radius: 2rem;
    border-bottom-right-radius: 2rem;
    margin-bottom: 3rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* ── Node Cards ───────────────────────────────────────────────── */
.node-card {
    background-color: var(--bg-card);
    border: none;
    border-radius: 1rem;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    height: 100%;
}

.node-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.node-img-wrapper {
    height: 200px;
    overflow: hidden;
    position: relative;
}

.node-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.node-card:hover .node-img-wrapper img {
    transform: scale(1.05);
}

.card-title {
    font-weight: 600;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.card-text {
    color: var(--text-muted);
}

/* ── Buttons — touch-friendly minimums ────────────────────────── */
.btn {
    min-height: 44px; /* iOS minimum tap target */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    font-weight: 500;
    padding: 0.5rem 1.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
}

/* ── Node Details Hero ────────────────────────────────────────── */
.details-hero {
    height: 300px;
    background-size: cover;
    background-position: center;
    position: relative;
    border-radius: 1rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: flex-end;
    padding: 2rem;
    overflow: hidden;
}

.details-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
}

.details-title {
    position: relative;
    z-index: 1;
    color: white;
}

.schedule-table {
    background: white;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* ── Form Controls ────────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: 0.5rem;
    padding: 0.6rem 1rem;
    border-color: #d1d5db;
    min-height: 44px;
    font-size: 1rem; /* prevent iOS zoom on focus */
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(37, 99, 235, 0.25);
}

/* ── Login Page ───────────────────────────────────────────────── */
.login-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    padding: 1rem;
}

.login-card {
    background: rgb(255, 255, 255);
    padding: 3rem;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 400px;
}

/* ── Footer ───────────────────────────────────────────────────── */
.site-footer {
    background-color: #1f2937;
    color: #9ca3af;
    padding: 1.5rem 0;
    font-size: 0.875rem;
    margin-top: auto;
}

.site-footer a {
    color: #d1d5db;
    text-decoration: none;
    transition: color 0.2s;
}

.site-footer a:hover {
    color: #ffffff;
}

/* ── Admin search bar ─────────────────────────────────────────── */
.admin-search {
    max-width: 320px;
}

.admin-search .form-control {
    border-radius: 0.5rem 0 0 0.5rem;
}

.admin-search .btn {
    border-radius: 0 0.5rem 0.5rem 0;
}

/* ── Submit spinner ───────────────────────────────────────────── */
.btn .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
    margin-right: 0.4rem;
    display: none;
}

.btn.is-loading .spinner-border {
    display: inline-block;
}

.btn.is-loading {
    pointer-events: none;
    opacity: 0.75;
}

/* ── Mobile card layout for admin tables ──────────────────────── */
/* These data-label driven cards replace horizontal table rows on mobile */
.mobile-card-row {
    display: none; /* hidden on desktop, shown via media query */
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (≤ 992px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 992px) {
    .hero-section {
        padding: 4rem 1.5rem;
        margin-bottom: 2rem;
    }

    .hero-section h1 {
        font-size: 2rem;
    }

    /* Dashboard stat cards: 2x2 grid */
    .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤ 768px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    body {
        font-size: 0.9375rem;
    }

    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* ── Hero ── */
    .hero-section {
        padding: 2.5rem 1rem;
        border-bottom-left-radius: 1rem;
        border-bottom-right-radius: 1rem;
        margin-bottom: 1.5rem;
    }

    .hero-section h1 {
        font-size: 1.5rem;
    }

    .hero-section .lead {
        font-size: 0.9rem;
    }

    .hero-section form {
        flex-direction: column;
        gap: 0.5rem;
    }

    .hero-section form .form-control {
        border-radius: 0.5rem !important;
    }

    .hero-section form .btn {
        border-radius: 0.5rem !important;
        width: 100%;
    }

    /* ── Node detail hero ── */
    .details-hero {
        height: 180px;
        padding: 1rem;
        border-radius: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .details-hero h1,
    .details-hero .display-5 {
        font-size: 1.25rem !important;
    }

    .details-hero .fs-5 {
        font-size: 0.875rem !important;
    }

    /* ── Node cards ── */
    .node-img-wrapper {
        height: 160px;
    }

    .node-card:hover {
        transform: none; /* disable hover lift on touch */
    }

    .card-title {
        font-size: 1.1rem;
    }

    /* ── Tables — stacked card layout ── */
    .schedule-table .table thead {
        display: none;
    }

    .schedule-table .table tbody tr {
        display: block;
        padding: 1rem;
        border-bottom: 1px solid #e5e7eb;
        position: relative;
    }

    .schedule-table .table tbody tr:last-child {
        border-bottom: none;
    }

    .schedule-table .table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.4rem 0 !important;
        border: none;
        text-align: right;
    }

    .schedule-table .table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-main);
        text-align: left;
        flex-shrink: 0;
        margin-right: 1rem;
    }

    /* ── Admin table card layout ── */
    .admin-table-desktop thead {
        display: none;
    }

    .admin-table-desktop tbody tr {
        display: block;
        background: white;
        border-radius: 0.75rem;
        padding: 1rem;
        margin-bottom: 0.75rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
        border: 1px solid #e5e7eb;
    }

    .admin-table-desktop tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.35rem 0 !important;
        border: none;
        gap: 0.5rem;
    }

    .admin-table-desktop tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        flex-shrink: 0;
    }

    .admin-table-desktop tbody td:last-child {
        justify-content: flex-end;
        padding-top: 0.75rem !important;
        border-top: 1px solid #f3f4f6;
        margin-top: 0.25rem;
    }

    .admin-table-desktop tbody td:last-child::before {
        display: none;
    }

    .admin-table-desktop tbody td .text-truncate {
        max-width: none !important;
        white-space: normal;
        word-break: break-word;
    }

    /* ── Login card ── */
    .login-card {
        margin: 0.5rem;
        padding: 1.75rem;
    }

    .login-card img {
        height: 48px !important;
    }

    /* ── Admin heading + button ── */
    .page-header-flex {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch !important;
    }

    .page-header-flex .btn {
        width: 100%;
    }

    /* ── Pagination ── */
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .pagination .page-link {
        min-width: 40px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }

    /* ── Filter form on index ── */
    .filter-form {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .filter-form .flex-grow-1 {
        width: 100%;
    }

    .filter-form > div:last-child {
        display: flex;
        gap: 0.5rem;
        width: 100%;
    }

    .filter-form > div:last-child .btn {
        flex: 1;
    }

    /* ── Dashboard cards ── */
    .dashboard-stats .col-md-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .dashboard-stats .card-body {
        padding: 1rem !important;
    }

    .dashboard-stats .display-6 {
        font-size: 1.75rem !important;
    }

    /* ── Quick action buttons ── */
    .quick-actions .btn {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
        flex: 1 1 calc(50% - 0.5rem);
        text-align: center;
    }

    /* ── Admin search ── */
    .admin-search {
        max-width: 100%;
        width: 100%;
    }

    /* ── Modal improvements ── */
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 0 !important;
    }

    /* ── Navbar mobile spacing ── */
    .navbar-nav {
        padding: 0.5rem 0;
    }

    .navbar-nav .nav-link {
        padding: 0.75rem 1rem !important;
        border-radius: 0.5rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .navbar-nav .nav-link:active {
        background-color: rgba(255,255,255,0.1);
    }

    /* ── Footer mobile ── */
    .site-footer {
        padding: 1rem 0;
        font-size: 0.8rem;
        padding-bottom: calc(1rem + var(--mobile-bottom-bar-h));
    }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Small mobile (≤ 576px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 576px) {
    .hero-section {
        padding: 2rem 0.75rem;
        border-radius: 0 0 0.75rem 0.75rem;
        margin-bottom: 1rem;
    }

    .hero-section h1 {
        font-size: 1.25rem;
    }

    .hero-section .lead {
        font-size: 0.85rem;
        margin-bottom: 1rem !important;
    }

    /* Dashboard stat cards: single column */
    .dashboard-stats .col-md-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Node cards full width */
    .row-cols-1 > .col {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .node-img-wrapper {
        height: 140px;
    }

    .card-title {
        font-size: 1rem;
    }

    .card-text {
        font-size: 0.875rem;
    }

    /* Admin action buttons — stack vertically */
    .admin-table-desktop tbody td:last-child {
        flex-direction: column;
    }

    .admin-table-desktop tbody td:last-child .btn {
        width: 100%;
    }

    /* Login card — tighter */
    .login-card {
        padding: 1.5rem;
        border-radius: 0.75rem;
    }

    /* ── Details page ── */
    .details-hero {
        height: 150px;
        border-radius: 0.5rem;
    }

    .details-hero h1,
    .details-hero .display-5 {
        font-size: 1.1rem !important;
    }

    /* Schedule table further refinement */
    .schedule-table .table tbody td {
        font-size: 0.875rem;
    }

    /* Full-width buttons on smallest screens */
    .btn-outline-primary.w-100,
    .btn-outline-success.w-100 {
        font-size: 0.9rem;
        padding: 0.6rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Very small (≤ 360px, small Android phones)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 360px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .hero-section h1 {
        font-size: 1.1rem;
    }

    .login-card {
        padding: 1.25rem;
    }

    .modal-dialog {
        margin: 0.25rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Landscape orientation on mobile
   ═══════════════════════════════════════════════════════════════ */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        padding: 1.5rem 1rem;
        margin-bottom: 1rem;
    }

    .login-container {
        align-items: flex-start;
        padding-top: 1rem;
    }

    .login-card {
        padding: 1.5rem;
    }

    .details-hero {
        height: 140px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Safe area insets for notched devices (iPhone X+, etc.)
   ═══════════════════════════════════════════════════════════════ */
@supports (padding: env(safe-area-inset-bottom)) {
    .site-footer {
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }

    .login-container {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .navbar {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* ═══════════════════════════════════════════════════════════════
   Accessibility — reduced motion
   ═══════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .node-card,
    .node-img-wrapper img,
    .btn-primary,
    .navbar-collapse {
        transition: none !important;
    }

    .node-card:hover {
        transform: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Print — hide nav and footer when printing
   ═══════════════════════════════════════════════════════════════ */
@media print {
    .navbar, .site-footer, .btn, .admin-search { display: none !important; }
    .hero-section { padding: 1rem 0; }
    body { background: white; }
}
