/*
 * 檔案名稱：assets/css/app.css
 * 修改日期：2026/09/04 18:12（UTC+8）
 * 檔案用途：FAMS 共用響應式後台與安裝介面樣式
 * 修改說明：FAMS v0.1.0 初始版本
 */

:root {
    --bg: #f3f6f9;
    --panel: #ffffff;
    --line: #dce4ec;
    --text: #243040;
    --muted: #6d7a8a;
    --primary: #16697a;
    --primary-dark: #0f5664;
    --success: #2f7d4a;
    --danger: #b33a3a;
    --warning: #9a6b1d;
    --sidebar: #213847;
    --sidebar-text: #dfe8ed;
    --sidebar-active: #ffffff;
    --shadow: 0 8px 24px rgba(40, 57, 70, 0.08);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    color: var(--text);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
    font-size: 15px;
    line-height: 1.55;
}

body.no-scroll {
    overflow: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

button,
input,
select,
textarea {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    color: var(--text);
    background: #fff;
    border: 1px solid #cdd8e2;
    border-radius: 9px;
    outline: none;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 105, 122, 0.12);
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

small,
.muted {
    color: var(--muted);
}

.panel {
    margin-bottom: 18px;
    padding: 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel h2,
.panel h3 {
    margin-top: 0;
}

.notice {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid #d7e0e8;
    border-radius: 10px;
    background: #f7fafc;
}

.notice.success {
    color: #205c37;
    border-color: #b7d9c3;
    background: #eef8f2;
}

.notice.danger {
    color: #812c2c;
    border-color: #e4bcbc;
    background: #fff3f3;
}

.notice.warning {
    color: #75531c;
    border-color: #e3d1a7;
    background: #fff8e8;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
    background: #edf1f5;
}

.badge.success {
    color: #205c37;
    background: #e7f5ec;
}

.badge.danger {
    color: #8d2e2e;
    background: #fdeaea;
}

.badge.warning {
    color: #78561f;
    background: #fff2cf;
}

.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 14px;
    color: var(--text);
    background: #fff;
    border: 1px solid #cbd6df;
    border-radius: 9px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}

.button:hover {
    border-color: #9fb0bf;
    text-decoration: none;
}

.button.primary {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.button.primary:hover {
    background: var(--primary-dark);
}

.button.danger {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}

.button.large {
    min-height: 48px;
    padding: 10px 20px;
    font-size: 16px;
}

.button:disabled,
button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    padding: 0;
    border: 1px solid #cbd6df;
    border-radius: 9px;
    background: #fff;
    cursor: pointer;
}

.password-wrap {
    display: flex;
    gap: 6px;
}

.password-wrap input {
    min-width: 0;
}

.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid.cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-grid.cols-5 {
    grid-template-columns: 1.2fr .55fr 1.2fr 1fr 1.2fr;
}

.field {
    min-width: 0;
}

.inline-status {
    min-height: 24px;
    margin-top: 10px;
}

.inline-status.success {
    color: var(--success);
}

.inline-status.danger {
    color: var(--danger);
}

.app-shell {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 18px 14px;
    color: var(--sidebar-text);
    background: var(--sidebar);
}

.brand {
    padding: 4px 8px 16px;
}

.brand-title {
    font-size: 20px;
    font-weight: 800;
    color: #fff;
}

.brand-subtitle {
    margin-top: 2px;
    font-size: 12px;
    color: #a8bcc8;
}

.nav-group {
    margin-top: 12px;
}

.nav-label {
    padding: 9px 10px 5px;
    color: #91a7b4;
    font-size: 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 3px 0;
    padding: 10px 11px;
    color: var(--sidebar-text);
    border-radius: 9px;
    text-decoration: none;
}

.nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, .08);
    text-decoration: none;
}

.nav-link.active {
    color: var(--sidebar);
    background: var(--sidebar-active);
    font-weight: 700;
}

.main {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 66px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(8px);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.page-content {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

.page-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.page-title-row h1 {
    margin: 0;
    font-size: 25px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    padding: 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.stat-value {
    margin-top: 5px;
    font-size: 25px;
    font-weight: 800;
}

.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.toolbar .grow {
    flex: 1 1 240px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

table {
    width: 100%;
    min-width: 780px;
    border-collapse: collapse;
}

th,
td {
    padding: 11px 12px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid #e7edf2;
    white-space: nowrap;
}

th {
    color: #536170;
    background: #f7f9fb;
    font-size: 13px;
}

tbody tr.clickable {
    cursor: pointer;
}

tbody tr.clickable:hover {
    background: #f6fafb;
}

.actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(20, 30, 38, .55);
}

.modal-backdrop.open {
    display: flex;
}

.modal {
    display: flex;
    flex-direction: column;
    width: min(980px, 100%);
    max-height: calc(100vh - 40px);
    overflow: hidden;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, .25);
}

.modal.small {
    width: min(520px, 100%);
}

.modal-header,
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.modal-footer {
    justify-content: flex-end;
    border-top: 1px solid var(--line);
    border-bottom: 0;
}

.modal-body {
    overflow-y: auto;
    padding: 16px;
}

.toast-stack {
    position: fixed;
    z-index: 2000;
    top: 18px;
    right: 18px;
    display: grid;
    gap: 9px;
    width: min(390px, calc(100vw - 36px));
}

.toast {
    padding: 12px 14px;
    color: #fff;
    background: #34424d;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.toast.success {
    background: #2f7d4a;
}

.toast.danger {
    background: #a93636;
}

.toast.warning {
    background: #8a641e;
}

.mobile-menu-button {
    display: none;
}

.empty-state {
    padding: 34px 18px;
    text-align: center;
    color: var(--muted);
}

.login-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 20px;
    background: #edf3f8;
}

.login-card {
    width: min(460px, 100%);
    padding: 28px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin: 0 0 4px;
    font-size: 24px;
}

.login-card .field {
    margin-top: 14px;
}

.captcha-row {
    display: grid;
    grid-template-columns: 1fr 150px;
    gap: 8px;
    align-items: stretch;
}

.captcha-image {
    width: 150px;
    height: 42px;
    border: 1px solid #cbd6df;
    border-radius: 9px;
    background: #f9fbfc;
    cursor: pointer;
}

@media (max-width: 1050px) {
    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid.cols-4,
    .form-grid.cols-5 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 60;
        width: min(280px, 86vw);
        transform: translateX(-105%);
        transition: transform .2s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-menu-button {
        display: inline-flex;
    }

    .topbar {
        padding: 9px 12px;
    }

    .page-content {
        padding: 14px 12px 24px;
    }

    .page-title-row {
        flex-direction: column;
    }

    .cards,
    .form-grid.cols-2,
    .form-grid.cols-3,
    .form-grid.cols-4,
    .form-grid.cols-5 {
        grid-template-columns: 1fr;
    }

    .modal-backdrop {
        padding: 0;
    }

    .modal,
    .modal.small {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .captcha-row {
        grid-template-columns: 1fr 130px;
    }

    .captcha-image {
        width: 130px;
    }
}
