/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background: linear-gradient(to bottom, #0a0a1a 0%, #1a0a2e 30%, #2d1b4e 60%, #1a0a2e 100%);
    color: #f0f0f0;
    min-height: 100vh;
    padding: 1rem;
    position: relative;
    overflow-x: hidden;
}

/* Night sky background with stars */
@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle 3s ease-in-out infinite;
}

.star:nth-child(1) { top: 10%; left: 20%; width: 2px; height: 2px; animation-delay: 0s; }
.star:nth-child(2) { top: 20%; left: 80%; width: 3px; height: 3px; animation-delay: 0.5s; }
.star:nth-child(3) { top: 30%; left: 40%; width: 2px; height: 2px; animation-delay: 1s; }
.star:nth-child(4) { top: 15%; left: 60%; width: 2px; height: 2px; animation-delay: 1.5s; }
.star:nth-child(5) { top: 25%; left: 10%; width: 3px; height: 3px; animation-delay: 2s; }
.star:nth-child(6) { top: 35%; left: 70%; width: 2px; height: 2px; animation-delay: 2.5s; }
.star:nth-child(7) { top: 5%; left: 50%; width: 2px; height: 2px; animation-delay: 0.3s; }
.star:nth-child(8) { top: 40%; left: 30%; width: 3px; height: 3px; animation-delay: 1.2s; }
.star:nth-child(9) { top: 12%; left: 90%; width: 2px; height: 2px; animation-delay: 1.8s; }
.star:nth-child(10) { top: 28%; left: 15%; width: 2px; height: 2px; animation-delay: 0.8s; }

/* Day theme */
body.day-sky {
    background: linear-gradient(to bottom, #87CEEB 0%, #98D8E8 30%, #B0E0E6 60%, #ADD8E6 100%);
    color: #333;
}

body.day-sky .stars {
    display: none;
}

body.day-sky .card {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(100, 150, 200, 0.3);
    color: #333;
}

body.day-sky .card-title {
    color: #4A90E2;
}

body.day-sky .input, 
body.day-sky .textarea {
    background: rgba(240, 248, 255, 0.7);
    border: 1px solid rgba(100, 150, 200, 0.3);
    color: #333;
}

body.day-sky .input:focus, 
body.day-sky .textarea:focus {
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.3);
}

body.day-sky .btn.primary {
    background: linear-gradient(to right, #4A90E2, #5BA8E8);
    color: white;
}

body.day-sky .btn.secondary {
    background: rgba(74, 144, 226, 0.2);
    color: #4A90E2;
    border: 1px solid rgba(74, 144, 226, 0.3);
}

body.day-sky .mode-btn {
    color: #4A90E2;
}

body.day-sky .mode-btn.active {
    background: linear-gradient(to right, #4A90E2, #5BA8E8);
    color: white;
}

body.day-sky .filter-btn {
    background: rgba(74, 144, 226, 0.2);
    color: #4A90E2;
}

body.day-sky .filter-btn.active {
    background: linear-gradient(to right, #4A90E2, #5BA8E8);
    color: white;
}

body.day-sky .dream-card {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(100, 150, 200, 0.3);
    color: #333;
}

body.day-sky .dream-title {
    color: #333;
}

body.day-sky .keyword {
    background: rgba(74, 144, 226, 0.2);
    color: #4A90E2;
    border: 1px solid rgba(74, 144, 226, 0.3);
}

body.day-sky .dream-date {
    color: #666;
}

body.day-sky .btn-icon {
    color: #4A90E2;
}

body.day-sky .btn-icon:hover {
    background: rgba(74, 144, 226, 0.2);
    color: #2A70C2;
}

body.day-sky .dream-details {
    border-top: 1px solid rgba(100, 150, 200, 0.3);
}

body.day-sky .dream-description {
    color: #444;
}

body.day-sky .ai-section {
    background: rgba(240, 248, 255, 0.7);
    border: 1px solid rgba(74, 144, 226, 0.3);
}

body.day-sky .ai-title {
    color: #4A90E2;
}

body.day-sky .ai-interpretation {
    color: #444;
}

body.day-sky .questions-list li {
    color: #444;
}

body.day-sky .questions-list li:before {
    color: #4A90E2;
}

body.day-sky .ai-chat-section {
    background: rgba(240, 248, 255, 0.7);
    border: 1px solid rgba(74, 144, 226, 0.3);
}

body.day-sky .ai-chat-message.user {
    background: rgba(74, 144, 226, 0.2);
}

body.day-sky .ai-chat-message.assistant {
    background: rgba(100, 150, 200, 0.2);
}

body.day-sky .ai-chat-role {
    color: #4A90E2;
}

body.day-sky .ai-chat-content {
    color: #444;
}

body.day-sky .ai-chat-text {
    background: rgba(240, 248, 255, 0.7);
    border: 1px solid rgba(100, 150, 200, 0.3);
    color: #333;
}

body.day-sky .empty-state {
    color: #666;
}

body.day-sky .empty-state .small {
    color: #888;
}

body.day-sky .footer {
    color: #666;
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1rem;
}

.title {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(to right, #c084fc, #f472b6, #60a5fa);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #c7d2fe;
    font-size: 1rem;
}

.user-info {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #a5b4fc;
}

/* Mode toggle */
.mode-toggle {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
    background: rgba(30, 30, 60, 0.8);
    border-radius: 50px;
    padding: 0.25rem;
    backdrop-filter: blur(10px);
}

.mode-btn {
    flex: 1;
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: #a5b4fc;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: linear-gradient(to right, #7e22ce, #db2777);
    color: white;
    box-shadow: 0 4px 15px rgba(126, 34, 206, 0.3);
}

/* Cards */
.card {
    background: rgba(30, 30, 60, 0.8);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(139, 92, 246, 0.3);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #c084fc;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Inputs */
.input, .textarea {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(139, 92, 246, 0.3);
    background: rgba(20, 20, 40, 0.7);
    color: white;
    font-size: 1rem;
}

.input:focus, .textarea:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3);
}

.textarea {
    min-height: 120px;
    resize: vertical;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.btn.primary {
    background: linear-gradient(to right, #7e22ce, #db2777);
    color: white;
    width: 100%;
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(126, 34, 206, 0.4);
}

.btn.secondary {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.btn.secondary:hover {
    background: rgba(99, 102, 241, 0.3);
}

.btn-icon {
    background: transparent;
    border: none;
    color: #a5b4fc;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(139, 92, 246, 0.2);
    color: #c084fc;
}

/* Search */
.search-container {
    margin-bottom: 1.5rem;
}

.search-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #a5b4fc;
}

.search-input {
    padding-left: 3rem;
}

/* Filter buttons */
.filter-buttons {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    flex: 1;
    padding: 0.5rem;
    border: none;
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    font-weight: 600;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.filter-btn.active {
    background: linear-gradient(to right, #7e22ce, #db2777);
    color: white;
}

/* Dreams list */
.dreams-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Dream card */
.dream-card {
    background: rgba(30, 30, 60, 0.8);
    border-radius: 1rem;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(139, 92, 246, 0.3);
    transition: all 0.3s ease;
}

.dream-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    border-color: rgba(139, 92, 246, 0.5);
}

/* Type-specific styling */
.dream-card.dream-type {
    border-left: 4px solid #8b5cf6; /* Purple for dreams */
}

.dream-card.day-type {
    border-left: 4px solid #fbbf24; /* Yellow for days */
}

.dream-header {
    display: flex;
    justify-content: space-between;
    padding: 1.25rem;
    align-items: flex-start;
}

.dream-info {
    flex: 1;
    min-width: 0;
}

.dream-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin-bottom: 0.5rem;
    word-break: break-word;
}

.type-indicator {
    margin-right: 0.5rem;
}

.dream-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.keyword {
    background: rgba(139, 92, 246, 0.2);
    color: #c084fc;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.dream-date {
    font-size: 0.8rem;
    color: #a5b4fc;
}

.dream-actions {
    display: flex;
    gap: 0.5rem;
}

.dream-details {
    padding: 0 1.25rem 1.25rem;
    border-top: 1px solid rgba(139, 92, 246, 0.2);
}

.dream-description {
    color: #e2e8f0;
    margin-bottom: 1rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* AI Section */
.ai-section {
    background: rgba(20, 20, 40, 0.7);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-top: 1rem;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.ai-title {
    font-size: 1rem;
    font-weight: 600;
    color: #a5b4fc;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-content {
    margin-bottom: 1rem;
}

.ai-interpretation {
    color: #e2e8f0;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.ai-questions h5 {
    color: #c084fc;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.questions-list {
    list-style-type: none;
}

.questions-list li {
    color: #e2e8f0;
    margin-bottom: 0.5rem;
    padding-left: 1.25rem;
    position: relative;
    font-size: 0.9rem;
    line-height: 1.4;
}

.questions-list li:before {
    content: "•";
    color: #8b5cf6;
    position: absolute;
    left: 0;
}

/* AI Chat Section */
.ai-chat-section {
    background: rgba(20, 20, 40, 0.7);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-top: 1rem;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.ai-chat-messages {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: rgba(10, 10, 30, 0.5);
    border-radius: 0.5rem;
}

.ai-chat-message {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.ai-chat-message.user {
    background: rgba(139, 92, 246, 0.2);
}

.ai-chat-message.assistant {
    background: rgba(99, 102, 241, 0.2);
}

.ai-chat-role {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: #c084fc;
}

.ai-chat-content {
    color: #e2e8f0;
    line-height: 1.4;
}

.ai-chat-input {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ai-chat-text {
    flex: 1;
    padding: 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(139, 92, 246, 0.3);
    background: rgba(20, 20, 40, 0.7);
    color: white;
    font-size: 0.9rem;
}

.ai-chat-send {
    padding: 0.5rem 1rem;
    background: linear-gradient(to right, #7e22ce, #db2777);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
}

.ai-chat-close {
    width: 100%;
}

/* Calendar Navigation */
.calendar-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.calendar-month-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #c084fc;
    text-align: center;
    flex: 1;
}

/* Calendar Grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
}

.calendar-day-header {
    text-align: center;
    padding: 0.5rem;
    font-weight: 600;
    color: #a5b4fc;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 20, 40, 0.7);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.calendar-day:hover {
    background: rgba(139, 92, 246, 0.3);
    transform: scale(1.05);
}

.calendar-day.has-dreams {
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.5);
}

.calendar-day.has-dream::after {
    content: "🌙";
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.6rem;
}

.calendar-day.has-day::after {
    content: "☀️";
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.6rem;
}

.calendar-day.has-dream.has-day::after {
    content: "🌙☀️";
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.6rem;
}

.calendar-day.today {
    background: linear-gradient(to right, #7e22ce, #db2777);
    color: white;
    font-weight: bold;
    border: 1px solid #8b5cf6;
}

.calendar-day.empty {
    background: transparent;
    border: none;
    cursor: default;
}

.calendar-day.empty:hover {
    background: transparent;
    transform: none;
}

/* Hidden utility class */
.hidden {
    display: none;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #a5b4fc;
}

.empty-state .small {
    font-size: 0.9rem;
    color: #c7d2fe;
    margin-top: 0.5rem;
}

/* Loading indicator */
.loading {
    text-align: center;
    padding: 2rem;
    color: #a5b4fc;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 2rem;
    padding: 1rem;
    color: #a5b4fc;
    font-size: 0.8rem;
}

/* Toasts */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: rgba(30, 30, 60, 0.95);
    color: white;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-left: 4px solid #8b5cf6;
    backdrop-filter: blur(10px);
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.toast.success {
    border-left-color: #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.info {
    border-left-color: #3b82f6;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 0.5rem;
    }
    
    .title {
        font-size: 1.75rem;
    }
    
    .card, .dream-card {
        padding: 1rem;
    }
    
    .dream-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .dream-actions {
        align-self: flex-end;
    }
    
    .mode-toggle {
        padding: 0.25rem;
    }
    
    .mode-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .ai-chat-input {
        flex-direction: column;
    }
    
    .filter-buttons {
        flex-direction: column;
    }
    
    .calendar-grid {
        gap: 0.1rem;
    }
    
    .calendar-day {
        font-size: 0.7rem;
    }
}

/* Icon styling */
.icon {
    display: inline-block;
}