/* 全局样式 */
:root {
    --primary-color: #1a73e8;
    --secondary-color: #34a853;
    --danger-color: #ea4335;
    --warning-color: #fbbc04;
    --text-color: #333;
    --light-text: #666;
    --background-color: #f8f9fa;
    --card-background: #fff;
    --border-color: #dadce0;
    --border-radius: 4px;
    --box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 登录模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 0;
    border: none;
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    text-align: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.form-tabs {
    display: flex;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 25px;
}

.form-tab {
    flex: 1;
    padding: 15px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.3s ease;
}

.form-tab.active {
    color: #667eea;
    border-bottom: 3px solid #667eea;
    font-weight: 600;
}

.form-tab:hover:not(.active) {
    background-color: #f8f9fa;
    color: #495057;
}

.login-container {
    padding: 25px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.password-container {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: #6c757d;
}

.input-feedback {
    font-size: 0.85rem;
    margin-top: 5px;
    min-height: 1.2em;
}

.divider {
    display: flex;
    align-items: center;
    margin: 25px 0;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background-color: #e9ecef;
}

.divider span {
    padding: 0 15px;
    color: #6c757d;
    font-size: 0.9rem;
}

.form-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: #6c757d;
}

.form-footer a {
    color: #667eea;
    text-decoration: none;
}

.form-footer a:hover {
    text-decoration: underline;
}

.modal-animation {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--primary-color);
    text-align: center;
}

/* 表单样式 */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--border-radius);
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%;
}

button:hover {
    background-color: #1557b0;
}

.btn-guest {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    margin-top: 10px;
}

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

/* 蓝牙设备扫描和列表样式 */
.scan-status {
    font-weight: 500;
    color: #495057;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
    border-left: 3px solid #007bff;
}

.btn-stop-scan {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    margin-bottom: 15px;
    transition: background-color 0.2s ease;
}

.btn-stop-scan:hover {
    background-color: #c82333;
}

.discovered-devices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.device-item {
    background-color: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.device-item:hover {
    border-color: var(--primary-color);
}

.device-name {
    font-weight: 600;
    color: #212529;
    font-size: 1.1rem;
}

.device-id {
    font-size: 0.85rem;
    color: #6c757d;
    font-family: monospace;
}

.btn-connect {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s ease;
    align-self: flex-start;
}

.btn-connect:hover:not(:disabled) {
    background-color: #218838;
}

.btn-connect:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-connect.connected {
    background-color: #17a2b8;
}

.connection-status {
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 5px;
}

.connection-status.connected {
    color: #28a745;
}

.connection-status:not(.connected) {
    color: #6c757d;
}

.no-devices {
    text-align: center;
    color: #6c757d;
    padding: 20px;
    font-style: italic;
}

.error-message {
    text-align: center;
    color: #dc3545;
    padding: 20px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.btn-primary:hover {
    background-color: #2c5aa0;
}

.btn-warning {
    background-color: #ffc107;
    color: #212529;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-warning:hover {
    background-color: #e0a800;
}

.settings-container {
    padding: 20px;
}

.setting-item {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.setting-item label {
    min-width: 150px;
    font-weight: 500;
}

.setting-item input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 100px;
}

.setting-info {
    margin-top: 15px;
    color: #666;
    font-size: 14px;
}

.error {
    color: var(--danger-color);
    margin-top: 10px;
    text-align: center;
}

/* 主应用样式 */
#app {
    opacity: 0;
    transition: opacity 0.3s ease;
}

#app:not(.hidden) {
    opacity: 1;
}

#app.hidden {
    display: none;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

header h1 {
    color: var(--primary-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#logoutBtn {
    width: auto;
    padding: 8px 16px;
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

#logoutBtn:hover {
    background-color: var(--primary-color);
    color: white;
}

/* 卡片样式 */
.card {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 25px;
    margin-bottom: 25px;
}

.card h2 {
    margin-bottom: 20px;
    color: var(--primary-color);
    font-size: 1.5rem;
}

/* 心率显示 */
.heart-rate-display {
    text-align: center;
}

.current-heart-rate {
    font-size: 4rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.current-heart-rate .unit {
    font-size: 1.5rem;
    font-weight: normal;
    color: var(--light-text);
    margin-left: 5px;
}

.status {
    font-size: 1.1rem;
    padding: 8px 16px;
    border-radius: 20px;
    display: inline-block;
    margin-top: 10px;
}

.status.normal {
    background-color: rgba(52, 168, 83, 0.1);
    color: var(--secondary-color);
}

.status.elevated {
    background-color: rgba(251, 188, 4, 0.1);
    color: var(--warning-color);
}

.status.danger {
    background-color: rgba(234, 67, 53, 0.1);
    color: var(--danger-color);
}

/* 图表容器 */
.chart-container {
    background-color: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-top: 10px;
    height: 300px;
    width: 100%;
}

/* 运动监测样式 */
.motion-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 15px;
}

.motion-stat {
    flex: 1;
    background-color: var(--primary-color);
    color: white;
    border-radius: var(--border-radius);
    padding: 15px;
    text-align: center;
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 2px;
}

.stat-coordinates {
    font-size: 12px;
    opacity: 0.9;
    margin-bottom: 2px;
    font-family: monospace;
}

.stat-unit {
    font-size: 12px;
    opacity: 0.8;
}

.stat-icon {
    font-size: 20px;
    margin-top: 5px;
}

.motion-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.motion-sensitivity {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 200px;
}

.motion-sensitivity label {
    font-weight: 500;
    color: #555;
}

.motion-sensitivity input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
}

.motion-sensitivity input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.motion-sensitivity input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

.motion-sensitivity span {
    min-width: 30px;
    text-align: center;
    font-weight: bold;
    color: #667eea;
}

/* 位置统计样式 */
.location-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    margin-top: 15px;
    gap: 15px;
}

/* 特定的位置统计卡片样式，使用纯色 */
.location-stats .motion-stat:nth-child(1) {
    background-color: #2196F3;
}

.location-stats .motion-stat:nth-child(2) {
    background-color: #FF9800;
}

.location-stats .motion-stat:nth-child(3) {
    background-color: #4CAF50;
}

/* 警告消息样式 */
.warning-message {
    background-color: #FFF3CD;
    color: #856404;
    padding: 10px 15px;
    border-radius: 8px;
    margin-top: 10px;
    border: 1px solid #FFEAA7;
    font-size: 14px;
    text-align: center;
}

/* 运动目标和提醒设置样式 */
.goals-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

@media (max-width: 768px) {
    .goals-container {
        grid-template-columns: 1fr;
    }
}

.goal-section, .reminder-section {
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 20px;
}

.goal-section h3, .reminder-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #495057;
    font-size: 18px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.goal-setting, .reminder-setting {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.goal-item, .reminder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.goal-item label, .reminder-item label {
    min-width: 120px;
    font-weight: 500;
    color: #495057;
}

.goal-item input, .reminder-item input[type="number"], .reminder-item select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    background-color: white;
    transition: border-color 0.3s ease;
}

.goal-item input:focus, .reminder-item input[type="number"]:focus, .reminder-item select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.reminder-item input[type="checkbox"] {
    margin-right: 5px;
    transform: scale(1.2);
}

.reminder-item select {
    cursor: pointer;
    min-width: 120px;
}

.goal-setting button, .reminder-setting button {
    margin-top: 10px;
    align-self: flex-start;
}

/* 进度条样式 */
.goal-progress {
    background-color: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.goal-progress h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #495057;
    font-size: 18px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.progress-bars {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.progress-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-item label {
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background-color: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

#timeProgress {
    background: linear-gradient(90deg, #f093fb 0%, #f5576c 100%);
}

.progress-item span {
    font-size: 14px;
    color: #6c757d;
    text-align: right;
}

/* 设备列表样式 */
.device-list {
    max-height: 300px;
    overflow-y: auto;
}

/* 扫描按钮样式 */
.scan-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    margin-bottom: 15px;
}

.scan-button:hover {
    background-color: #1557b0;
}

.scan-button:active {
    transform: scale(0.98);
}

/* 设备项样式 */
.device-item {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    border-radius: 6px;
    margin-bottom: 8px;
}

.device-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.device-item:hover {
    background-color: #f8f9fa;
}

.device-item.active {
    border-color: var(--secondary-color);
    background-color: rgba(52, 168, 83, 0.05);
    border-left: 4px solid var(--primary-color);
}

.device-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 5px;
}

.device-status {
    font-size: 0.9rem;
    color: var(--light-text);
}

.device-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.device-heart-rate {
    font-weight: 600;
    font-size: 18px;
    color: var(--primary-color);
}

.connect-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.connect-btn:hover:not(:disabled) {
    background-color: #2a8e44;
}

.connect-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

/* 状态容器 */
.status-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.label {
    font-weight: 500;
    color: var(--light-text);
}

.status-value {
    font-weight: 600;
}

.status-value.connected {
    color: var(--secondary-color);
}

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

/* 响应式设计 */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding-bottom: 15px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .current-heart-rate {
        font-size: 3rem;
    }

    .status-container {
        flex-direction: column;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }

    .container {
        padding: 15px;
    }

    .card {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.3rem;
    }

    .current-heart-rate {
        font-size: 2.5rem;
    }

    .card {
        padding: 15px;
        margin-bottom: 20px;
    }

    .card h2 {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }

    .container {
        padding: 10px;
    }

    button {
        padding: 10px 15px;
        font-size: 15px;
    }

    .device-list {
        max-height: 250px;
    }

    .device-item {
        padding: 12px;
    }

    .device-name {
        font-size: 15px;
    }

    .device-status {
        font-size: 0.8rem;
    }

    .device-heart-rate {
        font-size: 16px;
    }

    .scan-button {
        margin-bottom: 10px;
    }

    /* 通知在移动端的位置调整 */
    .notification {
        position: fixed;
        top: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
        margin: 0 auto;
    }
}

@media (max-width: 360px) {
    .current-heart-rate {
        font-size: 2rem;
    }

    .current-heart-rate .unit {
        font-size: 1.2rem;
    }

    header h1 {
        font-size: 1.1rem;
    }

    .card {
        padding: 12px;
    }

    .status {
        font-size: 1rem;
        padding: 6px 12px;
    }
}

/* 通知样式 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #fff;
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 350px;
    z-index: 1000;
    border-left: 4px solid #007bff;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform: translateX(0);
    opacity: 1;
}

.notification strong {
    display: block;
    font-size: 16px;
    margin-bottom: 5px;
    color: #333;
}

.notification p {
    margin: 0;
    font-size: 14px;
    color: #666;
}

/* 不同类型的通知 */
.notification-success {
    border-left-color: #28a745;
    background-color: #f8fff9;
}

.notification-error {
    border-left-color: #dc3545;
    background-color: #fff9f9;
}

.notification-warning {
    border-left-color: #ffc107;
    background-color: #fffdf0;
}

.notification-info {
    border-left-color: #17a2b8;
    background-color: #f8ffff;
}

/* 通知淡出动画 */
.notification.fade-out {
    transform: translateX(100%);
    opacity: 0;
}