/* ═══════════════════════════════════════════════════════
   web.css — 前端统一样式
   ═══════════════════════════════════════════════════════ */

/* ── Reset & Base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box }
html { font-size: 18px; -webkit-text-size-adjust: 100%; text-size-adjust: 100% }
body { font-family: Roboto, "Microsoft YaHei", system-ui, sans-serif; background: #f5f5f5; color: #333; line-height: 1.6; }

/* ── Header / Sidebar (nav.php) ── */
.o-header { height: 50px; background: #f8f9fa; border-bottom: 1px solid #e1e1e1; box-shadow: 0 1px 4px rgba(0,0,0,.1); position: fixed; top: 0; left: 0; right: 0; z-index: 999; display: flex; align-items: center; padding: 0 22px; }
.o-header .logo { font-size: 22px; font-weight: 600; color: #333; margin-right: 30px }
.o-header .menu-toggle { width: 36px; height: 36px; border-radius: 4px; border: 1px solid #ddd; background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; margin-right: 20px }

.o-sidebar { width: 220px; height: calc(100vh - 50px); background: #2f3e48; position: fixed; top: 50px; left: 0; z-index: 998; transform: translateX(-100%); transition: transform .3s ease; overflow-y: auto }
.o-sidebar.active { transform: translateX(0) }
.o-sidebar .nav-item { display: block; padding: 12px 20px; color: #e9ecef; text-decoration: none; border-left: 3px solid transparent }
.o-sidebar .nav-item:hover,
.o-sidebar .nav-item.active { background: #384854; border-left-color: #4caf50; color: #fff }

.o-content { margin-left: 0; padding: 60px 20px 20px; transition: margin-left .3s ease }
.o-sidebar.active + .o-content { margin-left: 220px }

/* ── Page Title ── */
.page-title { padding: 15px 16px; background: #059669; color: #fff; font-size: 18px; font-weight: bold; display: flex; align-items: center; gap: 8px; }
.page-title a { color: #fff; text-decoration: none; }

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 12px }
.page-container { max-width: 1400px; margin: 0 auto; padding: 24px 16px }
@media (max-width: 1200px) { .page-container { padding: 20px 12px } }
@media (max-width: 768px) { .page-container { padding: 16px 8px } }

/* ── Cards ── */
.card, .section, .box { background: #fff; border-radius: 12px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06) }
.card h3 { margin: 0 0 4px; font-size: 17px; display: flex; align-items: center; gap: 6px }
.card .sub { color: #6b7280; font-size: 13px; margin-bottom: 14px }
.section-title { font-size: 20px; font-weight: bold; margin-bottom: 16px; color: #222; display: flex; align-items: center; justify-content: space-between }

/* ── Product Grid (index / product / adopt) ── */
.grid { display: grid; gap: 15px; grid-template-columns: repeat(1, 1fr) }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 18px } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 20px } }
@media (min-width: 1200px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 20px } }

.product-list { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; align-items: stretch; max-width: 1200px; margin: 0 auto; padding: 0 15px }
.product-card { width: 270px; background: #fff; border: 1px solid #eee; border-radius: 10px; padding: 16px; display: flex; flex-direction: column; justify-content: space-between }
.product-card:hover { transform: translateY(-3px); box-shadow: 0 4px 12px rgba(0,0,0,.1) }
.card-name, .product-card .name { font-weight: bold; margin-bottom: 6px; color: #333 }
.card-price, .product-card .price { color: #e53935; font-weight: bold; margin-bottom: 8px }
.card-intro, .product-card .intro { color: #666; line-height: 1.4; margin-bottom: 12px; min-height: 28px }

/* ── Buttons ── */
.add-btn, .btn-primary { background: #4caf50; color: #fff; border: none; border-radius: 6px; padding: 8px 12px; width: 100%; cursor: pointer; font-size: 14px; font-weight: 500; transition: background .2s, transform .1s }
.add-btn:hover, .btn-primary:hover { background: #45a049 }
.add-btn:active { transform: scale(.98) }

.btn { padding: 8px 18px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; display: inline-block; text-decoration: none; }
.btn-success { background: #4caf50; color: #fff; }
.btn-danger { background: #e53935; color: #fff; }
.btn-gray { background: #999; color: #fff; }
.btn-outline { background: #fff; color: #4caf50; border: 2px solid #4caf50; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Tags / Badges ── */
.tag { display: inline-block; padding: 2px 10px; border-radius: 4px; font-size: 12px; font-weight: 500; white-space: nowrap }
.tag-red { background: #fee2e2; color: #dc2626 }
.tag-green { background: #d1fae5; color: #059669 }
.tag-blue { background: #dbeafe; color: #2563eb }
.tag-orange { background: #fef3c7; color: #d97706 }
.tag-purple { background: #EEEBFF; color: #5E44D1 }
.tag-stage { background: #E6F0FF; color: #165DFF; padding: 3px 12px; border-radius: 6px; font-size: 13px; }
.tag-grade { padding: 3px 12px; border-radius: 6px; font-size: 13px; }
.tag-grade.organic { background: #D1F7DC; color: #009457 }
.tag-grade.green { background: #dcfce7; color: #059669 }
.tag-grade.normal { background: #f3f4f6; color: #6b7280 }
.tag-method { padding: 1px 8px; border-radius: 4px; font-size: 11px; background: #EEEBFF; color: #5E44D1; vertical-align: middle; margin-left: 8px }

/* ── Tabs ── */
.tabs { display: flex; gap: 8px; padding: 14px 16px; background: #fff; border-bottom: 1px solid #e5e7eb; overflow-x: auto }
.tabs a { padding: 7px 18px; border-radius: 20px; text-decoration: none; font-size: 14px; background: #f3f4f6; color: #666; white-space: nowrap; transition: .2s }
.tabs a:hover { background: #e5e7eb }
.tabs a.active { background: #059669; color: #fff; font-weight: 600 }

/* ── Tables (responsive, horizontally scrollable) ── */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px }
.table-scroll::-webkit-scrollbar { height: 6px }
.table-scroll::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 3px }
.table-scroll::-webkit-scrollbar-thumb { background: #c1c7cd; border-radius: 3px }
.table-scroll::-webkit-scrollbar-thumb:hover { background: #a0a7ae }

table { width: auto; border-collapse: collapse; font-size: 14px }
th, td { padding: 14px 12px; text-align: left; border-bottom: 1px solid #E5E6EB; vertical-align: top; line-height: 1.6 }
thead th { background: #f9fafb; font-weight: 600; color: #374151; position: sticky; top: 0; z-index: 2; white-space: nowrap }
tbody tr:nth-child(even) td { background: #F7F8FA }
tbody tr:hover td { background: #f0fdf4 }
@media (max-width: 768px) { th, td { padding: 10px 8px; font-size: 13px } }

/* ── Forms ── */
.form-group { margin-bottom: 16px }
.form-group label { display: block; margin-bottom: 6px; color: #555; font-size: 14px }
.form-control { width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 8px; font-size: 15px; outline: none; transition: border-color .2s }
.form-control:focus { border-color: #4caf50; box-shadow: 0 0 0 3px rgba(76,175,80,.1) }
select.form-control { background: #fff }

/* ── Filters bar ── */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 14px }
.filters select,
.filters input[type=text] { padding: 7px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px; outline: none; background: #fff; color: #374151; transition: .2s }
.filters select:focus,
.filters input[type=text]:focus { border-color: #059669; box-shadow: 0 0 0 3px rgba(5,150,105,.1) }
.filters .btn { padding: 7px 18px; background: #059669; color: #fff; border: none; border-radius: 8px; cursor: pointer; font-size: 13px }
.filters .btn:hover { background: #047857 }
.filters .clear { color: #6b7280; text-decoration: none; font-size: 13px; padding: 7px 0 }
.filters .clear:hover { color: #374151 }

/* ── Price / dosage text ── */
.price { color: #e53935; font-weight: bold }
.price small { font-size: 12px; font-weight: normal; color: #999 }
.dosage-text { color: #C73A3A; font-size: 14px; font-weight: 700; line-height: 1.6 }
.method-text { color: #4E5969; font-size: 14px; line-height: 1.6 }
.notice-text { color: #86909C; font-size: 12px; line-height: 1.5 }

/* ── Toast ── */
.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 10px 20px; border-radius: 8px; z-index: 1000; display: none; font-size: 14px; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.2) }
.toast.show { display: block; animation: fadeInDown .3s ease }
.toast.success { background: #4caf50 }
.toast.error { background: #e53935 }
@keyframes fadeInDown { from { opacity: 0; transform: translateX(-50%) translateY(-20px) } to { opacity: 1; transform: translateX(-50%) translateY(0) } }

/* ── Cart FAB ── */
.cart-fab { position: fixed; bottom: 80px; right: 20px; background: #4caf50; width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; text-decoration: none; box-shadow: 0 4px 12px rgba(0,0,0,.2); z-index: 99; transition: transform .2s, box-shadow .2s }
.cart-fab:hover { transform: scale(1.08); box-shadow: 0 6px 16px rgba(0,0,0,.25) }
.cart-badge { position: absolute; top: -5px; right: -5px; background: #e53935; color: #fff; border-radius: 50%; min-width: 22px; height: 22px; font-size: 12px; display: flex; align-items: center; justify-content: center; padding: 0 5px; font-weight: bold }

/* ── Empty state ── */
.empty, .empty-state { text-align: center; padding: 50px 20px; color: #999 }
.empty .icon, .empty-state .icon { font-size: 48px; margin-bottom: 8px }
.empty p, .empty-state p { margin: 0; font-size: 15px }
.empty-tip { text-align: center; color: #999; padding: 30px }

/* ── Status badges ── */
.order-status { display: inline-block; padding: 3px 8px; border-radius: 3px; font-size: 12px; background: #f5f5f5; color: #666; white-space: nowrap }
.status-pay { background: #e6f7ff; color: #1890ff }
.status-wait { background: #fff7e6; color: #fa8c16 }
.status-finish { background: #f0fff4; color: #52c41a }
.status-cancel { background: #fff2f0; color: #f5222d }

/* ── Misc ── */
.banner { background: linear-gradient(135deg, #4caf50, #38a169); color: #fff; padding: 36px 20px; border-radius: 16px; text-align: center; margin-bottom: 20px; box-shadow: 0 6px 20px rgba(76,175,80,.15) }
.sub { color: #6b7280; font-size: 13px; margin-bottom: 14px }
.sticky-top { position: sticky; top: 50px; z-index: 10 }
.footer { text-align: center; padding: 20px 0; color: #999; border-top: 1px solid #eee; margin-top: 30px; font-size: 14px }
.loading { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.5); display: none; justify-content: center; align-items: center; z-index: 1000 }
.loading.active { display: flex }
.spinner { width: 40px; height: 40px; border: 3px solid #f3f3f3; border-top: 3px solid #667eea; border-radius: 50%; animation: spin .8s linear infinite }
@keyframes spin { to { transform: rotate(360deg) } }

/* ── Login ── */
.login-box { max-width: 400px; margin: 60px auto; background: #fff; border-radius: 12px; padding: 30px; box-shadow: 0 2px 10px rgba(0,0,0,.08) }
.login-box h2 { text-align: center; margin-bottom: 24px; color: #333 }
.login-box .error { color: #ff4d4f; background: #fff2f2; padding: 10px 12px; border-radius: 6px; margin-bottom: 16px; text-align: center }

/* ── Disease / table name ── */
.disease-name { font-size: 16px; font-weight: 700; color: #1D2129; white-space: nowrap }

/* ── Sticky top bar (groupon, order_agri) ── */
.top { background: #059669; color: #fff; padding: 15px 16px; text-align: center; font-size: 18px; font-weight: bold; position: sticky; top: 0; z-index: 10 }
.top a { color: #fff; text-decoration: none; float: left; font-size: 16px }

/* ── List layout (order_agri, groupon) ── */
.list { padding: 12px }
.list .card { display: flex; border-radius: 12px; margin-bottom: 12px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.06) }
.list .card .img { width: 120px; min-height: 120px; background: #f3f4f6; display: flex; align-items: center; justify-content: center; font-size: 36px; flex-shrink: 0 }
.list .card .info { padding: 14px; flex: 1 }
.list .card .info h3 { margin: 0 0 6px; font-size: 17px }
.list .card .info .price { color: #059669; font-size: 20px; font-weight: 700 }
.list .card .info .meta { font-size: 13px; color: #666; margin-top: 4px }
.list .card .info .btn { display: inline-block; margin-top: 8px; padding: 6px 18px; background: #059669; color: #fff; border-radius: 6px; text-decoration: none; font-size: 14px }

/* ── Responsive helpers ── */
@media (max-width: 768px) {
  .o-sidebar { width: 100% }
  .o-sidebar.active + .o-content { margin-left: 0 }
  .o-content { padding: 50px 12px 12px }
}
