/* =============================================================
   CrewPyNet — Unified Stylesheet
   Brand: SwanPyNet / Masterskip
   Primary: #1a3759 (dark navy)
   Hover:   #2a4a76 (medium navy)
   ============================================================= */

/* ---- CSS Custom Properties ---- */
:root {
    --primary-color: #1a3759;
    --primary-hover: #2a4a76;
    --dark-bg: #343a40;
    --transition-speed: 0.3s;
    --navbar-height: 60px;
    --footer-bg: var(--primary-color);
    --header-bg-primary: var(--primary-color);
    --header-bg-auth: #343a40;
    --header-bg-success: #198754;
    --header-bg-warning: #ffc107;
    --header-bg-danger: #dc3545;
    --header-bg-info: #0dcaf0;
}

/* ---- Top Navigation Bar ---- */
.navbar {
    background-color: var(--primary-color);
}

.navbar-dark .navbar-brand {
    color: #fff;
}

.navbar-dark .navbar-brand:hover {
    color: rgba(255, 255, 255, 0.85);
}

.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.9);
}

.navbar-dark .navbar-nav .nav-link:hover {
    color: #fff;
}

/* Navbar text — base (mobile) sizing */
.navbar-text {
    font-size: 0.85rem;
}

/* Logout button — base (mobile) sizing */
.navbar-logout-btn {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
}

/* ---- Desktop: ≥992px — scale up username + logout, generous spacing ---- */
@media (min-width: 992px) {
    .navbar-text {
        font-size: 1.15rem;
        margin-right: 1.5rem !important;
    }

    .navbar-text .bi-person-circle {
        font-size: 1.3rem;
    }

    .navbar-logout-btn {
        font-size: 1rem;
        padding: 0.4rem 1.25rem;
    }
}

/* ---- Tablet: 768px–991px — moderate sizing ---- */
@media (min-width: 768px) and (max-width: 991.98px) {
    .navbar-text {
        font-size: 1rem;
        margin-right: 1rem !important;
    }

    .navbar-text .bi-person-circle {
        font-size: 1.15rem;
    }

    .navbar-logout-btn {
        font-size: 0.9rem;
        padding: 0.3rem 0.85rem;
    }
}

/* ---- Footer ---- */
footer {
    background-color: var(--footer-bg);
}

/* ---- Nav-Circle Buttons (legacy support for home page) ---- */
.nav-circle {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: inline-block;
    text-align: center;
}

@media (min-width: 768px) {
    .nav-circle {
        padding: 16px 32px;
        font-size: 17px;
    }
}

.nav-circle:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* ---- Mobile Bottom Navigation ---- */
.navbar.fixed-bottom {
    background-color: var(--primary-color);
    padding: 0;
    min-height: 70px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
}

.navbar.fixed-bottom .nav-link {
    color: #fff;
    transition: all var(--transition-speed) ease;
    border-radius: 0;
    flex: 1 1 0;
    min-width: 0;
}

.navbar.fixed-bottom .nav-link:hover {
    background-color: var(--primary-hover);
    color: #fff;
}

.navbar.fixed-bottom .nav-link:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.navbar.fixed-bottom .nav-link i {
    transition: transform var(--transition-speed) ease;
}

.navbar.fixed-bottom .nav-link:hover i {
    transform: scale(1.1);
}

/* Main content padding for bottom nav */
@media (max-width: 991.98px) {
    main {
        padding-bottom: 80px;
    }
}

/* Bottom nav touch targets */
@media (max-width: 767.98px) {
    .navbar.fixed-bottom .nav-link {
        min-width: 60px !important;
        min-height: 60px !important;
        padding: 8px !important;
    }

    .navbar.fixed-bottom .nav-link i {
        font-size: 24px;
    }

    .navbar.fixed-bottom small {
        font-size: 10px;
        margin-top: 2px;
        color: #fff;
    }
}

/* ---- Responsive Container ---- */
.container-fluid {
    max-width: 100%;
    padding-left: var(--bs-gutter-x, 0.75rem);
    padding-right: var(--bs-gutter-x, 0.75rem);
    overflow-x: hidden;
}

/* ---- Responsive Logo & Navbar Layout ---- */

/* Logo size via CSS custom property — single source of truth */
:root {
    --logo-size: 80px;   /* desktop default */
}

/* Logo image styling */
.navbar-brand-logo {
    max-height: var(--logo-size);
    width: auto;
    height: auto;
    object-fit: contain;
    padding: 4px;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    transition: max-height 0.25s ease;
}

/* Navbar brand container */
.navbar-brand {
    transition: padding 0.25s ease;
}

/* ---- Desktop: ≥992px (lg) — logo caps at 60px, navbar driven by content ---- */
@media (min-width: 992px) {
    :root {
        --logo-size: 60px;
    }
    .navbar {
        padding-top: 0.4rem;
        padding-bottom: 0.4rem;
    }
}

/* ---- Tablet: 768px–991px (md) — moderate logo ---- */
@media (min-width: 768px) and (max-width: 991.98px) {
    :root {
        --logo-size: 50px;
    }
    .navbar {
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
    }
}

/* ---- Large Mobile: 576px–767px (sm) — compact logo ---- */
@media (min-width: 576px) and (max-width: 767.98px) {
    :root {
        --logo-size: 45px;
    }
    .navbar {
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
    }
}

/* ---- Small Mobile: <576px (xs) — smallest logo, tight bar ---- */
@media (max-width: 575.98px) {
    :root {
        --logo-size: 38px;
    }
    .navbar {
        padding-top: 0.15rem;
        padding-bottom: 0.15rem;
    }
}

/* ---- Accessibility: Skip Link ---- */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
    transition: top var(--transition-speed) ease;
}

.skip-link:focus {
    top: 6px;
}

/* ---- Accessibility: Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---- Accessibility: High Contrast ---- */
@media (prefers-contrast: high) {
    .nav-circle {
        border: 2px solid white;
    }

    .navbar.fixed-bottom .nav-link,
    .navbar-dark .navbar-nav .nav-link {
        border: 1px solid transparent;
    }

    .navbar.fixed-bottom .nav-link:hover,
    .navbar-dark .navbar-nav .nav-link:hover {
        border-color: white;
    }
}

/* ---- Accessibility: Focus Visible ---- */
.nav-circle:focus-visible,
.navbar-dark .navbar-nav .nav-link:focus-visible,
.navbar.fixed-bottom .nav-link:focus-visible,
.btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.focus-visible:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ---- Scroll-to-Top Button ---- */
#scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 20px;
    z-index: 1050;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

#scroll-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}

#scroll-to-top:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@media (max-width: 991.98px) {
    #scroll-to-top {
        bottom: 90px;
        right: 12px;
        width: 44px;
        height: 44px;
    }
}

/* ---- Enhanced Touch Targets (Mobile) ---- */
@media (max-width: 767.98px) {
    button, .btn, .accordion-button {
        min-height: 44px;
        min-width: 44px;
        padding: 12px;
    }

    .form-control, .form-select {
        min-height: 44px;
        font-size: 16px;
    }
}

/* ---- Responsive Typography ---- */
@media (max-width: 575.98px) {
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.9rem; }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
    h5 { font-size: 1.1rem; }
    h6 { font-size: 1rem; }
}

/* ---- Responsive Images ---- */
img {
    max-width: 100%;
    height: auto;
}

/* ---- Content Area Spacing ---- */
.content-area {
    line-height: 1.6;
}

@media (max-width: 575.98px) {
    .content-area {
        font-size: 0.95rem;
        line-height: 1.5;
    }
}

/* ---- Definition List Card Responsive ---- */
@media (max-width: 575.98px) {
    .card-body dl.row dt {
        display: block;
        background-color: rgba(0, 0, 0, 0.02);
        font-weight: 700;
        padding: 4px 8px;
        border-radius: 4px;
        margin-bottom: 2px;
    }
    .card-body dl.row dd {
        display: block;
        padding-left: 12px;
        margin-bottom: 8px;
    }
}

/* ---- Hero Logo Scaling ---- */
@media (max-width: 767.98px) {
    .hero-logo {
        max-height: 120px !important;
    }
}

/* ---- Table Button Sizing on Mobile ---- */
@media (max-width: 575.98px) {
    .table-responsive .btn-group-sm .btn,
    .table-responsive .btn-sm {
        min-height: 38px;
        min-width: 38px;
        padding: 6px 10px;
        font-size: 0.85rem;
    }
}

/* ---- Card-based Table Views (Mobile Alternative) ---- */
.table-card-view { display: none; }

@media (max-width: 767.98px) {
    .table-card-view { display: block; }
    .table-standard-view { display: none; }
    .expense-card, .report-card {
        border: 1px solid #dee2e6;
        border-radius: 0.5rem;
        padding: 1rem;
        margin-bottom: 0.75rem;
        background: #fff;
    }
    .expense-card .card-label, .report-card .card-label {
        font-weight: 600;
        color: #6c757d;
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    .expense-card .card-value, .report-card .card-value {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }
}

/* ---- DataTables Mobile Optimizations ---- */
@media (max-width: 767.98px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none;
        text-align: left;
        margin-bottom: 0.5rem;
    }
    .dataTables_wrapper .dataTables_length label,
    .dataTables_wrapper .dataTables_filter label {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    .dataTables_wrapper .dataTables_length select,
    .dataTables_wrapper .dataTables_filter input {
        min-height: 40px;
        font-size: 16px;
    }
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        min-width: 36px;
        min-height: 36px;
        padding: 4px 8px;
    }
}

/* ---- Content Overflow Guard ---- */
* {
    box-sizing: border-box;
}

.content-overflow-guard {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* ---- Back-to-Dashboard Navigation Bar ---- */
.back-nav {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 0.55rem 0;
}
.back-to-dashboard {
    display: inline-flex;
    align-items: center;
    color: var(--primary-color);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    padding: 0.3rem 0.75rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.back-to-dashboard:hover {
    background-color: var(--primary-color);
    color: #fff;
    text-decoration: none;
}
.back-nav .breadcrumb {
    margin-bottom: 0;
    padding: 0;
    background: none;
}
.back-nav .breadcrumb-item + .breadcrumb-item::before {
    color: #6c757d;
}
@media (max-width: 575.98px) {
    .back-nav {
        padding: 0.4rem 0;
    }
    .back-to-dashboard {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }
}

/* ---- Footer Components ---- */
.footer-logo {
    max-height: 70px;
    width: auto;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.15);
    padding: 3px;
}

.footer-heading {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.footer-address {
    color: rgba(255, 255, 255, 0.75);
    font-style: normal;
    font-size: 0.9rem;
    line-height: 1.6;
}

.footer-link {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color var(--transition-speed) ease;
}

.footer-link:hover {
    color: #fff;
    text-decoration: underline;
}

@media (max-width: 767.98px) {
    .footer-logo {
        max-height: 55px;
    }
}
