/* ========== CSS Variables & Reset ========== */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --purple-gradient: linear-gradient(135deg, #667eea, #764ba2);
    --pink-gradient: linear-gradient(135deg, #f093fb, #f5576c);
    --blue-gradient: linear-gradient(135deg, #4facfe, #00f2fe);
    --orange-gradient: linear-gradient(135deg, #fa709a, #fee140);
    --green-gradient: linear-gradient(135deg, #11998e, #38ef7d);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --radius: 20px;
    --radius-sm: 12px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ========== Background Effects ========== */
.background-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: var(--purple-gradient);
    top: -200px;
    right: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: var(--pink-gradient);
    bottom: -100px;
    left: -100px;
    animation-delay: -5s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: var(--blue-gradient);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -10s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(30px, -30px) scale(1.05);
    }

    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }

    75% {
        transform: translate(20px, 10px) scale(1.02);
    }
}

/* ========== Container ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* ========== Header ========== */
header {
    text-align: center;
    margin-bottom: 50px;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: var(--purple-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    animation: glow 3s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        filter: drop-shadow(0 0 10px rgba(102, 126, 234, 0.3));
    }

    to {
        filter: drop-shadow(0 0 20px rgba(102, 126, 234, 0.6));
    }
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
    margin-bottom: 15px;
}

.current-time {
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
}

/* ========== Add Button ========== */
.add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 auto 40px;
    padding: 16px 32px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.add-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.plus-icon {
    font-size: 1.5rem;
    font-weight: 300;
}

/* ========== Events Grid ========== */
.events-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
}

/* ========== Event Card ========== */
.event-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 28px;
    position: relative;
    overflow: hidden;
    animation: cardEnter 0.5s ease-out;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.event-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.event-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--card-gradient);
}

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

/* 标题容器：让它占据剩余空间，而不是被挤压 */
.card-header>div:first-child {
    flex: 1;
    min-width: 0;
    /* 关键：允许 flex item 缩小到比内容更小，防止撑爆 */
    margin-right: 15px;
}

.event-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    /* 强制不换行 */
    white-space: nowrap;
    /* 移除之前的 max-width 限制，让 flexbox 控制 */
    width: 100%;
}

.event-date {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s ease;
    padding: 5px;
    line-height: 1;
    flex-shrink: 0;
    /* 防止按钮被挤压 */
}

.delete-btn:hover {
    opacity: 1;
    color: #ff6b6b;
    transform: scale(1.1);
}

/* ========== Time Display ========== */
.time-display {
    text-align: center;
    padding: 20px 0;
}

.time-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.time-value {
    display: flex;
    justify-content: center;
    gap: 4px;
    flex-wrap: nowrap;
    align-items: center;
}

.time-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 48px;
}

.time-number {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--card-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    transition: transform 0.1s ease;
}

.time-number.pulse {
    animation: pulse 0.3s ease;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.time-unit-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.time-separator {
    font-size: 2rem;
    color: var(--text-muted);
    font-weight: 300;
    align-self: flex-start;
    margin-top: 5px;
    animation: blink 1s ease-in-out infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* ========== Card Type Badge ========== */
.type-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 15px;
}

.type-badge.anniversary {
    background: rgba(102, 126, 234, 0.2);
    color: #a5b4fc;
}

.type-badge.countdown {
    background: rgba(240, 147, 251, 0.2);
    color: #f9a8d4;
}

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 32px;
    width: 90%;
    max-width: 450px;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

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

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

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: var(--text-primary);
}

/* ========== Form Styles ========== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="time"] {
    width: 100%;
    padding: 14px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease, background 0.2s ease;
}

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

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

/* Radio Group */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.radio-label:hover {
    color: var(--text-primary);
}

.radio-label input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--glass-border);
    border-radius: 50%;
    position: relative;
    transition: border-color 0.2s ease;
}

.radio-label input[type="radio"]:checked+.radio-custom {
    border-color: #667eea;
}

.radio-label input[type="radio"]:checked+.radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: var(--purple-gradient);
    border-radius: 50%;
}

/* Color Picker */
.color-picker {
    display: flex;
    gap: 12px;
}

.color-picker input[type="radio"] {
    display: none;
}

.color-option {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 3px solid transparent;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-picker input[type="radio"]:checked+.color-option {
    border-color: var(--text-primary);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* Submit Button */
.submit-btn {
    width: 100%;
    padding: 16px;
    background: var(--purple-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

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

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.empty-state-text {
    font-size: 1.1rem;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .current-time {
        font-size: 1.2rem;
    }

    .events-grid {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .event-title {
        white-space: normal;
        max-width: 100%;
    }

    .time-number {
        font-size: 2rem;
    }

    .time-unit {
        min-width: 50px;
    }

    .modal {
        padding: 24px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 20px 15px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .event-card {
        padding: 20px;
    }

    .time-number {
        font-size: 1.6rem;
    }
}

/* CSS Update for Next Anniversary Text */
.next-anniversary {
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 12px;
    border-radius: 8px;
    display: inline-block;
}

.next-anniversary strong {
    color: var(--text-primary);
    font-size: 1.1rem;
}