/**
 * 小宝命理站 - 万年历工具独立样式表 (style.css)
 * 包含全局布局变量、月历网格、右侧干支/宜忌详情卡片、岁时记编辑器、关联记录卡片与暗色/移动端适配
 */

/* ==========================================================================
   1. 布局变量与主题基础 (Layout Variables & Base Theme)
   ========================================================================== */
:root {
    --calendar-bg: transparent;
    --calendar-border: rgba(255, 255, 255, 0.1);
    --card-bg: transparent;
    --calendar-cell-bg: transparent;
    --today-bg: var(--primary-color);
    --selected-bg: rgba(var(--primary-rgb), 0.2);
}

@media (min-width: 992px) {
    .tool-container-standard {
        max-width: 1100px !important;
    }
}

.tool-container-standard::before,
.tool-container-standard::after {
    content: none !important;
}

.tool-container::before,
.tool-container::after {
    content: none !important;
}

body {
    justify-content: flex-start !important;
    background: transparent !important;
}

.calendar-layout {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 24px;
    align-items: stretch;
}

@media (max-width: 992px) {
    .calendar-layout {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .calendar-grid-card,
    .detail-card {
        height: auto !important;
    }
}

/* ==========================================================================
   2. 顶部控制栏 (Header & Navigation Controls)
   ========================================================================== */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--glass-bg);
    backdrop-filter: var(--background-blur);
    -webkit-backdrop-filter: var(--background-blur);
    border-bottom: 1px solid var(--glass-border);
    border-radius: 20px 20px 0 0;
    border: 1px solid var(--glass-border);
}

.controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-nav {
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
    color: var(--text-primary) !important;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-nav:hover {
    background: var(--primary-color) !important;
    color: white !important;
    transform: scale(1.1);
}

.current-month-display {
    font-size: 1.5rem !important;
    font-weight: 600;
    color: var(--primary-color) !important;
    min-width: 140px;
    text-align: center;
}

.btn-today {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 14px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px var(--mystic-shadow);
}

.btn-today:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 6px 16px var(--mystic-glow);
}

/* ==========================================================================
   3. 日历网格与日期单元格 (Calendar Grid & Day Cells)
   ========================================================================== */
.calendar-grid-card {
    background: var(--glass-bg);
    backdrop-filter: var(--background-blur);
    -webkit-backdrop-filter: var(--background-blur);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    overflow: hidden;
    box-shadow: none;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.weekday {
    text-align: center;
    font-weight: 700;
    padding: 12px 0;
    color: var(--text-primary);
    font-size: 0.95rem;
    background: transparent;
    border-radius: 8px;
    margin-bottom: 4px;
}

.day-cell {
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
    box-shadow: none !important;
}

.day-cell:hover {
    background: rgba(255, 255, 255, 0.7) !important;
    border-color: var(--primary-color) !important;
    z-index: 2;
}

.day-cell.other-month {
    opacity: 0.2;
    cursor: default;
}

.day-cell.today {
    background: var(--primary-color) !important;
    color: white !important;
    box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.5) !important;
    font-weight: 800;
    border: 2px solid #fff !important;
}

.day-cell.today .solar-day,
.day-cell.today .lunar-day {
    color: #fff !important;
}

.day-cell.selected {
    background: var(--glass-bg-hover) !important;
    border: 2px solid var(--primary-color) !important;
    box-shadow: 0 0 15px var(--mystic-glow), inset 0 0 10px rgba(8, 145, 178, 0.1) !important;
    transform: scale(1.05);
    z-index: 10;
}

.day-cell.selected.today {
    background: var(--primary-color) !important;
    border: 2px solid #fff !important;
    box-shadow: 0 0 15px rgba(8, 145, 178, 0.5) !important;
}

.day-cell:active {
    transform: scale(0.92);
    transition: transform 0.1s ease;
}

.solar-day {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
}

.lunar-day {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.term-tag {
    background: rgba(251, 191, 36, 0.15);
    color: #f59e0b;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
}

.festival-tag {
    color: #ef4444;
    font-size: 0.75rem;
    margin-top: 4px;
    font-weight: 600;
}

.shuo-tag {
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
}

.wang-tag {
    background: rgba(236, 72, 153, 0.15);
    color: #ec4899;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
}

.day-cell.lunar-shuo {
    border-color: rgba(99, 102, 241, 0.35) !important;
}

.day-cell.lunar-wang {
    border-color: rgba(236, 72, 153, 0.35) !important;
}

.shuo-wang-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 1px 5px;
    font-size: 9px;
    line-height: 12px;
    border-radius: 4px;
    font-weight: bold;
    color: white;
    z-index: 4;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.shuo-wang-badge.shuo {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

.shuo-wang-badge.wang {
    background: linear-gradient(135deg, #db2777, #e11d48);
}

.day-cell.has-legal-holiday .shuo-wang-badge {
    right: 24px;
}

.legal-holiday {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    font-size: 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    z-index: 5;
}

.holiday-xiu {
    background-color: #ef4444; /* 休 */
}

.holiday-ban {
    background-color: #64748b; /* 班 */
}

.day-cell.has-note::after {
    content: '';
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: breathe 2s infinite ease-in-out;
}

@keyframes breathe {
    0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.6; box-shadow: 0 0 4px var(--primary-color); }
    50% { transform: translateX(-50%) scale(1.6); opacity: 1; box-shadow: 0 0 12px var(--primary-color); }
}

@keyframes breathe-qimen {
    0%, 100% { transform: scale(1); opacity: 0.7; filter: drop-shadow(0 0 2px var(--tertiary-color)); }
    50% { transform: scale(1.3); opacity: 1; filter: drop-shadow(0 0 6px var(--tertiary-color)); }
}

@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(-15deg); }
    40% { transform: rotate(10deg); }
    60% { transform: rotate(-5deg); }
    80% { transform: rotate(5deg); }
}

/* ==========================================================================
   4. 右侧详情卡片与干支/宜忌区 (Detail Card & Ganzhi / Yi-Ji Info)
   ========================================================================== */
.detail-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--glass-bg);
    backdrop-filter: var(--background-blur);
    -webkit-backdrop-filter: var(--background-blur);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: none;
    height: 100%;
    box-sizing: border-box;
}

.detail-date {
    border-bottom: 1px solid var(--calendar-border);
    padding-bottom: 16px;
}

.detail-date h2 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.5rem;
}

.detail-lunar {
    font-size: 1.1rem;
    margin-top: 8px;
    color: var(--text-primary) !important;
}

#detail-weekday {
    color: var(--text-primary) !important;
}

.ganzhi-info {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 12px;
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 16px;
}

.ganzhi-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    gap: 2px;
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 8px;
    padding: 6px 2px;
}

.ganzhi-label {
    font-size: 0.7rem;
    color: var(--text-secondary) !important;
    font-weight: 600;
}

.ganzhi-value {
    font-weight: 700;
    color: var(--text-primary) !important;
    font-size: 1rem;
}

.almanac-section {
    margin-top: 24px;
}

.yi-ji-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.yi-ji-box {
    display: flex;
    gap: 12px;
}

.yi-ji-label {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
}

.yi-label {
    background: #10b981;
}

.ji-label {
    background: #ef4444;
}

.yi-ji-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 4px;
}

.yi-ji-item {
    font-size: 0.95rem;
    color: var(--text-primary) !important;
}

.term-details {
    margin-top: 24px;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.2);
    padding: 16px;
    border-radius: 12px;
    color: #d97706;
}

.term-time {
    font-weight: 700;
    display: block;
    margin-top: 4px;
}

/* ==========================================================================
   5. 岁时记编辑器与记事样式 (Note Editor Section)
   ========================================================================== */
.note-editor-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

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

.note-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
}

#note-textarea {
    height: 80px;
    resize: none;
}

.note-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.btn-save-note {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px;
    width: 100%;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s var(--ease-liquid);
    box-shadow: 0 4px 12px var(--mystic-shadow);
}

.btn-save-note:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--mystic-glow);
}

.save-status {
    font-size: 12px;
    color: var(--text-muted);
    transition: opacity 0.3s;
}

.login-prompt-card {
    margin-top: 24px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px dashed var(--glass-border);
    border-radius: 16px;
    text-align: center;
}

.login-prompt-card p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.btn-login-inline {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
}

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

/* ==========================================================================
   6. 生日提醒与关联记录卡片 (Birthday & Linked Record Cards)
   ========================================================================== */
.birthday-list {
    margin-bottom: 16px;
}

.birthday-item {
    background: rgba(236, 72, 153, 0.1);
    color: #ec4899;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.birthday-links {
    display: flex;
    gap: 15px;
    font-size: 18px;
}

.birthday-links a {
    text-decoration: none;
    filter: grayscale(1) opacity(0.6);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.birthday-links a:hover {
    filter: grayscale(0) opacity(1);
    transform: scale(1.3) rotate(8deg);
}

.qimen-record-list {
    margin-bottom: 16px;
}

.qimen-item {
    background: rgba(var(--tertiary-rgb, 99, 102, 241), 0.1);
    color: var(--tertiary-color);
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-left: 3px solid var(--tertiary-color);
    transition: transform 0.2s;
    cursor: pointer;
    text-decoration: none;
}

.qimen-item:hover {
    transform: translateX(4px);
    background: rgba(var(--tertiary-rgb, 99, 102, 241), 0.15);
}

.qimen-item .qm-title {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.qimen-item .qm-notes {
    font-size: 12px;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   7. 移动端与响应式适配 (Responsive Media Queries)
   ========================================================================== */
@media (max-width: 480px) {
    .tool-container {
        padding: 10px;
        gap: 16px;
    }

    .calendar-header {
        padding: 12px;
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .calendar-header .controls {
        justify-content: center;
    }

    .current-month-display {
        font-size: 1.1rem !important;
        min-width: 120px;
    }

    .calendar-grid-card {
        padding: 10px;
    }

    .calendar-grid {
        gap: 4px;
    }

    .weekday {
        padding: 8px 0;
        font-size: 0.8rem;
        margin-bottom: 2px;
    }

    .day-cell {
        border-radius: 8px;
    }

    .solar-day {
        font-size: 1rem;
    }

    .lunar-day {
        font-size: 0.6rem;
        transform: scale(0.9);
        margin-top: 2px;
    }

    .festival-tag {
        font-size: 0.6rem;
        transform: scale(0.9);
    }

    .legal-holiday {
        width: 12px;
        height: 12px;
        font-size: 8px;
        top: 2px;
        right: 2px;
        border-radius: 2px;
    }

    .detail-card {
        padding: 16px;
        gap: 12px;
        position: static;
        max-height: none;
    }

    .detail-date {
        padding-bottom: 12px;
    }

    .detail-date h2 {
        font-size: 1.3rem;
    }

    .ganzhi-info {
        gap: 8px;
    }

    .ganzhi-item {
        padding: 8px;
    }
}
