/* Import Modern Font */
@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;700&display=swap');

:root {
    --bg: #1e1e2e;
    --surface: #262638;
    --surface-2: #32324a;
    --surface-gradient: linear-gradient(145deg, #2a2a3d, #262638); /* New tactile gradient */
    --primary: #818cf8; /* Indigo */
    --primary-glow: rgba(129, 140, 248, 0.4);
    --text: #ffffff;
    --text-muted: #a1a1aa;
    --danger: #ef4444;
    --nav-height: 70px; 
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    -webkit-tap-highlight-color: transparent; 
}

/* ENHANCEMENT: Custom Dark Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

body { 
    background-color: var(--bg); 
    color: var(--text); 
    height: 100vh; 
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
}

/* --- 🔐 PIN GATE --- */
.gate-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg); z-index: 999; display: flex;
    justify-content: center; align-items: center; text-align: center;
    transition: transform 0.4s cubic-bezier(0.77, 0, 0.175, 1);
}
.gate-container.unlocked { transform: translateY(-100%); }

.logo { 
    font-size: 2.5rem; margin-bottom: 20px; letter-spacing: 1px; font-weight: 800;
    background: linear-gradient(135deg, #ffffff 30%, #818cf8 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.pin-display { display: flex; gap: 20px; justify-content: center; margin-bottom: 40px; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--primary); transition: all 0.2s; }
.pin-dot.filled { background: var(--primary); box-shadow: 0 0 15px var(--primary-glow); transform: scale(1.1); }

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 25px; max-width: 320px; margin: 0 auto; }
.num-btn {
    background: var(--surface); color: var(--text); border: none; font-size: 1.6rem;
    width: 75px; height: 75px; border-radius: 50%; cursor: pointer;
    box-shadow: 4px 4px 15px rgba(0,0,0,0.2), inset 1px 1px 1px rgba(255,255,255,0.1); 
    transition: transform 0.1s; font-weight: 700;
}
.num-btn:active { transform: scale(0.9); background: var(--surface-2); }
.num-btn.delete { color: var(--danger); font-size: 1.2rem; }

/* --- 📱 MAIN APP LAYOUT --- */
main { flex: 1; display: flex; flex-direction: column; height: 100%; position: relative; overflow: hidden; }
.hidden { display: none !important; }

/* ENHANCEMENT: Sticky Glass Header */
.app-header {
    padding: 20px 25px; display: flex; justify-content: space-between; align-items: center;
    /* Sticky Magic */
    position: sticky; top: 0; z-index: 40;
    background: rgba(30, 30, 46, 0.85);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#page-title {
    font-size: 1.8rem; font-weight: 700;
    background: linear-gradient(135deg, #ffffff 30%, #818cf8 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

/* --- VIEWS --- */
.view {
    flex: 1; overflow-y: auto; 
    padding: 20px 20px 140px 20px; /* Added top padding */
    display: none; animation: fadeIn 0.4s ease;
}
.view.active-view { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

/* --- CALENDAR --- */
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.calendar-header button { 
    background: var(--surface); border: none; color: var(--primary); 
    width: 45px; height: 45px; border-radius: 50%;
    font-size: 1.4rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.calendar-header h3 { font-size: 1.4rem; font-weight: 700; }

.calendar-days { 
    display: grid; grid-template-columns: repeat(7, 1fr); 
    gap: 8px; text-align: center; 
    color: var(--text-muted); font-size: 0.9rem; font-weight: bold; margin-bottom: 10px; 
}

/* ENHANCEMENT: Weekend Color Hint */
.calendar-days span:nth-child(1), .calendar-days span:nth-child(7) { color: var(--danger); opacity: 0.7; }

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

.day {
    aspect-ratio: 1; min-height: 40px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: 12px; cursor: pointer; font-size: 1rem; font-weight: 600; position: relative;
    transition: all 0.2s;
    background: rgba(255,255,255,0.02);
    border: 1px solid transparent; /* Prevents layout shift on hover */
}
.day:active { transform: scale(0.9); }
.day.active { background: var(--surface-2); border: 1px solid var(--primary); }
.day.selected { 
    background: var(--primary); color: #fff; 
    box-shadow: 0 4px 15px var(--primary-glow); transform: scale(1.05); 
}
.day.has-event::after {
    content: ''; position: absolute; bottom: 5px; width: 4px; height: 4px;
    background: var(--danger); border-radius: 50%; box-shadow: 0 0 5px var(--danger);
}

.event-list-container { margin-top: 25px; padding-top: 20px; border-top: 1px solid var(--surface-2); }
.event-item {
    background: var(--surface-gradient); /* Subtle gradient */
    padding: 18px; border-radius: 16px; margin-bottom: 12px;
    display: flex; justify-content: space-between; align-items: center;
    animation: slideUp 0.3s ease; box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.03);
}
.event-item .time { color: var(--primary); font-weight: 700; font-size: 0.9rem; margin-right: 15px; }
.delete-event { background: none; border: none; color: var(--text-muted); font-size: 1.4rem; padding: 5px; cursor: pointer; }

/* --- NOTES --- */
.notes-grid { display: grid; gap: 15px; }
#note-search { 
    width: 100%; padding: 12px 20px; border-radius: 25px; border: 1px solid transparent; 
    background: var(--surface); color: white; outline: none; font-size: 1rem;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2); transition: all 0.3s;
}
/* ENHANCEMENT: Focus Glow */
#note-search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

.note-card {
    background: var(--surface-gradient); /* Subtle gradient */
    padding: 20px; border-radius: 18px; cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2); transition: transform 0.2s;
    animation: slideUpFade 0.5s backwards;
    border: 1px solid rgba(255,255,255,0.03);
}
.note-card:nth-child(1) { animation-delay: 0.05s; }
.note-card:nth-child(2) { animation-delay: 0.1s; }
.note-card:nth-child(3) { animation-delay: 0.15s; }
.note-card:nth-child(4) { animation-delay: 0.2s; }
.note-card:nth-child(5) { animation-delay: 0.25s; }

.note-card:active { transform: scale(0.97); }
.note-card h4 { margin-bottom: 8px; color: var(--primary); font-size: 1.1rem; }
.note-card p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* --- EDITOR --- */
.editor-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg); z-index: 50; display: flex; flex-direction: column; padding: 25px;
    animation: slideUp 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.editor-header { display: flex; justify-content: space-between; margin-bottom: 25px; }
.editor-header button { background: none; border: none; color: var(--primary); font-size: 1.1rem; cursor: pointer; font-weight: 600; }
#editor-title { background: none; border: none; color: white; font-size: 1.8rem; font-weight: 700; margin-bottom: 20px; outline: none; width: 100%; }
#editor-content { flex: 1; background: none; border: none; color: var(--text-muted); font-size: 1.1rem; outline: none; resize: none; line-height: 1.6; }
.danger-btn { color: var(--danger); background: rgba(239, 68, 68, 0.1); border: 1px solid var(--danger); padding: 12px; border-radius: 12px; margin-top: 10px; font-weight: 600; }

/* --- NAVIGATION --- */
.bottom-nav {
    height: var(--nav-height); 
    background: rgba(30, 30, 46, 0.85); 
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    display: flex; justify-content: space-around; align-items: center;
    position: absolute; bottom: 0; width: 100%; 
    border-top-left-radius: 25px; border-top-right-radius: 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 -10px 30px rgba(0,0,0,0.3); z-index: 40;
}
.nav-item { background: none; border: none; display: flex; flex-direction: column; align-items: center; color: var(--text-muted); cursor: pointer; transition: color 0.3s; }
.nav-item.active { color: var(--primary); transform: translateY(-2px); }
.nav-item .icon { font-size: 1.6rem; margin-bottom: 4px; }
.nav-item .label { font-size: 0.75rem; font-weight: 600; }

/* --- FAB (Rounded Square) --- */
.fab {
    position: absolute; bottom: 90px; right: 25px; width: 60px; height: 60px;
    border-radius: 20px; 
    background: var(--primary); color: white; border: none;
    font-size: 2.2rem; box-shadow: 0 4px 20px var(--primary-glow); z-index: 30;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    cursor: pointer; display: flex; justify-content: center; align-items: center; padding-bottom: 6px;
}
.fab:active { transform: scale(0.9) rotate(90deg); }

/* --- MODAL --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px); z-index: 60; display: flex; justify-content: center; align-items: center;
    animation: fadeIn 0.2s;
}
.modal-card {
    background: var(--surface); padding: 30px; border-radius: 24px; width: 85%; max-width: 400px;
    display: flex; flex-direction: column; gap: 20px; box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.05);
}
.modal-card h3 { font-size: 1.4rem; color: var(--text); }

/* ENHANCEMENT: Input Styling */
.modal-card input { 
    padding: 15px; background: var(--bg); border: 1px solid var(--surface-2); 
    border-radius: 12px; color: white; outline: none; font-size: 1rem; transition: all 0.3s;
}
.modal-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

.modal-actions { display: flex; justify-content: flex-end; gap: 15px; margin-top: 10px; }
.modal-actions button { padding: 12px 25px; border-radius: 12px; border: none; cursor: pointer; font-weight: 600; font-size: 0.95rem; }
.modal-actions .primary { background: var(--primary); color: white; box-shadow: 0 4px 15px var(--primary-glow); }
.modal-actions .secondary { background: transparent; color: var(--text-muted); }

/* --- TOAST --- */
.toast {
    position: fixed; top: 40px; left: 50%; transform: translateX(-50%);
    background: var(--surface); color: white; padding: 12px 30px;
    border-radius: 30px; z-index: 1000; box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    animation: slideDown 0.4s; font-weight: 600; display: flex; align-items: center; gap: 10px;
}

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slideDown { from { transform: translate(-50%, -30px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}