/* ====== Zs服药提醒智能体 - 样式表 ====== */

:root {
    --primary: #10B981;
    --primary-dark: #059669;
    --primary-light: #D1FAE5;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --info: #3B82F6;
    --info-light: #DBEAFE;
    --bg: #F8FAFC;
    --card-bg: #FFFFFF;
    --text: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

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

/* ====== Layout ====== */
.container { max-width: 800px; margin: 0 auto; padding: 16px; }

/* ====== Header ====== */
.app-header {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.app-header .logo {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-header .logo .icon { font-size: 24px; }

.app-header .user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.app-header .user-menu a {
    color: white;
    opacity: 0.9;
}

.app-header .user-menu a:hover { opacity: 1; text-decoration: none; }

/* ====== Bottom Nav ====== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    z-index: 100;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.05);
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 11px;
    text-decoration: none;
    padding: 4px 12px;
    transition: color 0.2s;
}

.bottom-nav a:hover { text-decoration: none; }
.bottom-nav a.active { color: var(--primary); }

.bottom-nav a .nav-icon { font-size: 22px; }

/* ====== Cards ====== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.card-header {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ====== Stats Cards ====== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.info .stat-value { color: var(--info); }

/* ====== Buttons ====== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-success { background: var(--primary); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; border-radius: var(--radius); }
.btn-block { width: 100%; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ====== Today List ====== */
.today-list { list-style: none; }

.today-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.today-item:last-child { border-bottom: none; }
.today-item:hover { background: var(--bg); }

.today-item .time-badge {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-dark);
    background: var(--primary-light);
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
    min-width: 48px;
    text-align: center;
}

.today-item .time-badge.overdue {
    background: var(--danger-light);
    color: var(--danger);
}

.today-item .time-badge.done {
    background: #E5E7EB;
    color: var(--text-muted);
}

.today-item .med-info { flex: 1; min-width: 0; }
.today-item .med-info .med-name { font-weight: 600; font-size: 15px; }
.today-item .med-info .med-detail { font-size: 12px; color: var(--text-secondary); }

.today-item .action-btns {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.today-item .btn-action {
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.today-item .btn-taken { background: var(--primary); color: white; }
.today-item .btn-taken:hover { background: var(--primary-dark); }
.today-item .btn-delay { background: var(--warning-light); color: #92400E; }
.today-item .btn-delay:hover { background: var(--warning); color: white; }
.today-item .btn-skip { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.today-item .btn-skip:hover { background: var(--bg); }

.today-item.completed { opacity: 0.6; }
.today-item.completed .med-name { text-decoration: line-through; }

.status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
}

.status-badge.taken { background: var(--primary-light); color: var(--primary-dark); }
.status-badge.delayed { background: var(--warning-light); color: #92400E; }
.status-badge.skipped { background: #F3F4F6; color: var(--text-muted); }
.status-badge.pending { background: var(--info-light); color: #1D4ED8; }

/* ====== Forms ====== */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: var(--font);
    color: var(--text);
    background: var(--card-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input::placeholder { color: var(--text-muted); }

textarea.form-input {
    min-height: 80px;
    resize: vertical;
}

.form-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
    display: none;
}

.form-error.show { display: block; }

/* ====== Auth Pages ====== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 50%, #A7F3D0 100%);
    padding: 20px;
}

.auth-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
}

.auth-card .auth-logo {
    text-align: center;
    margin-bottom: 24px;
    font-size: 36px;
}

.auth-card .auth-title {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
}

.auth-card .auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 24px;
}

.auth-card .form-group { margin-bottom: 16px; }

.auth-link {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* ====== Upload Zone ====== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg);
    position: relative;
    overflow: hidden;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-zone .upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.upload-zone .upload-text {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.upload-zone .upload-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* ====== Preview ====== */
.upload-preview {
    margin-top: 16px;
    display: none;
}

.upload-preview.show { display: block; }

.upload-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ====== OCR Result ====== */
.ocr-result {
    display: none;
    margin-top: 16px;
}

.ocr-result.show { display: block; }

.ocr-result .ocr-raw {
    background: var(--bg);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
    white-space: pre-wrap;
    max-height: 120px;
    overflow-y: auto;
}

/* ====== Medicine List ====== */
.medicine-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 10px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.medicine-card:hover { box-shadow: var(--shadow-md); }

.medicine-card .med-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.medicine-card .med-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.medicine-card .med-content { flex: 1; min-width: 0; }
.medicine-card .med-content .med-name { font-weight: 600; font-size: 15px; }
.medicine-card .med-content .med-spec { font-size: 12px; color: var(--text-secondary); }
.medicine-card .med-content .med-expiry { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.medicine-card .expiry-warning {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--danger-light);
    color: var(--danger);
    flex-shrink: 0;
}

.medicine-card .expiry-soon {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--warning-light);
    color: #92400E;
    flex-shrink: 0;
}

/* ====== Empty State ====== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state .empty-icon { font-size: 56px; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 16px; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state .empty-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

/* ====== Alert / Warning ====== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 12px;
}

.alert-warning {
    background: var(--warning-light);
    color: #92400E;
    border: 1px solid #FCD34D;
}

.alert-danger {
    background: var(--danger-light);
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

.alert-info {
    background: var(--info-light);
    color: #1E40AF;
    border: 1px solid #93C5FD;
}

/* ====== Loading ====== */
.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.loading.show { display: block; }

.spinner {
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ====== Toast ====== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    color: white;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.show { opacity: 1; }
.toast.success { background: var(--primary); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }

/* ====== Tabs ====== */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 16px;
}

.tab-btn {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--card-bg);
    color: var(--primary);
    box-shadow: var(--shadow);
}

/* ====== History ====== */
.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.history-item:last-child { border-bottom: none; }

.history-item .status-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.history-item .status-icon.taken { background: var(--primary-light); }
.history-item .status-icon.delayed { background: var(--warning-light); }
.history-item .status-icon.skipped { background: #F3F4F6; }

.history-item .hist-content { flex: 1; min-width: 0; }
.history-item .hist-content .hist-name { font-weight: 600; font-size: 14px; }
.history-item .hist-content .hist-time { font-size: 12px; color: var(--text-secondary); }

/* ====== Reminder Settings ====== */
.reminder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.reminder-item .rem-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reminder-item .rem-time {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-dark);
}

.reminder-item .rem-detail {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #CBD5E1;
    border-radius: 28px;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ====== Modal ====== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: flex-end;
}

.modal-overlay.show { display: flex; }

.modal {
    background: var(--card-bg);
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px 20px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header .modal-title {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

/* ====== Page Title ====== */
.page-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-title .back-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
}

/* ====== Section ====== */
.section-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}

/* ====== Responsive ====== */
@media (min-width: 768px) {
    .container { padding: 24px; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .bottom-nav { max-width: 500px; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; }
    .auth-card { padding: 40px; }
    .modal { border-radius: 16px; margin: 20px; }
    .modal-overlay { align-items: center; }
}

@media (min-width: 1024px) {
    .container { max-width: 900px; }
    .app-header { padding: 12px 32px; }
}

/* ====== FAB ====== */
.fab {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab:hover { transform: scale(1.1); background: var(--primary-dark); }

/* ====== Medication detail page ====== */
.detail-image {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.detail-table {
    width: 100%;
    margin-bottom: 16px;
}

.detail-table td {
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.detail-table td:first-child {
    color: var(--text-secondary);
    width: 80px;
    font-weight: 600;
}
