/**
 * ============================================================
 * VILLAGE WATER SUPPLY MANAGEMENT SYSTEM
 * Global Application CSS
 * ============================================================
 *
 * File:
 *     assets/css/app.css
 *
 * หน้าที่:
 *     - CSS กลางของระบบ
 *     - Mobile First
 *     - Bootstrap 5 Compatible
 *     - ใช้ร่วมกันทุก Role
 *
 * ============================================================
 */


/* ============================================================
   ROOT VARIABLES
   ============================================================ */

:root {

    --water-primary: #0d6efd;
    --water-primary-dark: #084298;
    --water-secondary: #0dcaf0;

    --water-success: #198754;
    --water-warning: #ffc107;
    --water-danger: #dc3545;

    --water-info: #0dcaf0;

    --water-bg: #f4f8fc;
    --water-card: #ffffff;

    --water-text: #1f2937;
    --water-muted: #6c757d;

    --water-border: #e4eaf1;

    --water-radius: 14px;
    --water-radius-lg: 20px;

    --water-shadow:
        0 5px 20px rgba(0, 0, 0, 0.06);

    --water-shadow-lg:
        0 10px 35px rgba(0, 0, 0, 0.10);

    --water-navbar-height: 64px;
}


/* ============================================================
   GLOBAL
   ============================================================ */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

html,
body {
    min-height: 100%;
}

body {

    margin: 0;

    background: var(--water-bg);

    color: var(--water-text);

    font-family:
        "TH Sarabun New",
        "TH Sarabun",
        "Sarabun",
        Tahoma,
        Arial,
        sans-serif;

    font-size: 19px;

    line-height: 1.5;

    -webkit-font-smoothing: antialiased;

    -moz-osx-font-smoothing: grayscale;
}


/* ============================================================
   LINKS
   ============================================================ */

a {
    color: var(--water-primary);
}

a:hover {
    color: var(--water-primary-dark);
}


/* ============================================================
   IMAGES
   ============================================================ */

img {

    max-width: 100%;

    height: auto;

    vertical-align: middle;
}


/* ============================================================
   BUTTONS
   ============================================================ */

.btn {

    font-family:
        "TH Sarabun New",
        "TH Sarabun",
        "Sarabun",
        Tahoma,
        Arial,
        sans-serif;

    font-size: 18px;

    border-radius: 10px;

    min-height: 42px;
}

.btn-lg {

    min-height: 48px;

    font-size: 20px;

    border-radius: 12px;
}

.btn-sm {

    min-height: 36px;

    font-size: 16px;
}


/* ============================================================
   FORM CONTROLS
   ============================================================ */

.form-control,
.form-select {

    min-height: 44px;

    border-radius: 10px;

    border-color: var(--water-border);

    font-family:
        "TH Sarabun New",
        "TH Sarabun",
        "Sarabun",
        Tahoma,
        Arial,
        sans-serif;

    font-size: 18px;
}

.form-control:focus,
.form-select:focus {

    border-color: var(--water-primary);

    box-shadow:
        0 0 0 0.2rem
        rgba(13, 110, 253, 0.12);
}

.form-label {

    font-weight: 700;

    margin-bottom: 6px;
}


/* ============================================================
   APP NAVBAR
   ============================================================ */

.app-navbar {

    min-height: var(--water-navbar-height);

    background: #ffffff;

    border-bottom: 1px solid var(--water-border);

    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.05);

    position: sticky;

    top: 0;

    z-index: 1030;
}

.app-navbar .navbar-brand {

    color: var(--water-primary);

    font-size: 24px;

    font-weight: 700;
}

.app-navbar .navbar-brand:hover {

    color: var(--water-primary-dark);
}

.app-brand-icon {

    width: 40px;

    height: 40px;

    display: inline-flex;

    align-items: center;

    justify-content: center;

    border-radius: 11px;

    margin-right: 7px;

    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            var(--water-primary),
            var(--water-secondary)
        );
}


/* ============================================================
   PAGE WRAPPER
   ============================================================ */

.app-wrapper {

    min-height:
        calc(
            100vh -
            var(--water-navbar-height)
        );
}

.app-main {

    padding:
        20px 12px 40px;
}

.app-container {

    width: 100%;

    max-width: 1400px;

    margin: 0 auto;
}


/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {

    margin-bottom: 20px;
}

.page-title {

    margin: 0;

    font-size: 30px;

    line-height: 1.2;

    font-weight: 700;

    color: var(--water-text);
}

.page-subtitle {

    margin-top: 5px;

    margin-bottom: 0;

    color: var(--water-muted);

    font-size: 17px;
}


/* ============================================================
   CARD
   ============================================================ */

.app-card {

    background: var(--water-card);

    border:
        1px solid var(--water-border);

    border-radius: var(--water-radius);

    box-shadow: var(--water-shadow);

    overflow: hidden;
}

.app-card-header {

    padding:
        16px 18px;

    border-bottom:
        1px solid var(--water-border);

    background: #ffffff;
}

.app-card-title {

    margin: 0;

    font-size: 22px;

    font-weight: 700;
}

.app-card-body {

    padding: 18px;
}

.app-card-footer {

    padding:
        14px 18px;

    border-top:
        1px solid var(--water-border);

    background: #fafcff;
}


/* ============================================================
   STAT CARDS
   ============================================================ */

.stat-card {

    height: 100%;

    background: #ffffff;

    border:
        1px solid var(--water-border);

    border-radius: var(--water-radius);

    padding: 18px;

    box-shadow: var(--water-shadow);
}

.stat-icon {

    width: 50px;

    height: 50px;

    display: flex;

    align-items: center;

    justify-content: center;

    border-radius: 13px;

    background: #eaf3ff;

    color: var(--water-primary);

    font-size: 25px;

    margin-bottom: 12px;
}

.stat-label {

    color: var(--water-muted);

    font-size: 16px;

    margin-bottom: 2px;
}

.stat-value {

    font-size: 29px;

    line-height: 1.15;

    font-weight: 700;

    color: var(--water-text);
}

.stat-description {

    margin-top: 5px;

    color: var(--water-muted);

    font-size: 15px;
}


/* ============================================================
   COLOR VARIANTS
   ============================================================ */

.stat-primary .stat-icon {

    background: #eaf3ff;

    color: var(--water-primary);
}

.stat-success .stat-icon {

    background: #eaf8f0;

    color: var(--water-success);
}

.stat-warning .stat-icon {

    background: #fff8e1;

    color: #a67c00;
}

.stat-danger .stat-icon {

    background: #fff0f1;

    color: var(--water-danger);
}

.stat-info .stat-icon {

    background: #e8faff;

    color: #087f9c;
}


/* ============================================================
   DASHBOARD MENU
   ============================================================ */

.dashboard-menu {

    display: block;

    height: 100%;

    padding: 20px;

    background: #ffffff;

    border:
        1px solid var(--water-border);

    border-radius: var(--water-radius);

    box-shadow: var(--water-shadow);

    color: var(--water-text);

    text-decoration: none;

    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

.dashboard-menu:hover {

    color: var(--water-text);

    transform: translateY(-3px);

    box-shadow:
        0 10px 28px
        rgba(13, 110, 253, 0.12);
}

.dashboard-menu-icon {

    width: 55px;

    height: 55px;

    display: flex;

    align-items: center;

    justify-content: center;

    border-radius: 14px;

    margin-bottom: 13px;

    background: #eaf3ff;

    color: var(--water-primary);

    font-size: 27px;
}

.dashboard-menu-title {

    font-size: 21px;

    font-weight: 700;

    margin-bottom: 3px;
}

.dashboard-menu-text {

    color: var(--water-muted);

    font-size: 16px;

    line-height: 1.35;

    margin: 0;
}


/* ============================================================
   TABLE
   ============================================================ */

.table-responsive {

    border-radius: 10px;
}

.table {

    margin-bottom: 0;

    vertical-align: middle;
}

.table thead th {

    white-space: nowrap;

    background: #f5f8fc;

    font-weight: 700;

    border-bottom-width: 1px;
}

.table td,
.table th {

    padding:
        11px 12px;
}

.table-hover tbody tr:hover {

    background: #f8fbff;
}


/* ============================================================
   MOBILE TABLE
   ============================================================ */

.mobile-table {

    width: 100%;

    overflow-x: auto;

    -webkit-overflow-scrolling: touch;
}


/* ============================================================
   BADGES
   ============================================================ */

.badge {

    font-weight: 600;

    padding:
        6px 9px;

    border-radius: 7px;
}


/* ============================================================
   STATUS BADGES
   ============================================================ */

.status-unpaid {

    color: #842029;

    background: #f8d7da;
}

.status-partial {

    color: #664d03;

    background: #fff3cd;
}

.status-paid {

    color: #0f5132;

    background: #d1e7dd;
}

.status-overdue {

    color: #842029;

    background: #f8d7da;
}

.status-cancelled {

    color: #41464b;

    background: #e2e3e5;
}

.status-pending {

    color: #664d03;

    background: #fff3cd;
}

.status-verified {

    color: #0f5132;

    background: #d1e7dd;
}

.status-rejected {

    color: #842029;

    background: #f8d7da;
}


/* ============================================================
   MONEY
   ============================================================ */

.money {

    white-space: nowrap;

    font-variant-numeric:
        tabular-nums;
}

.money-positive {

    color: var(--water-success);

    font-weight: 700;
}

.money-negative {

    color: var(--water-danger);

    font-weight: 700;
}


/* ============================================================
   SEARCH BOX
   ============================================================ */

.search-box {

    position: relative;
}

.search-box .bi {

    position: absolute;

    left: 13px;

    top: 50%;

    transform:
        translateY(-50%);

    color: var(--water-muted);

    pointer-events: none;
}

.search-box .form-control {

    padding-left: 40px;
}


/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {

    text-align: center;

    padding:
        45px 20px;

    color: var(--water-muted);
}

.empty-state-icon {

    width: 70px;

    height: 70px;

    display: flex;

    align-items: center;

    justify-content: center;

    margin:
        0 auto 15px;

    border-radius: 50%;

    background: #eef4fa;

    color: #8a9aaa;

    font-size: 30px;
}

.empty-state-title {

    color: var(--water-text);

    font-size: 22px;

    font-weight: 700;

    margin-bottom: 5px;
}

.empty-state-text {

    margin: 0;

    font-size: 17px;
}


/* ============================================================
   ALERT
   ============================================================ */

.alert {

    border-radius: 11px;
}


/* ============================================================
   TOAST
   ============================================================ */

.app-toast {

    position: fixed;

    right: 15px;

    bottom: 15px;

    z-index: 2000;

    max-width: 360px;
}


/* ============================================================
   LOADING
   ============================================================ */

.loading-overlay {

    position: fixed;

    inset: 0;

    z-index: 3000;

    display: none;

    align-items: center;

    justify-content: center;

    background:
        rgba(255, 255, 255, 0.82);

    backdrop-filter:
        blur(3px);
}

.loading-overlay.active {

    display: flex;
}

.loading-box {

    min-width: 180px;

    padding: 25px;

    border-radius: 16px;

    background: #ffffff;

    box-shadow: var(--water-shadow-lg);

    text-align: center;
}

.loading-text {

    margin-top: 10px;

    color: var(--water-muted);

    font-size: 17px;
}


/* ============================================================
   USER AVATAR
   ============================================================ */

.user-avatar {

    width: 42px;

    height: 42px;

    display: inline-flex;

    align-items: center;

    justify-content: center;

    border-radius: 50%;

    background:
        linear-gradient(
            135deg,
            var(--water-primary),
            var(--water-secondary)
        );

    color: #ffffff;

    font-size: 20px;

    font-weight: 700;
}


/* ============================================================
   MOBILE BOTTOM NAVIGATION
   ============================================================ */

.mobile-bottom-nav {

    display: none;

    position: fixed;

    left: 0;

    right: 0;

    bottom: 0;

    z-index: 1020;

    background: #ffffff;

    border-top:
        1px solid var(--water-border);

    box-shadow:
        0 -3px 15px
        rgba(0, 0, 0, 0.07);

    padding:
        6px 4px
        calc(6px + env(safe-area-inset-bottom));
}

.mobile-bottom-nav .nav-item {

    flex: 1;

    text-align: center;
}

.mobile-bottom-nav a {

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    min-height: 52px;

    color: var(--water-muted);

    text-decoration: none;

    font-size: 13px;

    line-height: 1.1;
}

.mobile-bottom-nav a .bi {

    font-size: 21px;

    margin-bottom: 2px;
}

.mobile-bottom-nav a.active {

    color: var(--water-primary);

    font-weight: 700;
}


/* ============================================================
   QUICK ACTION
   ============================================================ */

.quick-action {

    display: flex;

    align-items: center;

    gap: 12px;

    padding: 14px;

    background: #ffffff;

    border:
        1px solid var(--water-border);

    border-radius: 12px;

    color: var(--water-text);

    text-decoration: none;
}

.quick-action:hover {

    color: var(--water-text);

    background: #f8fbff;
}

.quick-action-icon {

    flex: 0 0 auto;

    width: 45px;

    height: 45px;

    display: flex;

    align-items: center;

    justify-content: center;

    border-radius: 11px;

    background: #eaf3ff;

    color: var(--water-primary);

    font-size: 23px;
}

.quick-action-title {

    font-weight: 700;

    font-size: 18px;
}

.quick-action-text {

    color: var(--water-muted);

    font-size: 15px;
}


/* ============================================================
   INVOICE
   ============================================================ */

.invoice-card {

    background: #ffffff;

    border:
        1px solid var(--water-border);

    border-radius: 15px;

    box-shadow: var(--water-shadow);

    overflow: hidden;
}

.invoice-header {

    padding: 18px;

    background:
        linear-gradient(
            135deg,
            #0d6efd,
            #0dcaf0
        );

    color: #ffffff;
}

.invoice-title {

    font-size: 23px;

    font-weight: 700;

    margin: 0;
}

.invoice-number {

    opacity: 0.9;

    font-size: 16px;
}

.invoice-body {

    padding: 18px;
}

.invoice-total {

    padding: 15px;

    border-radius: 12px;

    background: #f0f7ff;

    text-align: center;
}

.invoice-total-label {

    color: var(--water-muted);

    font-size: 16px;
}

.invoice-total-value {

    color: var(--water-primary);

    font-size: 32px;

    line-height: 1.15;

    font-weight: 700;
}


/* ============================================================
   PAYMENT METHOD
   ============================================================ */

.payment-method {

    display: block;

    padding: 17px;

    border:
        2px solid var(--water-border);

    border-radius: 13px;

    background: #ffffff;

    cursor: pointer;

    transition:
        border-color 0.15s ease,
        background 0.15s ease;
}

.payment-method:hover {

    border-color: #b7d3f7;

    background: #f8fbff;
}

.payment-method.active {

    border-color: var(--water-primary);

    background: #f0f7ff;
}

.payment-method-icon {

    font-size: 30px;

    color: var(--water-primary);

    margin-bottom: 7px;
}

.payment-method-title {

    font-size: 20px;

    font-weight: 700;
}

.payment-method-text {

    color: var(--water-muted);

    font-size: 15px;
}


/* ============================================================
   QR CODE AREA
   ============================================================ */

.qr-container {

    width: 100%;

    max-width: 320px;

    margin: 0 auto;

    padding: 20px;

    background: #ffffff;

    border-radius: 15px;

    border:
        1px solid var(--water-border);

    text-align: center;
}

.qr-image {

    width: 100%;

    max-width: 260px;

    height: auto;

    margin: 0 auto 12px;

    display: block;
}


/* ============================================================
   RECEIPT
   ============================================================ */

.receipt-preview {

    width: 100%;

    max-width: 380px;

    margin: 0 auto;

    padding: 20px;

    background: #ffffff;

    border:
        1px dashed #999;

    color: #111111;

    font-family:
        "Courier New",
        monospace;

    font-size: 13px;
}

.receipt-center {

    text-align: center;
}

.receipt-line {

    border-top:
        1px dashed #555;

    margin:
        8px 0;
}

.receipt-row {

    display: flex;

    justify-content: space-between;

    gap: 10px;
}


/* ============================================================
   METER READING
   ============================================================ */

.meter-reading-box {

    padding: 20px;

    border-radius: 16px;

    background:
        linear-gradient(
            135deg,
            #f1f8ff,
            #ffffff
        );

    border:
        1px solid #dbeaf8;
}

.meter-number {

    font-size: 27px;

    font-weight: 700;

    color: var(--water-primary);
}

.meter-value {

    font-size: 34px;

    font-weight: 700;

    font-variant-numeric:
        tabular-nums;
}


/* ============================================================
   PHOTO UPLOAD
   ============================================================ */

.photo-upload {

    position: relative;

    display: flex;

    align-items: center;

    justify-content: center;

    min-height: 160px;

    padding: 20px;

    border:
        2px dashed #bfd1e4;

    border-radius: 14px;

    background: #f8fbff;

    text-align: center;

    cursor: pointer;
}

.photo-upload:hover {

    border-color: var(--water-primary);

    background: #f1f7ff;
}

.photo-upload-icon {

    font-size: 42px;

    color: var(--water-primary);

    margin-bottom: 7px;
}

.photo-preview {

    width: 100%;

    max-height: 320px;

    object-fit: contain;

    border-radius: 10px;

    margin-top: 12px;
}


/* ============================================================
   FILTER BAR
   ============================================================ */

.filter-bar {

    padding: 15px;

    background: #ffffff;

    border:
        1px solid var(--water-border);

    border-radius: var(--water-radius);

    box-shadow: var(--water-shadow);

    margin-bottom: 18px;
}


/* ============================================================
   PAGINATION
   ============================================================ */

.pagination {

    margin-bottom: 0;
}

.page-link {

    border-radius: 8px !important;

    margin: 0 2px;

    min-width: 38px;

    text-align: center;
}


/* ============================================================
   FOOTER
   ============================================================ */

.app-footer {

    margin-top: 30px;

    padding:
        25px 15px;

    background: #0b1f3a;

    color: #dbeafe;

    text-align: center;
}

.app-footer-title {

    color: #ffffff;

    font-size: 22px;

    font-weight: 700;
}

.app-footer-text {

    margin-top: 4px;

    font-size: 16px;

    opacity: 0.85;
}

.app-footer-version {

    margin-top: 7px;

    font-size: 14px;

    opacity: 0.6;
}


/* ============================================================
   UTILITY
   ============================================================ */

.cursor-pointer {

    cursor: pointer;
}

.text-primary-water {

    color: var(--water-primary) !important;
}

.bg-primary-water {

    background:
        var(--water-primary) !important;
}

.border-water {

    border-color:
        var(--water-border) !important;
}

.rounded-water {

    border-radius:
        var(--water-radius) !important;
}

.shadow-water {

    box-shadow:
        var(--water-shadow) !important;
}

.shadow-water-lg {

    box-shadow:
        var(--water-shadow-lg) !important;
}

.fw-700 {

    font-weight: 700 !important;
}

.fs-water-lg {

    font-size: 24px !important;
}

.no-wrap {

    white-space: nowrap;
}


/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 767.98px) {

    body {

        font-size: 18px;

        padding-bottom: 70px;
    }

    .app-main {

        padding:
            15px 10px 30px;
    }

    .page-title {

        font-size: 27px;
    }

    .page-subtitle {

        font-size: 16px;
    }

    .app-card-body {

        padding: 14px;
    }

    .app-card-header {

        padding:
            13px 14px;
    }

    .app-card-title {

        font-size: 20px;
    }

    .stat-card {

        padding: 15px;
    }

    .stat-value {

        font-size: 26px;
    }

    .table td,
    .table th {

        padding:
            9px 10px;

        font-size: 16px;
    }

    .mobile-bottom-nav {

        display: flex;
    }

    .filter-bar {

        padding: 12px;
    }

    .invoice-total-value {

        font-size: 29px;
    }

}


/* ============================================================
   TABLET
   ============================================================ */

@media (min-width: 768px) {

    .app-main {

        padding:
            25px 20px 50px;
    }

    .page-title {

        font-size: 34px;
    }

}


/* ============================================================
   DESKTOP
   ============================================================ */

@media (min-width: 1200px) {

    .app-main {

        padding:
            30px 25px 60px;
    }

}