/* ============================================================
   FastAccount - ธีมสำหรับผู้ใช้งานวัย 40-80 ปี
   เน้น Mobile-First, ตัวอักษรใหญ่, ปุ่มใหญ่, สีสบายตา
   ============================================================ */

:root {
    --bg:           #f7f3ea;  /* เบจ/ขาวนวลอุ่น */
    --surface:      #ffffff;
    --text:         #2b2b2b;
    --muted:        #6b6b6b;
    --forest:       #1f6f43;  /* เขียวป่าเข้ม (รายรับ / ปุ่มหลัก) */
    --forest-dark:  #185536;
    --navy:         #1b3a5b;  /* น้ำเงินเนวี่เข้ม (หัวข้อ / แถบบน) */
    --navy-dark:    #142c46;
    --expense:      #9c3d2e;  /* แดงอิฐสบายตา (รายจ่าย) */
    --expense-dark: #7d3024;
    --border:       #d9d2c2;
    --shadow:       0 2px 10px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Sarabun', system-ui, -apple-system, sans-serif;
    font-size: 17px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
    padding-bottom: 88px; /* เผื่อพื้นที่แถบเมนูล่าง */
}

h1, h2, h3, h4, h5 {
    font-weight: 700;
    line-height: 1.35;
}
h1 { font-size: 26px; }
h2 { font-size: 23px; }
h3 { font-size: 20px; }

/* ---------- แถบหัวเรื่องด้านบน ---------- */
.app-header {
    background: var(--navy);
    color: #fff;
    padding: 16px 18px;
    text-align: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1020;
}
.app-header .title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
}
.app-header .subtitle {
    font-size: 16px;
    opacity: .85;
    margin: 2px 0 0;
}

/* ---------- กล่องเนื้อหา ---------- */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

/* กรอบรวมทั้งแอป (ใช้แสดงเป็นเฟรมมือถือกลางจอบน Desktop) */
.app-shell {
    width: 100%;
}

.card-soft {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 16px;
}

/* ---------- ฟอร์ม : ช่องกรอก/ปุ่ม สูง >= 52px ---------- */
.form-label {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--navy);
}

.form-control,
.form-select {
    min-height: 56px;
    font-size: 19px;
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    background-color: #fff;
}
.form-control:focus,
.form-select:focus {
    border-color: var(--forest);
    box-shadow: 0 0 0 .2rem rgba(31,111,67,.20);
}

/* ช่องจำนวนเงินตัวใหญ่พิเศษ */
.amount-input {
    min-height: 64px;
    font-size: 30px !important;
    font-weight: 700;
    text-align: center;
    color: var(--navy);
}

/* ---------- ปุ่ม ---------- */
.btn {
    min-height: 56px;
    font-size: 19px;
    font-weight: 600;
    border-radius: 12px;
    padding: 10px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-lg-block {
    width: 100%;
    min-height: 60px;
    font-size: 21px;
}

.btn-forest {
    background: var(--forest);
    border: 2px solid var(--forest);
    color: #fff;
}
.btn-forest:hover, .btn-forest:active { background: var(--forest-dark); color:#fff; }

.btn-navy {
    background: var(--navy);
    border: 2px solid var(--navy);
    color: #fff;
}
.btn-navy:hover, .btn-navy:active { background: var(--navy-dark); color:#fff; }

.btn-expense {
    background: var(--expense);
    border: 2px solid var(--expense);
    color: #fff;
}
.btn-expense:hover, .btn-expense:active { background: var(--expense-dark); color:#fff; }

.btn-outline-soft {
    background: #fff;
    border: 2px solid var(--border);
    color: var(--text);
}

.btn-danger-soft {
    background: #fff;
    border: 2px solid var(--expense);
    color: var(--expense);
    min-height: 48px;
    font-size: 17px;
}
.btn-danger-soft:hover { background: var(--expense); color: #fff; }

/* ---------- เมนูปุ่มใหญ่หน้าหลัก ---------- */
.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.menu-tile {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 18px;
    padding: 22px 12px;
    text-align: center;
    text-decoration: none;
    color: var(--navy);
    box-shadow: var(--shadow);
    min-height: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.menu-tile .icon { font-size: 40px; line-height: 1; }
.menu-tile .label { font-size: 19px; font-weight: 700; }
.menu-tile.income  { border-color: var(--forest); color: var(--forest); }
.menu-tile.expense { border-color: var(--expense); color: var(--expense); }

/* ---------- แท็บ ---------- */
.tab-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.tab-btn {
    flex: 1;
    min-height: 56px;
    border: 2px solid var(--border);
    background: #fff;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    color: var(--muted);
}
.tab-btn.active {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}
.tab-btn.active.income  { background: var(--forest); border-color: var(--forest); }
.tab-btn.active.expense { background: var(--expense); border-color: var(--expense); }

/* ---------- รายการ / ตาราง ---------- */
.list-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.list-item .name { font-size: 18px; font-weight: 600; }
.list-item .meta { font-size: 15px; color: var(--muted); }

/* ---------- กล่องสรุปยอด ---------- */
.summary-box {
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    color: #fff;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.summary-box.income  { background: var(--forest); }
.summary-box.expense { background: var(--expense); }
.summary-box .label { font-size: 18px; opacity: .9; }
.summary-box .value { font-size: 38px; font-weight: 800; margin-top: 4px; }

.amount-in  { color: var(--forest); font-weight: 700; }
.amount-out { color: var(--expense); font-weight: 700; }

/* ---------- แถบเมนูล่าง (Bottom Nav) ---------- */
.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    margin: 0 auto;            /* จัดกึ่งกลางเมื่ออยู่บนจอกว้าง */
    max-width: 600px;          /* คงความกว้างเสมือนมือถือบน Desktop */
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 1030;
    box-shadow: 0 -2px 10px rgba(0,0,0,.08);
}
.bottom-nav a {
    flex: 1;
    text-align: center;
    padding: 8px 2px;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}
.bottom-nav a .nav-icon { font-size: 24px; line-height: 1; }
.bottom-nav a.active { color: var(--navy); }

/* ---------- หน้าจอโหลด ---------- */
.loader-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 2000;
    font-size: 19px;
    color: var(--navy);
}
.spinner {
    width: 52px; height: 52px;
    border: 6px solid var(--border);
    border-top-color: var(--forest);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ข้อความแจ้งเตือน ---------- */
.alert-soft {
    border-radius: 12px;
    font-size: 17px;
    padding: 14px 16px;
}

.empty-text {
    text-align: center;
    color: var(--muted);
    font-size: 17px;
    padding: 20px 0;
}

/* ============================================================
   จอคอมพิวเตอร์ (Desktop) : แสดงผลเสมือนหน้าจอมือถือขนาดใหญ่
   อยู่กึ่งกลางจอ มีกรอบ เงา และเส้นขอบชัดเจน
   ============================================================ */
@media (min-width: 768px) {
    body {
        background: #ece5d6;          /* พื้นหลังเข้มขึ้นเล็กน้อยให้กรอบเด่น */
        padding: 28px 0 28px;
        min-height: 100vh;
    }

    .app-shell {
        max-width: 600px;
        margin: 0 auto;
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: 22px;
        box-shadow: 0 10px 35px rgba(0,0,0,.14);
        min-height: calc(100vh - 56px);
        position: relative;
        display: flex;
        flex-direction: column;
    }

    /* ในกรอบ Desktop หัวเรื่องเป็นส่วนหนึ่งของกรอบ มุมบนโค้งตามกรอบ */
    .app-header {
        position: static;
        border-radius: 22px 22px 0 0;
    }

    .app-container {
        flex: 1 1 auto;
        width: 100%;
        padding: 20px 22px;
    }

    /* แถบเมนูล่างให้ติดอยู่ก้นกรอบ และเลื่อนตามได้ */
    .bottom-nav {
        position: sticky;
        bottom: 0;
        left: auto; right: auto;
        max-width: none;
        border-bottom-left-radius: 22px;
        border-bottom-right-radius: 22px;
    }

    /* บน Desktop ไม่ต้องเผื่อพื้นที่ปุ่มล่างแบบ fixed */
    body { padding-bottom: 28px; }
}
