/* BNI 華字輩 Portal — 主樣式 */
:root {
  --red: #CF2030;
  --red-dark: #a51826;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-600: #6c757d;
  --gray-800: #343a40;
  --white: #ffffff;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', sans-serif; background: var(--gray-100); color: var(--gray-800); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }

/* Header */
.site-header { background: var(--red); color: white; padding: .75rem 0; box-shadow: 0 2px 4px rgba(0,0,0,.15); }
.header-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.logo { color: white; font-size: 1.2rem; font-weight: 700; letter-spacing: .02em; }
.logo:hover { text-decoration: none; }
.header-nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.header-nav a, .header-nav .user-greeting { color: rgba(255,255,255,.9); font-size: .9rem; }
.header-nav a:hover { color: white; text-decoration: underline; }
.badge { background: rgba(255,255,255,.2); border-radius: 20px; padding: .15rem .6rem; font-size: .8rem; color: white; }
.btn-link { background: none; border: none; cursor: pointer; color: rgba(255,255,255,.9); font-size: .9rem; padding: 0; }
.btn-link:hover { color: white; text-decoration: underline; }

/* Main */
.main-content { flex: 1; padding: 2rem 0; }
.site-footer { background: var(--gray-800); color: var(--gray-600); text-align: center; padding: 1rem; font-size: .85rem; margin-top: auto; }

/* Buttons */
.btn { display: inline-block; padding: .5rem 1.2rem; border-radius: var(--radius); font-size: .95rem; font-weight: 600; cursor: pointer; border: none; text-align: center; transition: background .15s; }
.btn-primary { background: var(--red); color: white; }
.btn-primary:hover { background: var(--red-dark); text-decoration: none; color: white; }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-secondary:hover { background: #d1d5db; text-decoration: none; }
.btn-success { background: #198754; color: white; }
.btn-success:hover { background: #157347; text-decoration: none; color: white; }
.btn-danger { background: #dc3545; color: white; }
.btn-danger:hover { background: #bb2d3b; text-decoration: none; color: white; }
.btn-sm { padding: .3rem .75rem; font-size: .85rem; }
.btn-full { width: 100%; display: block; }

/* Auth */
.auth-box { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; max-width: 420px; margin: 2rem auto; }
.auth-box-wide { max-width: 620px; }
.auth-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.5rem; color: var(--gray-800); text-align: center; }
.auth-links { margin-top: 1.25rem; display: flex; justify-content: space-between; font-size: .9rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .35rem; }
.form-group input, .form-group select { width: 100%; padding: .55rem .75rem; border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 1rem; }
.form-group input:focus, .form-group select:focus { outline: 2px solid var(--red); border-color: var(--red); }
.input-disabled { background: var(--gray-100); color: var(--gray-600); cursor: not-allowed; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; }
.required { color: var(--red); }
.form-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem; max-width: 640px; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 120px; }

/* Alerts */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .95rem; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem; }
.page-header h1 { font-size: 1.5rem; }
.subtitle { color: var(--gray-600); font-size: .95rem; margin-top: .25rem; }

/* Dashboard app grid — 響應式：手機 1 欄、平板 2 欄、桌機 3 欄 */
.app-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
@media (min-width: 700px) { .app-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .app-grid { grid-template-columns: repeat(3, 1fr); } }
.app-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; transition: box-shadow .15s; }
.app-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.app-card-body { padding: 1.25rem; flex: 1; }
.app-name { font-size: 1.1rem; font-weight: 700; color: var(--gray-800); margin-bottom: .5rem; }
.app-desc { font-size: .9rem; color: var(--gray-600); line-height: 1.5; }
.app-card-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--gray-200); }

/* Admin */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; text-align: center; }
.stat-number { font-size: 2.5rem; font-weight: 700; line-height: 1; margin-bottom: .25rem; }
.alert-red { color: var(--red); }
.stat-label { font-size: .9rem; color: var(--gray-600); margin-bottom: .75rem; }
.admin-nav { display: flex; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.admin-nav-item { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: .75rem 1.5rem; font-weight: 600; color: var(--red); }
.admin-nav-item:hover { background: var(--red); color: white; text-decoration: none; }
.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 1.5rem; }
.data-table th, .data-table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--gray-200); font-size: .9rem; }
.data-table th { background: var(--gray-100); font-weight: 700; }
.data-table tr:last-child td { border-bottom: none; }
.action-cell { display: flex; gap: .4rem; flex-wrap: wrap; }
.filter-form { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; align-items: center; }
.filter-form select, .filter-form input { padding: .45rem .75rem; border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: .9rem; }
.status-badge { padding: .15rem .6rem; border-radius: 20px; font-size: .8rem; font-weight: 600; }
.status-active { background: #d1fae5; color: #065f46; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-suspended { background: #fee2e2; color: #991b1b; }
.app-key { color: var(--gray-600); font-weight: normal; font-size: .85rem; }

/* Profile chips, sections, textareas */
.tool-chip { display: inline-block; background: var(--gray-200); color: var(--gray-600); font-size: .72rem; font-weight: 500; padding: .1rem .45rem; border-radius: 20px; vertical-align: middle; margin-left: .3rem; }
.section-title { font-size: 1.05rem; font-weight: 700; color: var(--gray-800); margin: 1.5rem 0 .75rem; padding-bottom: .4rem; border-bottom: 2px solid var(--gray-200); }
.subsection-title { font-size: .95rem; font-weight: 700; color: var(--gray-800); margin: 1.25rem 0 .5rem; }
.field-hint { font-size: .8rem; color: var(--gray-600); margin-top: .25rem; }
.form-group textarea { width: 100%; padding: .55rem .75rem; border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 1rem; font-family: inherit; resize: vertical; }
.form-group textarea:focus { outline: 2px solid var(--red); border-color: var(--red); }
.checkbox-group { display: flex; gap: 1.25rem; flex-wrap: wrap; margin-top: .25rem; }
.checkbox-label { display: flex; align-items: center; gap: .4rem; font-weight: 400; cursor: pointer; font-size: .95rem; }
.checkbox-label input[type="checkbox"] { width: auto; }

/* Error & misc */
.error-page { text-align: center; padding: 4rem 1rem; }
.error-icon { width: 64px; height: 64px; background: var(--red); color: white; border-radius: 50%; font-size: 2rem; font-weight: 700; line-height: 64px; margin: 0 auto 1.5rem; }
.error-page h1 { font-size: 1.75rem; margin-bottom: .75rem; }
.error-page p { color: var(--gray-600); margin-bottom: 1.5rem; }
.empty-state { text-align: center; padding: 3rem; color: var(--gray-600); }
.status-icon { font-size: 3rem; text-align: center; margin-bottom: 1rem; }
.text-center { text-align: center; }

/* Responsive */
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .auth-box { padding: 1.5rem; }
  .data-table { font-size: .8rem; }
  .data-table th, .data-table td { padding: .5rem .6rem; }
}
