/* =====================================
   SmartBook Mobile 1.0
   ===================================== */

@media (max-width: 768px) {

    html,
    body {
        width: 100%;
        min-height: 100%;
        overflow-x: hidden;
    }

    body {
        padding-bottom: 84px;
        background: #f4f7fb;
    }

    /* ===============================
       共用版面
       =============================== */

    .container {
        width: 100%;
        max-width: 100%;
        margin-top: 18px !important;
        margin-bottom: 24px !important;
        padding-left: 14px;
        padding-right: 14px;
    }

    .content {
        width: 100%;
        padding-bottom: 92px;
    }

    .card,
    .card-box,
    .dashboard-panel,
    .transaction {
        border-radius: 16px;
    }

    .card {
        padding: 18px !important;
    }

    h1 {
        font-size: 27px;
    }

    h2 {
        font-size: 24px;
    }

    h4 {
        font-size: 19px;
    }

    /* ===============================
       側邊選單改成手機上方導覽
       =============================== */

    .app {
        display: block;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 1000;
        width: 100%;
        padding: 14px;
        background: #15213b;
        box-shadow: 0 4px 16px rgba(15, 23, 42, 0.18);
    }

    .sidebar-header {
        margin-bottom: 12px;
        text-align: center;
    }

    .logo {
        margin: 0;
        font-size: 21px;
    }

    .sidebar-subtitle {
        margin-top: 4px;
        font-size: 12px;
    }

    .menu {
        display: flex;
        gap: 8px;
        margin: 0;
        padding: 0 0 4px;
        overflow-x: auto;
        white-space: nowrap;
        scrollbar-width: none;
    }

    .menu::-webkit-scrollbar {
        display: none;
    }

    .menu li {
        flex: 0 0 auto;
        margin: 0;
    }

    .menu li a {
        padding: 9px 12px;
        font-size: 13px;
        border-radius: 10px;
    }

    /* ===============================
       首頁頂部
       =============================== */

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
        padding: 22px 16px 16px;
    }

    .topbar h1 {
        font-size: 27px;
    }

    .page-description {
        font-size: 14px;
        line-height: 1.6;
    }

    .topbar .btn {
        width: 100%;
        min-height: 46px;
    }

    /* ===============================
       Dashboard 統計卡
       =============================== */

    .dashboard {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        padding: 0 16px 18px;
    }

    .summary-card {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        min-height: 150px;
        padding: 17px;
    }

    .summary-card .card-icon {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
        font-size: 21px;
        border-radius: 13px;
    }

    .summary-card h5 {
        margin-bottom: 6px;
        font-size: 13px;
    }

    .summary-card p {
        font-size: 21px;
        word-break: break-word;
    }

    .summary-card small {
        font-size: 11px;
        line-height: 1.5;
    }

    .budget-card {
        grid-column: 1 / -1;
    }

    .budget-card-content {
        width: 100%;
    }

    #budgetStatus {
        font-size: 14px;
    }

    /* ===============================
       快速記帳
       =============================== */

    .quick-entry-section {
        padding: 0 16px 18px;
    }

    .quick-entry-panel {
        padding: 18px;
    }

    .quick-entry-panel .row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .quick-entry-panel .row > div {
        width: 100%;
        max-width: 100%;
    }

    .quick-entry-panel .row > div:nth-child(4),
    .quick-entry-panel .row > div:nth-child(5),
    .quick-entry-panel .row > div:nth-child(6) {
        grid-column: 1 / -1;
    }

    .quick-entry-panel .btn {
        min-height: 48px;
    }

    /* ===============================
       首頁資訊區
       =============================== */

    .dashboard-sections {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 0 16px;
    }

    .dashboard-panel,
    .transaction {
        margin: 0;
        padding: 18px;
    }

    .panel-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .panel-header .panel-link {
        align-self: flex-end;
    }

    /* ===============================
       表單
       =============================== */

    .form-control,
    .form-select {
        min-height: 46px;
        font-size: 16px;
        border-radius: 11px;
    }

    textarea.form-control {
        min-height: 96px;
    }

    .form-label {
        margin-bottom: 7px;
        font-size: 14px;
        font-weight: 700;
    }

    .btn {
        min-height: 44px;
        font-size: 15px;
        border-radius: 11px;
    }

    #addBtn {
        width: 100%;
        min-height: 48px;
        font-weight: 800;
    }

    /* ===============================
       搜尋與篩選
       =============================== */

    #searchBtn,
    #clearSearchBtn {
        width: 100%;
        margin: 0 0 10px !important;
    }

    /* ===============================
       交易表格
       =============================== */

    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
    }

    table {
        min-width: 980px;
        font-size: 13px;
    }

    table th,
    table td {
        padding: 10px 8px !important;
        white-space: nowrap;
    }

    /* ===============================
       月曆
       =============================== */

    .calendar-panel {
        overflow-x: auto;
    }

    .calendar-controls {
        width: 100%;
        justify-content: space-between;
    }

    #calendarTitle {
        min-width: auto;
        font-size: 15px;
    }

    .calendar-weekdays,
    .calendar-grid {
        min-width: 700px;
    }

    .calendar-day {
        min-height: 88px;
        padding: 7px;
    }

    .calendar-date-number {
        font-size: 13px;
    }

    .calendar-day-summary {
        gap: 3px;
        font-size: 10px;
    }

    /* ===============================
       圖表
       =============================== */

    .trend-chart-container {
        height: 270px;
    }

    canvas {
        max-width: 100%;
    }

    /* ===============================
       手機浮動新增按鈕
       =============================== */

    .mobile-fab{
    position: fixed;
    right: 20px;
    bottom: 100px;

    width: 60px;
    height: 60px;

    border-radius: 50%;

    background: #2563eb;
    color: white;

    font-size: 32px;

    display: flex;
    justify-content: center;
    align-items: center;

    text-decoration: none;

    box-shadow: 0 8px 20px rgba(0,0,0,.25);

    z-index: 9999;
}

    .mobile-fab:hover,
    .mobile-fab:focus {
        color: #ffffff;
        background: #1d4ed8;
    }

    /* ===============================
       手機底部導航
       =============================== */

    .mobile-bottom-nav {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1050;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        min-height: 70px;
        padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, 0.96);
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -6px 22px rgba(15, 23, 42, 0.1);
        backdrop-filter: blur(12px);
    }

    .mobile-bottom-nav a {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 3px;
        color: #6b7280;
        font-size: 11px;
        font-weight: 700;
        text-decoration: none;
        border-radius: 10px;
    }

    .mobile-bottom-nav a span:first-child {
        font-size: 20px;
        line-height: 1;
    }

    .mobile-bottom-nav a.active,
    .mobile-bottom-nav a:hover {
        color: #2563eb;
        background: #eff6ff;
    }

}

/* 小型手機 */
@media (max-width: 420px) {

    .dashboard {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding-right: 12px;
        padding-left: 12px;
    }

    .summary-card {
        min-height: 145px;
        padding: 14px;
    }

    .summary-card p {
        font-size: 18px;
    }

    .quick-entry-panel .row {
        grid-template-columns: 1fr;
    }

    .quick-entry-panel .row > div {
        grid-column: 1 / -1;
    }

}
/* =====================================
   Mobile 2.0：隱藏手機版側邊選單
   ===================================== */

@media (max-width: 768px) {

    .sidebar {
        display: none;
    }

    .content {
        width: 100%;
        padding-top: 0;
    }

    .topbar {
        padding-top: 18px;
    }

}