/* 全局样式重置和变量 */
:root {
    --bg-light: #ffffff;
    --primary: #2196F3;
    --primary-dark: #0b7dda;
    --danger: #f44336;
    --text: #333333;
    --text-muted: #757575;
    --border: #dddddd;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    font-size: 16px;
}

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

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-light);
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container {
    max-width: 1000px;
    width: 100%;
    padding: 20px;
    text-align: center;
}

/* 按钮样式 */
.btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    margin: 10px;
    font-weight: 500;
}

.btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

.btn-back {
    background-color: #757575;
}

.btn-back:hover {
    background-color: #616161;
}

.btn-danger {
    background-color: var(--danger);
}

.btn-danger:hover {
    background-color: #d32f2f;
}

/* 表单样式 */
.form-container {
    margin: 30px auto;
    padding: 25px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: #f9f9f9;
    max-width: 600px;
    box-shadow: var(--shadow);
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--text);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.form-group textarea {
    min-height: 150px;
    resize: vertical;
    font-family: inherit;
}

/* 标题样式 */
h1, h2, h3, h4 {
    color: var(--text);
    margin-bottom: 20px;
    line-height: 1.4;
}

h1 {
    font-size: 2.2rem;
    margin-top: 0;
}

h2 {
    font-size: 1.8rem;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
    display: inline-block;
}

/* 首页样式 */
.home-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    text-align: center;
    padding: 20px;
}

.home-text {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 30px;
    line-height: 1.6;
}

/* 识别结果样式 */
.result-container {
    margin-top: 30px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: white;
    text-align: left;
    box-shadow: var(--shadow);
}

.result-name {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.result-description {
    line-height: 1.8;
    color: var(--text);
}

.result-description h3 {
    color: var(--primary);
    margin-top: 20px;
    margin-bottom: 10px;
}

.result-description ul,
.result-description ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.result-description img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 10px 0;
}

.result-description blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 15px;
    color: var(--text-muted);
    font-style: italic;
    margin: 15px 0;
}

/* 规则列表样式 */
.rules-list {
    margin-top: 30px;
}

.rule-item {
    margin-bottom: 20px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: white;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rule-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.rule-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary);
    flex: 1;
}

.rule-actions {
    display: flex;
    gap: 10px;
}

.rule-description {
    line-height: 1.6;
    color: var(--text);
}

/* 动物屏蔽设置样式 */
.mark-all-animals {
    margin: 20px auto;
    padding: 20px;
    background-color: #e3f2fd;
    border-radius: 8px;
    max-width: 600px;
    text-align: left;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: bold;
    color: var(--text);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

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

input:checked + .toggle-slider {
    background-color: var(--primary);
}

input:checked + .toggle-slider:before {
    transform: translateX(30px);
}

/* 预览容器样式 */
.preview-container {
    margin-top: 15px;
    padding: 15px;
    background-color: white;
    border: 1px solid var(--border);
    border-radius: 4px;
    min-height: 80px;
}

.preview-container h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--text);
    font-size: 1rem;
}

/* 消息提示样式 */
.success-message,
.error-message {
    padding: 15px;
    border-radius: 4px;
    margin: 20px auto;
    max-width: 600px;
    text-align: center;
    font-weight: 500;
}

.success-message {
    color: #4caf50;
    background-color: #e8f5e8;
    border: 1px solid #c8e6c8;
}

.error-message {
    color: #f44336;
    background-color: #ffebee;
    border: 1px solid #ffcdd2;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
        margin: 8px;
        width: 100%;
        max-width: 300px;
    }
    
    .form-container,
    .mark-all-animals {
        padding: 15px;
    }
    
    .rule-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .rule-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem;
    }
    
    .home-text {
        font-size: 1rem;
    }
    
    .form-group input,
    .form-group textarea {
        font-size: 14px;
        padding: 10px;
    }
}

.global-frame {
    min-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.flash-overlay {
    position: fixed;
    top: 18px;
    right: 18px;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    z-index: 60;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.flash-overlay.hide {
    opacity: 0;
    transform: translateY(-10px);
}

.flash-overlay.is-hidden {
    display: none;
}

.container {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

.flash-list {
    display: grid;
    gap: 0.8rem;
}

.flash {
    padding: 12px 20px;
    border-radius: 12px;
    border-left: 4px solid var(--accent);
    background: #e6f7ff;
    color: #0958d9;
    box-shadow: 0 6px 18px rgba(9, 88, 217, 0.12);
}

.recognition-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.recognition-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

.recognition-overlay__dialog {
    background: rgba(0, 0, 0, 0.65);
    padding: 1.6rem 2.2rem;
    border-radius: 16px;
    color: #fff;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 220px;
}

.recognition-overlay__spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    margin: 0 auto;
    animation: spin 0.8s linear infinite;
}

.hero-panel {
    background: linear-gradient(135deg, #c8e6c9, #a5d6a7);
    border-radius: 14px;
    padding: 1.1rem 1.3rem;
    color: #1b3d21;
    box-shadow: 0 12px 28px rgba(82, 196, 26, 0.18);
    margin-bottom: 1rem;
    max-width: 550px;
    margin-left: auto;
    margin-right: auto;
}

.hero-panel__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.8rem;
    align-items: center;
}

.hero-panel__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.hero-panel__subtitle {
    margin: 0.2rem 0 0.4rem;
    color: rgba(27, 61, 33, 0.7);
    font-size: 0.9rem;
}

.hero-panel__metrics {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.6rem;
}

.hero-panel__chip {
    flex: 1;
    min-width: 110px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.hero-panel__chip span {
    font-size: 0.85rem;
    color: rgba(27, 61, 33, 0.6);
}

.hero-panel__chip strong {
    display: block;
    font-size: 1.8rem;
    margin-top: 0.2rem;
    color: #fff;
}

.hero-panel__chip small {
    display: block;
    margin-top: 0.4rem;
    color: rgba(27, 61, 33, 0.8);
}

.hero-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.hero-logout {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.card h1,
.card h2 {
    margin: 0 0 1.2rem;
    color: var(--text);
}

.grid.two-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.8rem;
}

.center-card {
    max-width: 480px;
    margin: 0 auto;
}

.form-grid {
    display: grid;
    gap: 0.9rem;
}

label {
    font-weight: 600;
    color: var(--text);
}

input,
select,
textarea {
    font: inherit;
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(82, 196, 26, 0.2);
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 0.85rem 1.4rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn.primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 6px 18px rgba(82, 196, 26, 0.25);
}

.btn.primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn.ghost {
    background: #f0f9f4;
    color: var(--primary);
    border: 1px solid rgba(82, 196, 26, 0.4);
}

.btn.ghost:hover {
    background: #d8f3dc;
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

.metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    font-size: 1rem;
    color: var(--text-muted);
}

.metric strong {
    font-size: 2rem;
    color: var(--primary);
}

.camera-box {
    border: 2px dashed var(--border);
    border-radius: 14px;
    padding: 1rem;
    background: var(--muted-bg);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.camera-card {
    display: none;
}

.camera-trigger {
    margin-top: 0.4rem;
}

.mobile-upload-hint {
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 0.8rem;
    background: #fffef7;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.result-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.8rem;
}

.result-list li {
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fdfefb;
}

.result-list .prob {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.result-callout {
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 1.2rem;
    background: #fff;
    box-shadow: 0 10px 24px rgba(82, 196, 26, 0.12);
}

.table {
    display: grid;
    gap: 1rem;
}

.table__head,
.table__row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr 2fr;
    gap: 0.6rem;
    align-items: center;
}

.table__head {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table__row {
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 1rem 1.2rem;
    background: #fff;
    box-shadow: 0 8px 18px rgba(82, 196, 26, 0.12);
}

.table__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.table__actions form {
    display: inline-flex;
    gap: 0.4rem;
    align-items: center;
}

.table__actions input {
    width: 110px;
}

.table__actions select {
    min-width: 130px;
}

.hint {
    color: var(--text-muted);
    font-size: 0.9rem;
}

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

@media (max-width: 720px) {
    body {
        padding: 12px;
    }

    .navbar__inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .navbar__links a {
        margin-left: 0;
    }

    .grid.two-columns {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .table__head,
    .table__row {
        grid-template-columns: 1fr;
    }

    .hero-panel {
        max-width: 100%;
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .hero-panel__grid {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }

    .hero-panel__chip {
        min-width: auto;
        padding: 0.8rem;
    }

    .hero-panel__chip strong {
        font-size: 1.5rem;
    }

    .hero-panel__metrics {
        flex-direction: column;
        gap: 0.5rem;
    }

    .camera-card {
        display: none;
    }

    .mobile-upload-hint {
        display: block;
        text-align: center;
        font-size: 0.85rem;
        margin-top: 0.8rem;
    }

    .form-grid {
        max-width: none;
        margin: 0;
        gap: 0.8rem;
    }

    input,
    select,
    textarea {
        width: 100%;
        padding: 0.75rem 0.9rem;
        font-size: 16px; /* 防止iOS缩放 */
    }

    .btn {
        width: 100%;
        padding: 0.9rem 1.2rem;
        font-size: 1rem;
    }

    .recognition-overlay__dialog {
        min-width: 200px;
        padding: 1.4rem 1.8rem;
    }

    .recognition-overlay__spinner {
        width: 30px;
        height: 30px;
    }
}
