@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Playfair+Display:ital,wght@0,400;0,600;1,400&display=swap');

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: #fafafa;
    color: #1a1a1a;
    overscroll-behavior-y: none;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* --- CALENDAR SYSTEM --- */
.calendar-card {
    background: white;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
}

.calendar-card:active {
    transform: scale(0.98);
}

.date-badge {
    background: #f1f5f9;
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.slot-pill {
    display: block;
    width: 100%;
    padding: 8px;
    margin-bottom: 4px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    border: 1px solid #e2e8f0;
    color: #475569;
    transition: all 0.2s;
}

.slot-pill:hover:not(:disabled) {
    border-color: #6366f1;
    color: #6366f1;
    background: #eef2ff;
}

/* Heavy Glass - Only for static elements (Header/Modals) */
.glass-heavy {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Light Glass - For scrollable items (Performance optimized) */
.glass-light {
    background: rgba(255, 255, 255, 0.92);
    /* Removed backdrop-filter for scroll performance */
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.hidden {
    display: none !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.active-tab {
    background-color: white;
    color: var(--primary);
    box-shadow: 0 4px 12px -2px rgba(99, 102, 241, 0.2);
}

.message-bubble {
    position: relative;
    box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.12);
    /* Slightly more defined shadow */
    touch-action: pan-y;
    transform: translateZ(0);
    will-change: transform;
    padding: 6px 12px 4px 12px;
    /* Compact padding like WhatsApp */
    font-size: 14px;
    line-height: 1.45;
}

.message-row.cluster-start {
    margin-top: 12px;
    /* Gap between different sender blocks */
}

.message-row.cluster-continue {
    margin-top: 1px;
    /* Tighter gap for same sender */
}

.message-row.cluster-continue img {
    opacity: 0;
    pointer-events: none;
    /* Use opacity/visibility to maintain horizontal alignment of bubbles */
}

/* Stylized Love Note Bubble (Pink/Red) */
.love-note-bubble {
    background: linear-gradient(135deg, #ec4899 0%, #f43f5e 100%);
    color: white;
    font-weight: 600;
    padding: 1rem 1.5rem !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 20px -5px rgba(236, 72, 153, 0.4);
    text-align: center;
}

/* Stylized Love Echo Bubble (Blue/Indigo) */
.love-echo-bubble {
    background: linear-gradient(135deg, #4f46e5 0%, #0ea5e9 100%);
    color: white;
    font-weight: 600;
    padding: 1rem 1.5rem !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 20px -5px rgba(14, 165, 233, 0.4);
    text-align: center;
}

/* Say It Back Button */
.say-it-back-btn {
    margin-top: 8px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 3px 8px;
    border-radius: 10px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.6rem;
    font-weight: 600;
    color: white;
    opacity: 0.85;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    position: relative;
    z-index: 50;
    pointer-events: auto;
}

.say-it-back-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
    opacity: 1;
}

.say-it-back-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.25);
}

.swiping {
    transition: none !important;
    user-select: none;
}

.gradient-bg {
    background: radial-gradient(circle at top left, #e0e7ff 0%, #f3e8ff 50%, #fefce8 100%);
}

input:focus,
textarea:focus {
    outline: none;
}

@media screen and (max-width: 768px) {

    input,
    textarea {
        font-size: 16px !important;
    }
}

/* Animations */
@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(74, 222, 128, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
    }
}

.online-pulse {
    animation: pulse-green 2s infinite;
}

.typing-dot {
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

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

    40% {
        transform: scale(1);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-4px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(4px);
    }
}

.shake-it {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

/* Consolidated Action Bar */
.action-bar-container {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin: 0 16px;
}

.action-bar-container.active {
    max-height: 80px;
    opacity: 1;
    margin-bottom: -16px;
    /* Negative margin to pull bubble closer */
}

.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-bottom: none;
    border-radius: 20px 20px 0 0;
}

/* Heart Pulse for Echo Mode */
@keyframes heartbeat {
    0% {
        transform: scale(1);
    }

    15% {
        transform: scale(1.3);
    }

    30% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.3);
    }

    60% {
        transform: scale(1);
    }

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

.heart-pulse-active {
    animation: heartbeat 2s infinite;
    color: #eab308 !important;
    /* Gold */
    filter: drop-shadow(0 0 5px rgba(234, 179, 8, 0.5));
}

/* Love Animation */
@keyframes floatUp {
    0% {
        transform: translateY(100vh) scale(0.5) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    100% {
        transform: translateY(-20vh) scale(1.5) rotate(360deg);
        opacity: 0;
    }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.heart-particle {
    position: absolute;
    animation: floatUp 4s ease-in-out forwards;
    pointer-events: none;
    z-index: 9999;
    will-change: transform, opacity;
}

@keyframes professionalPop {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
        filter: blur(10px);
    }

    15% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
        filter: blur(0px);
    }

    25% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    85% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
        filter: blur(0px);
    }

    100% {
        transform: translate(-50%, -60%) scale(1.1);
        opacity: 0;
        filter: blur(20px);
    }
}

.love-text-anim {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 800;
    letter-spacing: -0.05em;
    color: #be185d;
    text-shadow: 0 10px 30px rgba(190, 24, 93, 0.3);
    animation: professionalPop 4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    pointer-events: none;
    z-index: 10000;
    white-space: nowrap;
    text-align: center;
    line-height: 1;
}

.echo-text-anim {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 800;
    letter-spacing: -0.05em;
    color: #0284c7;
    /* Sky Blue */
    text-shadow: 0 10px 30px rgba(14, 165, 233, 0.3);
    animation: professionalPop 4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    pointer-events: none;
    z-index: 10000;
    white-space: nowrap;
    text-align: center;
    line-height: 1;
}

/* Sidebar Tooltip */
.sidebar-tooltip {
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    white-space: nowrap;
    z-index: 999;
    pointer-events: none;
}

.group:hover .sidebar-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(15px);
}

/* Reaction Picker Grid */
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

#media-viewer img {
    transition: transform 0.1s ease-out;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    touch-action: none;
}

.reply-quote {
    border-left: 3px solid #cbd5e1;
    background: rgba(255, 255, 255, 0.5);
}

/* Context Menu */
#context-menu {
    transform-origin: top left;
    animation: menu-pop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes menu-pop {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #334155;
    transition: all 0.1s;
    cursor: pointer;
    white-space: nowrap;
}

.context-item:active {
    background: rgba(99, 102, 241, 0.1);
}

.message-controls-side {
    padding: 0 4px;
}

.side-control-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    background: transparent;
    border-radius: 50%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.side-control-btn:hover {
    background: rgba(99, 102, 241, 0.08);
    color: #6366f1;
    transform: translateY(-1px);
}

.side-control-btn:active {
    transform: scale(0.92);
}

.side-control-btn i {
    width: 14px;
    height: 14px;
}

/* Swipe Indicator */
.swipe-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%) scale(0);
    transition: transform 0.2s;
    z-index: 0;
    color: #6366f1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* --- UNIFIED TOP BAR STYLES (Desktop & Mobile) --- */
.top-bar {
    width: 100%;
    height: 60px;
    /* Fixed height */
    display: flex;
    flex-direction: row;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
    justify-content: space-between;
    align-items: center;
    z-index: 50;
    /* Changed from fixed to relative/flex item for stability with keyboard */
    position: relative;
    flex-shrink: 0;
}

/* Adjust main content to account for fixed header */
.content-wrapper {
    /* padding-top: 60px; Removed */
    /* height: 100dvh; Removed specific height, let flex handle it */
    flex: 1;
    /* Take remaining space */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Contain scroll */
    position: relative;
}

/* Tabs - Clean spacing */
nav {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
    background: rgba(255, 255, 255, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

nav button {
    padding-top: 4px;
    padding-bottom: 4px;
    font-size: 11px;
}

/* Adjust Content Area */
#section-chat {
    padding-left: 0;
    padding-right: 0;
}

#chat-messages {
    padding-bottom: 20px;
    padding-left: 12px;
    padding-right: 12px;
    /* Enhance scroll performance */
    -webkit-overflow-scrolling: touch;
}

.sidebar-tooltip {
    display: block !important;
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) !important;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    white-space: normal;
    text-align: center;
    min-width: 200px;
}

.group:active .sidebar-tooltip,
.group:hover .sidebar-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) !important;
}

.timestamp-read {
    font-size: 10px;
    opacity: 0.5;
    margin-top: 1px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    font-weight: 500;
    /* WhatsApp style weight */
}

/* Archive Styles */
.font-serif-elegant {
    font-family: 'Playfair Display', serif;
}

.archive-card {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.archive-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
}

.writing-paper {
    background-image: linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px);
    background-size: 100% 1.5rem;
    line-height: 1.5rem;
    background-color: #fffbf0;
}

.polaroid-shadow {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* --- DASHBOARD STYLES --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding-bottom: 80px;
}

.dashboard-widget {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 24px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    min-height: 160px;
}

.dashboard-widget:active {
    transform: scale(0.98);
}

.widget-large {
    grid-column: span 2;
}

.widget-title {
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.widget-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.widget-value {
    font-size: 28px;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.1;
    margin-bottom: 4px;
}

.widget-sub {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
}

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

.animate-fade-in-up {
    animation: fade-in-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#passcode-input {
    /* Prevent iOS zoom on focus while keeping it large and readable */
    font-size: 32px !important; 
    letter-spacing: 0.8em;
    text-indent: 0.4em; /* offset the last letter-spacing */
}

#passcode-input::placeholder {
    letter-spacing: normal;
    text-indent: 0;
    font-size: 16px;
}