/* CSS Custom Properties for theming */
:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #64748b;
    --text-color: #1e293b;
    --text-light: #64748b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
}

/* Dark mode variables */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #60a5fa;
        --primary-hover: #93c5fd;
        --text-color: #f1f5f9;
        --text-light: #94a3b8;
        --bg-color: #0f172a;
        --card-bg: #1e293b;
        --border-color: #334155;
    }
}

/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header styles */
.header {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.app-title {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.app-title i {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-size: 0.9rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--card-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.nav-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.nav-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: scale(1.05);
}

/* Main content layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px; /* Increased gap for better separation */
    flex: 1;
    min-height: 0; /* Important for flex children */
    overflow: hidden; /* Prevent overflow */
}

/* Calendar container */
.calendar-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for flex children */
    backdrop-filter: blur(10px);
    overflow: hidden; /* Prevent overflow */
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.month-display {
    text-align: center;
    flex: 1;
}

.month-display h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.month-display p {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Calendar grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 16px;
    flex: 1;
    min-height: 0; /* Important for flex children */
    padding: 20px;
    overflow-x: auto; /* Allow horizontal scrolling on small screens */
}

/* Weekday headers */
.weekday-header {
    text-align: center;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.8rem;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-color);
}

/* Day cells */
.day-cell {
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 15px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: var(--transition);
    background: var(--card-bg);
    position: relative;
    min-height: 140px; /* Increased height for better spacing */
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    margin-bottom: 10px; /* Add bottom margin for vertical separation */
    z-index: 1; /* Ensure proper stacking */
}

.day-cell:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.day-cell.today {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.05));
    border: 2px solid var(--primary-color);
    font-weight: 700;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.2);
}

.day-cell.other-month {
    color: var(--text-light);
    background: var(--bg-color);
    border-style: dashed;
    opacity: 0.6;
}

.day-cell.has-events::after {
    content: '';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.day-number {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: auto;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.events-preview {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: auto;
    max-height: 60px;
    overflow: hidden;
}

.event-dot {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--primary-color);
    opacity: 0.9;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

.event-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Sidebar */
.sidebar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 350px;
    overflow: hidden; /* Prevent overflow */
}

.events-section h3 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: var(--text-light);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.events-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.event-item {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    transition: var(--transition);
    border-left: 4px solid var(--primary-color);
}

.event-item:hover {
    transform: translateX(5px);
    background: var(--card-bg);
}

.event-time {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.event-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.event-desc {
    font-size: 0.85rem;
    color: var(--text-light);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.no-events {
    text-align: center;
    color: var(--text-light);
    font-style: italic;
    padding: 20px;
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: var(--transition);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-btn:hover {
    background: var(--bg-color);
    color: var(--text-color);
}

.modal-content {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-light);
    font-size: 0.9rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.color-picker {
    display: flex;
    align-items: center;
    gap: 15px;
}

.color-preview {
    font-family: monospace;
    font-size: 0.9rem;
    padding: 5px 10px;
    border-radius: 4px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
}

/* Checkbox styling */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.checkbox-label span {
    cursor: pointer;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.right-actions {
    display: flex;
    gap: 10px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* Responsive design */
@media (max-width: 768px) {
    .app {
        padding: 10px;
    }
    
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        order: -1;
        min-width: auto;
        max-width: none;
    }
    
    /* Mobile calendar - list view instead of grid */
    .calendar-grid {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 10px;
        overflow-x: hidden;
    }
    
    /* Hide weekday headers on mobile */
    .weekday-header {
        display: none;
    }
    
    .day-cell {
        min-height: 80px; /* Reduced height for mobile */
        padding: 12px; /* Reduced padding for mobile */
        border-radius: var(--radius);
        margin-bottom: 0; /* Remove bottom margin */
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 15px;
        min-width: auto; /* Remove min-width constraint */
    }
    
    .day-number {
        font-size: 1.2rem;
        font-weight: 700;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: var(--bg-color);
        border: 1px solid var(--border-color);
        flex-shrink: 0;
    }
    
    .day-cell.today .day-number {
        background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.1));
        border-color: var(--primary-color);
        color: var(--primary-color);
        font-weight: 700;
    }
    
    .day-cell.other-month .day-number {
        background: var(--bg-color);
        border-style: dashed;
        opacity: 0.6;
    }
    
    .events-preview {
        display: flex;
        flex-direction: row;
        gap: 8px;
        margin-top: 0;
        max-height: 20px;
        flex: 1;
        justify-content: flex-start;
    }
    
    .event-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        flex-shrink: 0;
    }
    
    .event-indicator {
        position: static;
        margin-left: auto;
        width: 24px;
        height: 24px;
        font-size: 0.8rem;
    }
    
    .events-preview + .event-indicator {
        margin-left: 10px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal {
        width: 95%;
        margin: 10px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .day-cell {
        min-height: 70px; /* Even smaller height */
        padding: 10px; /* Even smaller padding */
    }
    
    .day-number {
        font-size: 1.1rem;
        width: 35px;
        height: 35px;
    }
    
    .event-indicator {
        width: 20px;
        height: 20px;
        font-size: 0.7rem;
    }
    
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .app-title {
        gap: 10px;
    }
    
    .app-title i {
        font-size: 1.5rem;
    }
}

/* Animation for events */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.event-item {
    animation: fadeIn 0.3s ease;
}

/* Utility classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* Loading states */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Focus styles for accessibility */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Remove default focus styles for mouse users */
*:focus:not(:focus-visible) {
    outline: none;
}
