/* =================================================================
   最终版 完整CSS 文件 (超紧凑版)
   ================================================================= */

/* --- 1. 颜色变量与基础布局 --- */
:root {
    --bg-color: #2c3e50;
    --card-bg: #34495e;
    --text-color: #ecf0f1;
    --shadow-color: rgba(0, 0, 0, 0.2);
    
    /* 药丸颜色定义 */
    --pill-name-bg: #c0392b;
    --pill-date-bg: #7f8c8d;
    --pill-dose-bg: #8e44ad;
    --pill-age-bg: #27ae60;
    --pill-location-bg: #f39c12;
    --pill-days-bg: #2980b9;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

header h1 {
    color: #fff;
    text-align: center;
    margin-bottom: 30px;
}

/* --- 2. 卡片列表与药丸样式 (超紧凑版) --- */
.record-list {
    display: flex;
    flex-direction: column;
    gap: 8px; /* 从 10px 减小 */
}

.record-card {
    display: flex;
    align-items: stretch;
    gap: 5px; /* 从 6px 减小 */
    background-color: var(--card-bg);
    padding: 8px; /* 从 10px 减小 */
    border-radius: 7px; /* 从 8px 减小 */
    box-shadow: 0 2px 5px var(--shadow-color);
}

.pills-container {
    display: flex;
    flex-grow: 1;
    gap: 5px; /* 从 6px 减小 */
}

.pill {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 4px 8px; /* 从 5px 10px 减小 */
    border-radius: 5px; /* 从 6px 减小 */
    text-align: center;
    min-width: 65px; /* 从 75px 减小 */
}

.pill-label {
    font-size: 0.6em; /* 从 0.65em 减小 */
    font-weight: 500;
    opacity: 0.8;
    margin-bottom: 1px; /* 从 2px 减小 */
    text-transform: uppercase;
}

.pill-value {
    font-size: 0.8em; /* 从 0.85em 减小 */
    font-weight: 600;
    white-space: nowrap;
}

.pill.name { background-color: var(--pill-name-bg); flex-grow: 1; min-width: 120px; align-items: flex-start; } /* 从 140px 减小 */
.pill.date { background-color: var(--pill-date-bg); }
.pill.dose { background-color: var(--pill-dose-bg); }
.pill.age { background-color: var(--pill-age-bg); }
.pill.location { background-color: var(--pill-location-bg); }
.pill.days { background-color: var(--pill-days-bg); }

/* --- 3. 卡片操作按钮样式 --- */
.card-actions {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    gap: 5px; /* 从 6px 减小 */
}

.action-btn {
    background: none;
    border: 1px solid #7f8c8d;
    color: #ecf0f1;
    border-radius: 4px; /* 从 5px 减小 */
    padding: 1px 6px; /* 从 2px 8px 减小 */
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    font-size: 11px; /* 从 12px 减小 */
}

.action-btn.edit-btn:hover {
    background-color: var(--pill-days-bg);
    border-color: var(--pill-days-bg);
}

.action-btn.delete-btn:hover {
    background-color: var(--pill-name-bg);
    border-color: var(--pill-name-bg);
}


/* --- 4. 悬浮按钮(+) 和 弹窗(Modal) 样式 --- */
.fab {
    position: fixed;
    bottom: 25px; /* 从 30px 减小 */
    right: 25px; /* 从 30px 减小 */
    width: 50px; /* 从 55px 减小 */
    height: 50px; /* 从 55px 减小 */
    background-color: var(--pill-days-bg);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 30px; /* 从 32px 减小 */
    line-height: 50px; /* 从 55px 减小 */
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 999;
    transition: transform 0.2s ease;
}

.fab:hover {
    transform: scale(1.1);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 25px 30px;
    border-radius: 10px;
    position: relative;
    width: 100%;
    max-width: 600px;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.close-button {
    position: absolute;
    top: 10px;
    right: 20px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover {
    color: white;
}

/* --- 5. 表单样式 --- */
.form-container {
    padding-top: 15px;
}
.form-container h2 {
    text-align: center;
    color: #fff;
    margin-top: 0;
    margin-bottom: 20px;
    font-weight: 600;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.form-group {
    display: flex;
    flex-direction: column;
}
.form-group label {
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
    opacity: 0.9;
}
.form-group input {
    padding: 12px;
    border: 1px solid #556678;
    border-radius: 6px;
    font-size: 1em;
    font-family: inherit;
    background-color: #2c3e50;
    color: var(--text-color);
}
.form-group input:focus {
    outline: none;
    border-color: var(--pill-days-bg);
    box-shadow: 0 0 0 2px rgba(41, 128, 185, 0.4);
}
#submit-button {
    width: 100%;
    padding: 12px;
    margin-top: 25px;
    background-color: var(--pill-days-bg);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 45px;
}
#submit-button:hover:not(:disabled) {
    background-color: #3498db;
}
#submit-button.update-mode {
    background-color: var(--pill-age-bg);
}
#submit-button.update-mode:hover:not(:disabled) {
    background-color: #2ecc71;
}
#submit-button:disabled {
    background-color: #7f8c8d;
    cursor: not-allowed;
}
.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    width: 18px;
    height: 18px;
    animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- 6. 响应式布局 (手机端) --- */
@media (max-width: 768px) {
    .record-card, .pills-container {
        overflow-x: auto;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    .record-card::-webkit-scrollbar, .pills-container::-webkit-scrollbar {
        display: none;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .fab {
        bottom: 20px;
        right: 20px;
        width: 50px; /* 统一为 50px */
        height: 50px; /* 统一为 50px */
        font-size: 30px; /* 统一为 30px */
        line-height: 50px; /* 统一为 50px */
    }
}
