/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
    /* Colors */
    --pink-50: #fef0f5;
    --pink-100: #fce4ec;
    --pink-200: #f8bbd0;
    --pink-300: #f48fb1;
    --pink-400: #ec407a;
    --pink-500: #e91e63;
    --purple-50: #faf0ff;
    --purple-100: #f3e5f5;
    --purple-200: #ce93d8;
    --purple-300: #ba68c8;
    --purple-400: #ab47bc;
    --gold-100: #fff8e1;
    --gold-200: #ffe082;
    --gold-300: #ffd54f;
    --gold-400: #ffca28;
    --gold-500: #ff8f00;
    --white: #ffffff;
    --text-primary: #3d1f35;
    --text-secondary: #6b4560;
    --text-muted: #9a7e93;
    --text-light: #c4a8bc;
    --bg-gradient: linear-gradient(160deg, #fce4ec 0%, #f3e5f5 40%, #ede7f6 70%, #fce4ec 100%);
    --card-bg: linear-gradient(145deg, #ffffff 0%, #fef6f9 100%);
    --card-shadow: 0 4px 24px rgba(233, 30, 99, 0.08);
    --card-shadow-hover: 0 8px 32px rgba(233, 30, 99, 0.14);

    /* Typography */
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-love: 'Caveat', cursive;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radii */
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --radius-full: 9999px;

    /* Transitions */
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 150ms var(--ease-smooth);
    --transition-medium: 300ms var(--ease-smooth);
}

/* ===== LOGIN GATE ===== */
.login-gate {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-gradient);
    background-attachment: fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.login-gate.hidden {
    display: none;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    width: 100%;
    max-width: 340px;
    animation: slideUp 0.5s var(--ease-bounce);
}

.login-emoji {
    font-size: 48px;
    margin-bottom: var(--space-md);
}

.login-title {
    font-family: var(--font-love);
    font-size: 28px;
    color: var(--pink-400);
    margin-bottom: var(--space-xs);
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 300;
    margin-bottom: var(--space-lg);
}

.login-input-wrapper {
    margin-bottom: var(--space-md);
}

.login-input-wrapper input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--pink-200);
    border-radius: var(--radius-full);
    font-family: var(--font-ui);
    font-size: 16px;
    color: var(--text-primary);
    background: var(--white);
    outline: none;
    transition: border-color var(--transition-fast);
    text-align: center;
}

.login-input-wrapper input:focus {
    border-color: var(--pink-400);
}

.login-input-wrapper input::placeholder {
    color: var(--text-light);
}

.login-error {
    color: var(--pink-500);
    font-size: 13px;
    margin-bottom: var(--space-md);
    animation: shake 0.4s ease;
}

.login-error.hidden {
    display: none;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-gradient);
    background-attachment: fixed;
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== APP CONTAINER ===== */
#app-header,
.view {
    max-width: 420px;
    margin: 0 auto;
    width: 100%;
}

/* ===== HEADER ===== */
#app-header {
    padding: var(--space-md) var(--space-md) 0;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(180deg, #fce4ec 0%, #fce4ecee 70%, #fce4ec00 100%);
    padding-bottom: var(--space-md);
}

.app-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-sm);
}

.app-title .heart {
    display: inline-block;
    animation: heartbeat 2s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.15); }
    30% { transform: scale(1); }
    45% { transform: scale(1.1); }
    60% { transform: scale(1); }
}

/* ===== NAVIGATION ===== */
.nav-bar {
    display: flex;
    gap: var(--space-xs);
    background: var(--white);
    border-radius: var(--radius-full);
    padding: var(--space-xs);
    box-shadow: var(--card-shadow);
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-sm) var(--space-md);
    border: none;
    background: transparent;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-ui);
    color: var(--text-muted);
}

.nav-btn.active {
    background: var(--pink-100);
    color: var(--pink-500);
}

.nav-btn:active {
    transform: scale(0.95);
}

.nav-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.nav-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ===== VIEWS ===== */
.view {
    display: none;
    padding: var(--space-lg) var(--space-md) var(--space-2xl);
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

.view.active {
    display: flex;
}

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

.view-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    text-align: center;
}

/* ===== INPUT VIEW ===== */
.date-display {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    text-align: center;
}

.input-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: var(--space-xl) var(--space-lg);
    box-shadow: var(--card-shadow);
    width: 100%;
    text-align: center;
}

.input-label {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.amount-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.euro-sign {
    font-size: 2.5rem;
    font-weight: 300;
    color: var(--text-muted);
}

#amount-input {
    font-family: var(--font-ui);
    font-size: 3rem;
    font-weight: 600;
    color: var(--text-primary);
    border: none;
    background: transparent;
    text-align: center;
    width: 160px;
    outline: none;
    border-bottom: 3px solid var(--pink-200);
    padding-bottom: var(--space-xs);
    transition: border-color var(--transition-fast);
    caret-color: var(--pink-400);
}

#amount-input::placeholder {
    color: var(--text-light);
    font-weight: 300;
}

#amount-input:focus {
    border-bottom-color: var(--pink-400);
}

.input-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
}

.input-error {
    font-size: 0.85rem;
    color: #e53935;
    margin-bottom: var(--space-md);
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

/* ===== BUTTONS ===== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    background: linear-gradient(135deg, var(--pink-400), var(--purple-300));
    color: var(--white);
    border: none;
    border-radius: var(--radius-full);
    font-family: var(--font-ui);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 16px rgba(233, 30, 99, 0.3);
    width: 100%;
    max-width: 280px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(233, 30, 99, 0.4);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

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

.btn-secondary {
    padding: var(--space-sm) var(--space-lg);
    background: var(--white);
    color: var(--pink-500);
    border: 2px solid var(--pink-200);
    border-radius: var(--radius-full);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--pink-50);
    border-color: var(--pink-300);
}

.btn-secondary:active {
    transform: scale(0.97);
}

.btn-love {
    padding: var(--space-md) var(--space-xl);
    background: linear-gradient(135deg, var(--pink-300), var(--purple-200));
    color: var(--white);
    border: none;
    border-radius: var(--radius-full);
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-medium);
    box-shadow: 0 4px 16px rgba(233, 30, 99, 0.2);
    animation: gentlePulse 2s ease-in-out infinite;
}

@keyframes gentlePulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(233, 30, 99, 0.2); }
    50% { box-shadow: 0 4px 24px rgba(233, 30, 99, 0.35); }
}

.btn-love:active {
    transform: scale(0.97);
}

.btn-text {
    padding: var(--space-sm) var(--space-md);
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: var(--space-lg);
    transition: color var(--transition-fast);
}

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

/* ===== ALREADY LOGGED STATE ===== */
.already-logged {
    text-align: center;
    width: 100%;
}

.already-logged-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    animation: popIn 0.5s var(--ease-bounce);
}

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

.already-logged-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.already-logged-summary {
    display: flex;
    gap: var(--space-lg);
    justify-content: center;
    margin-bottom: var(--space-lg);
}

/* ===== STAT DISPLAY ===== */
.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value.accent {
    color: var(--pink-500);
}

/* ===== REWARD VIEW ===== */
.reward-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: var(--space-xl) var(--space-lg);
    box-shadow: var(--card-shadow);
    width: 100%;
    text-align: center;
    animation: slideUp 0.5s var(--ease-bounce);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.reward-emoji {
    font-size: 4rem;
    margin-bottom: var(--space-md);
    animation: emojiPop 0.6s var(--ease-bounce);
}

@keyframes emojiPop {
    0% { transform: scale(0) rotate(-15deg); }
    60% { transform: scale(1.2) rotate(5deg); }
    80% { transform: scale(0.95) rotate(-2deg); }
    100% { transform: scale(1) rotate(0); }
}

.reward-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xl);
    line-height: 1.4;
}

.savings-summary {
    display: flex;
    gap: var(--space-xl);
    justify-content: center;
    padding-top: var(--space-lg);
    border-top: 1px solid var(--pink-100);
}

/* ===== ENVELOPE & LOVE MESSAGE ===== */
.envelope-container {
    margin-top: var(--space-xl);
    text-align: center;
    width: 100%;
    animation: slideUp 0.6s var(--ease-bounce) 0.3s both;
}

.envelope-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
    font-style: italic;
}

.envelope {
    position: relative;
    width: 280px;
    height: 180px;
    margin: 0 auto var(--space-lg);
    perspective: 800px;
    transition: height 0.6s var(--ease-smooth) 0.3s;
}

.envelope.opened {
    height: 0;
    margin-bottom: 0;
    overflow: hidden;
}

.envelope-back {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 130px;
    background: linear-gradient(145deg, #f8bbd0, #f3e5f5);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    z-index: 1;
}

.envelope-front {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 130px;
    background: linear-gradient(145deg, #fce4ec, #f8e8f0);
    clip-path: polygon(0 30%, 50% 0, 100% 30%, 100% 100%, 0 100%);
    z-index: 3;
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(180deg, #f48fb1, #f8bbd0);
    clip-path: polygon(0 0, 50% 100%, 100% 0);
    z-index: 4;
    transform-origin: top center;
    transition: transform 0.5s var(--ease-bounce);
}

.envelope.opened .envelope-flap {
    transform: rotateX(180deg);
    z-index: 0;
}

/* The letter is positioned OUTSIDE the envelope, hidden until opened */
.envelope-letter {
    display: none;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-xl) var(--space-lg);
    box-shadow: var(--card-shadow);
    width: 100%;
    text-align: center;
}

.envelope-letter.revealed {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: letterReveal 0.6s var(--ease-bounce);
}

@keyframes letterReveal {
    from { opacity: 0; transform: scale(0.9) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.love-text {
    font-family: var(--font-love);
    font-size: 1.35rem;
    line-height: 1.6;
    color: var(--text-primary);
    text-align: center;
}

.love-signature {
    font-family: var(--font-love);
    font-size: 1.05rem;
    color: var(--text-muted);
    margin-top: var(--space-sm);
    display: block;
}

/* ===== MILESTONE ALERT (on reward view) ===== */
.milestone-alert {
    margin-top: var(--space-lg);
    background: linear-gradient(135deg, var(--gold-100), var(--gold-200));
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    text-align: center;
    width: 100%;
    animation: slideUp 0.5s var(--ease-bounce) 0.6s both;
    box-shadow: 0 4px 16px rgba(255, 143, 0, 0.15);
}

.milestone-alert-emoji {
    font-size: 2.5rem;
    margin-bottom: var(--space-sm);
}

.milestone-alert-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gold-500);
}

/* ===== HISTORY VIEW ===== */
.history-stats-bar {
    display: flex;
    gap: var(--space-xl);
    justify-content: center;
    margin-bottom: var(--space-lg);
    width: 100%;
}

.stat-mini {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-mini-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.stat-mini-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.history-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.history-item {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    box-shadow: var(--card-shadow);
    transition: all var(--transition-fast);
}

.history-item.has-message {
    cursor: pointer;
}

.history-item.has-message:active {
    transform: scale(0.98);
    box-shadow: var(--card-shadow-hover);
}

.history-item.missed-day {
    background: linear-gradient(145deg, #fff9fb, #fef0f8);
    border: 1px dashed var(--pink-200);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xs);
}

.history-date {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.history-saved-badge {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--pink-500);
    background: var(--pink-100);
    padding: 2px var(--space-sm);
    border-radius: var(--radius-full);
}

.history-stats {
    display: flex;
    gap: var(--space-lg);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-message-hint {
    margin-top: var(--space-sm);
    font-size: 0.8rem;
    color: var(--pink-400);
    font-weight: 500;
}

.history-missed-hint {
    font-size: 0.85rem;
    color: var(--pink-400);
    font-weight: 500;
    font-style: italic;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
}

.empty-hint {
    font-size: 0.85rem;
    margin-top: var(--space-sm);
    color: var(--text-light);
}

/* ===== MILESTONES VIEW ===== */
.milestones-grid {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.milestone-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--card-shadow);
    transition: all var(--transition-medium);
}

.milestone-card.reached {
    background: linear-gradient(145deg, #fff8e1, #fff3cd);
    box-shadow: 0 4px 24px rgba(255, 143, 0, 0.12);
}

.milestone-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.milestone-emoji {
    font-size: 1.8rem;
}

.milestone-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.milestone-bar {
    height: 10px;
    background: var(--pink-100);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

.milestone-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pink-300), var(--purple-200));
    border-radius: var(--radius-full);
    width: var(--progress, 0%);
    transition: width 1s var(--ease-smooth);
}

.milestone-card.reached .milestone-bar-fill {
    background: linear-gradient(90deg, var(--gold-300), var(--gold-500));
}

.milestone-amount {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.milestone-badge {
    margin-top: var(--space-sm);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gold-500);
    text-align: center;
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(61, 31, 53, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-xl) var(--space-lg);
    max-width: 340px;
    width: 100%;
    text-align: center;
    animation: modalIn 0.4s var(--ease-bounce);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-md);
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: var(--space-xs);
    transition: color var(--transition-fast);
}

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

.modal-date {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.modal-divider {
    font-size: 1.2rem;
    margin-bottom: var(--space-md);
}

.modal-message {
    font-size: 1.3rem;
    margin-bottom: var(--space-md);
}

.modal-signature {
    font-family: var(--font-love);
    font-size: 1rem;
    color: var(--text-muted);
}

/* ===== CONFETTI CANVAS ===== */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    display: none;
}

/* ===== UTILITIES ===== */
.hidden {
    display: none !important;
}

/* ===== RESPONSIVE ===== */
@media (min-width: 400px) {
    #amount-input {
        font-size: 3.5rem;
    }

    .euro-sign {
        font-size: 2.8rem;
    }
}

@media (min-width: 600px) {
    body {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    #app-header {
        background: transparent;
    }
}

/* ===== SAFE AREA (notch phones) ===== */
@supports (padding-top: env(safe-area-inset-top)) {
    #app-header {
        padding-top: calc(var(--space-md) + env(safe-area-inset-top));
    }

    .view:last-of-type {
        padding-bottom: calc(var(--space-2xl) + env(safe-area-inset-bottom));
    }
}
