/* ==========================================================================
   Design System & Variables
   ========================================================================== */
:root {
    /* Color Palette */
    --clr-bg-gradient-start: #e0e7ff;
    --clr-bg-gradient-end: #f3e8ff;
    --clr-text-main: #1e293b;
    --clr-text-muted: #64748b;
    --clr-border: rgba(255, 255, 255, 0.4);
    --clr-glass-bg: rgba(255, 255, 255, 0.7);
    --clr-glass-shadow: rgba(31, 38, 135, 0.05);
    
    /* Event Colors */
    --clr-event-blue: #3b82f6;
    --clr-event-purple: #8b5cf6;
    --clr-event-pink: #ec4899;
    --clr-event-orange: #f97316;
    
    /* Typography */
    --font-primary: 'Plus Jakarta Sans', sans-serif;
    
    /* Layout & Spacing */
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    --radius-pill: 9999px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    color: var(--clr-text-main);
    background-color: #f8fafc;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button {
    font-family: var(--font-primary);
    border: none;
    background: none;
    cursor: pointer;
    outline: none;
}

input, textarea {
    font-family: var(--font-primary);
    outline: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* ==========================================================================
   Background & Animated Blobs (Glassmorphism Environment)
   ========================================================================== */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, var(--clr-bg-gradient-start) 0%, var(--clr-bg-gradient-end) 100%);
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 20s infinite alternate ease-in-out;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: #a5b4fc;
    top: -10%;
    left: -10%;
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
}

.blob-2 {
    width: 600px;
    height: 600px;
    background: #fbcfe8;
    bottom: -20%;
    right: -10%;
    border-radius: 60% 40% 30% 70% / 50% 60% 40% 50%;
    animation-delay: -5s;
    animation-duration: 25s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }
    100% {
        transform: translate(100px, 50px) rotate(45deg);
    }
}

/* ==========================================================================
   Layout Containers
   ========================================================================== */
.app-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* Reusable Glass Panel */
.glass-panel {
    background: var(--clr-glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px 0 var(--clr-glass-shadow);
}

/* ==========================================================================
   Header Section
   ========================================================================== */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #1a73e8, #00f2fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.month-navigation {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.month-title {
    font-size: 1.5rem;
    font-weight: 600;
    min-width: 180px;
    text-align: center;
    color: var(--clr-text-main);
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-pill);
    color: var(--clr-text-muted);
    transition: var(--transition-smooth);
}

.glass-btn {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    color: #1a73e8;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}

.modern-btn {
    background: rgba(255, 255, 255, 0.6);
    color: var(--clr-text-main);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.modern-btn:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   Main Calendar Layout
   ========================================================================== */
.calendar-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.calendar-days-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    padding: 1.25rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    background: rgba(255, 255, 255, 0.3);
}

.day-name {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--clr-text-muted);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(120px, 1fr);
    flex: 1;
    background: rgba(0, 0, 0, 0.02);
    gap: 1px; /* Creates delicate inner borders */
}

.calendar-cell {
    background: rgba(255, 255, 255, 0.4);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: var(--transition-smooth);
    cursor: pointer;
    overflow-y: auto;
    overflow-x: hidden;
}

.calendar-cell:hover {
    background: rgba(255, 255, 255, 0.8);
}

.inactive-month {
    opacity: 0.4;
}

.inactive-month:hover {
    opacity: 0.6;
}

.date-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--clr-text-main);
    border-radius: var(--radius-pill);
    align-self: flex-end;
    margin-bottom: 0.25rem;
}

.today .date-number {
    background: linear-gradient(135deg, #1a73e8, #00f2fe);
    color: white;
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3);
}

/* ==========================================================================
   Event Chips
   ========================================================================== */
.event-chip {
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    width: 100%;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: fade-in 0.3s ease-out forwards;
}

.event-chip:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    z-index: 2;
    position: relative;
}

.bg-blue   { background-color: var(--clr-event-blue); }
.bg-purple { background-color: var(--clr-event-purple); }
.bg-pink   { background-color: var(--clr-event-pink); }
.bg-orange { background-color: var(--clr-event-orange); }

/* ==========================================================================
   Floating Action Button (FAB)
   ========================================================================== */
.fab {
    position: fixed;
    bottom: 2.5rem;
    right: 2.5rem;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 10px 25px rgba(26, 115, 232, 0.4);
    z-index: 10;
    transition: var(--transition-smooth);
}

.modern-gradient-btn {
    background: linear-gradient(135deg, #1a73e8, #00f2fe);
    color: white;
    font-weight: 600;
}

.modern-gradient-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 14px 30px rgba(26, 115, 232, 0.5);
}

.modern-gradient-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================================================
   Modal & Forms
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    margin: 1.5rem;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 1);
    transform: translateY(0) scale(1);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal-content {
    transform: translateY(30px) scale(0.95);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--clr-text-main);
}

.close-btn {
    color: var(--clr-text-muted);
}

.close-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.modal-body {
    padding: 2rem;
}

.event-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--clr-text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.modern-input {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.6);
    font-size: 0.95rem;
    color: var(--clr-text-main);
    transition: var(--transition-smooth);
}

.modern-input:focus {
    background: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.event-title-input {
    font-size: 1.15rem;
    font-weight: 600;
    border: none;
    background: transparent;
    padding: 0.5rem 0;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 0;
}

.event-title-input:focus {
    background: transparent;
    border-color: #3b82f6;
    box-shadow: none;
}

textarea.modern-input {
    resize: vertical;
    min-height: 80px;
}

/* Custom Color Picker */
.color-picker {
    display: flex;
    gap: 1rem;
    padding-top: 0.25rem;
}

.color-option {
    cursor: pointer;
    position: relative;
}

.color-option input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.color-swatch {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-pill);
    transition: var(--transition-smooth);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    border: 3px solid transparent;
}

.color-option input:checked ~ .color-swatch {
    transform: scale(1.15);
    border-color: white;
    box-shadow: 0 0 0 2px var(--clr-text-muted);
}

.modal-footer {
    padding: 1.25rem 2rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.spacer {
    flex: 1;
}

.danger-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.danger-btn:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

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

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

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 900px) {
    .app-container {
        padding: 1rem;
    }
    
    .month-navigation {
        gap: 0.5rem;
    }
    
    .month-title {
        min-width: 140px;
        font-size: 1.2rem;
    }
}

@media (max-width: 600px) {
    .top-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .header-actions {
        width: 100%;
    }
    
    .header-actions .btn {
        width: 100%;
    }

    .calendar-grid {
        grid-auto-rows: minmax(80px, 1fr);
    }
    
    .calendar-cell {
        padding: 0.25rem;
    }
    
    .date-number {
        width: 24px;
        height: 24px;
        font-size: 0.8rem;
    }
    
    .day-name {
        font-size: 0.7rem;
    }
    
    .event-chip {
        padding: 0.2rem 0.3rem;
        font-size: 0.65rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .fab {
        width: 56px;
        height: 56px;
        bottom: 1.5rem;
        right: 1.5rem;
    }
}