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

/* Performance optimizations - optimized for speed */
.card {
    /* Hardware acceleration - only when needed */
    transform: translateZ(0);
    /* Optimize rendering */
    contain: layout style paint;
    /* Reduce backdrop-filter for better performance */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.diary-textarea {
    /* Optimize text rendering */
    contain: layout style;
    /* Hardware acceleration for smooth typing */
    transform: translateZ(0);
}

/* Optimize cloud animations */
body::before {
    /* Hardware acceleration for background animations */
    transform: translateZ(0);
    /* Reduce animation complexity */
    will-change: transform;
}

/* Optimize animations for better performance */
@media (prefers-reduced-motion: no-preference) {
    .card:hover {
        /* Use transform instead of box-shadow for better performance */
        transform: translateY(-5px) translateZ(0);
    }
    
    .nav-btn:hover:not(:disabled),
    .history-btn:hover,
    .save-btn:hover,
    .emoji-btn:hover {
        transform: scale(1.05) translateZ(0);
    }
    
    .panda-image:hover {
        transform: scale(1.1) translateZ(0);
    }
    
    .history-entry:hover {
        transform: translateY(-2px) translateZ(0);
    }
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #98D8E8 25%, #B0E0E6 50%, #ADD8E6 75%, #87CEEB 100%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Cloud Background Animation - Optimized */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Simplified gradients for better performance */
    background: 
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.25) 0%, transparent 40%),
        radial-gradient(circle at 80% 40%, rgba(255, 255, 255, 0.15) 0%, transparent 40%);
    pointer-events: none;
    z-index: -1;
    /* Slower animation for better performance */
    animation: cloudFloat 30s ease-in-out infinite;
    /* Hardware acceleration */
    transform: translateZ(0);
    will-change: transform;
}

@keyframes cloudFloat {
    0%, 100% { transform: translateX(0px) translateY(0px) translateZ(0); }
    50% { transform: translateX(10px) translateY(-5px) translateZ(0); }
}

/* Container Layout */
.container {
    display: flex;
    min-height: 100vh;
    padding: 20px;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.left-column, .right-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Make left column cards equal height */
.left-column .card {
    flex: 1;
    min-height: 0; /* Allow flex shrinking */
}

/* Glassmorphism Card Styles - Optimized */
.card {
    background: rgba(255, 255, 255, 0.15);
    /* Reduced blur for better performance while maintaining glass effect */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 25px;
    /* Simplified box-shadow for better performance */
    box-shadow: 
        0 8px 24px rgba(31, 38, 135, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    /* Hardware acceleration */
    transform: translateZ(0);
    /* Optimize rendering */
    contain: layout style paint;
}

.card:hover {
    transform: translateY(-5px) translateZ(0);
    /* Simplified hover shadow for better performance */
    box-shadow: 
        0 12px 32px rgba(31, 38, 135, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.card h3 {
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 20px;
    font-size: 1.3rem;
}





/* Mood Styles */
.mood-card {
    display: flex;
    flex-direction: column;
    flex: 0.7; /* Take up more space to balance with smaller time card */
}

.mood-info {
    text-align: center;
    margin-bottom: 20px;
}

.current-mood {
    font-size: 1.1rem;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 10px;
}

.mood-emoji {
    font-size: 2.5rem;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

.mood-emoji:hover {
    transform: scale(1.1);
}

.mood-selector {
    margin-top: 15px;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    max-width: 100%;
    /* Perfect for 2 rows of 5 emojis each */
}

.emoji-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 12px 8px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #2c3e50;
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.emoji-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.emoji-btn.selected {
    background: rgba(52, 152, 219, 0.3);
    border-color: rgba(52, 152, 219, 0.6);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.3);
}

/* Photo Album Card Styles */
.photo-album-card {
    display: flex;
    flex-direction: column;
    flex: 1;
    margin-bottom: 20px;
}

.photo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.photo-preview {
    width: 100%;
    height: 200px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
}

.photo-preview:hover {
    border-color: rgba(52, 152, 219, 0.5);
    background: rgba(255, 255, 255, 0.15);
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 13px;
}

.photo-placeholder {
    text-align: center;
    color: #7f8c8d;
}

.photo-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 10px;
}

.photo-placeholder p {
    margin: 5px 0;
    font-size: 0.9rem;
}

.photo-hint {
    font-size: 0.8rem;
    color: #95a5a6;
    font-style: italic;
}

.photo-controls {
    display: flex;
    gap: 10px;
    width: 100%;
}

.photo-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #2c3e50;
    border-radius: 25px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
    flex: 1;
}

.photo-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.photo-btn:active {
    transform: translateY(0);
}

/* Diary Card Styles */
.diary-card {
    min-height: 600px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.diary-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    position: relative;
}

.panda-corner {
    position: absolute;
    top: -10px;
    right: -10px;
}

.panda-image {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.panda-image:hover {
    transform: scale(1.1) rotate(5deg);
}

.diary-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2c3e50;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-width: 44px;
    min-height: 44px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.nav-btn:active {
    transform: scale(0.95);
}

.current-day {
    font-size: 1.2rem;
    color: #2c3e50;
    font-weight: 600;
    min-width: 150px;
    text-align: center;
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.5px;
}

.diary-content {
    flex: 1;
    margin-bottom: 20px;
}

.diary-textarea {
    width: 100%;
    height: 100%;
    min-height: 300px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 20px;
    font-family: 'Cookie', 'Quicksand', 'Bunch Blossoms', 'Comic Neue', 'Varela Round', cursive;
    font-size: 1.4rem;
    font-weight: normal;
    color: #2c3e50;
    resize: none;
    outline: none;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    line-height: 1.6;
    letter-spacing: 0.5px;
    /* Performance optimization */
    will-change: contents;
    contain: layout style;
}

.diary-textarea:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(52, 152, 219, 0.5);
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.2);
}

.diary-textarea::placeholder {
    color: #95a5a6;
    font-style: italic;
}

.diary-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}



.history-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #2c3e50;
    border-radius: 25px;
    padding: 12px 25px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
}

.history-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.history-btn:active {
    transform: translateY(0);
}

.save-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #2c3e50;
    border-radius: 25px;
    padding: 12px 25px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
}

.save-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.save-btn:active {
    transform: translateY(0);
}

/* Page Flip Animation */
.page-flip {
    animation: pageFlip 0.6s ease-in-out;
}

@keyframes pageFlip {
    0% {
        transform: rotateY(0deg);
        opacity: 1;
    }
    50% {
        transform: rotateY(90deg);
        opacity: 0.5;
    }
    100% {
        transform: rotateY(0deg);
        opacity: 1;
    }
}

/* Panda Animation */
.panda-bounce {
    animation: pandaBounce 0.8s ease-in-out;
}

@keyframes pandaBounce {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.2) rotate(-5deg); }
    50% { transform: scale(1.1) rotate(5deg); }
    75% { transform: scale(1.15) rotate(-3deg); }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .container {
        max-width: 100%;
        padding: 15px;
    }
    
    .card h3 {
        font-size: 1.2rem;
    }
    
    .current-time {
        font-size: 2.5rem;
    }
    
    .current-date {
        font-size: 1rem;
    }
}

@media (max-width: 992px) {
    .container {
        flex-direction: column;
        gap: 15px;
    }
    
    .left-column, .right-column {
        gap: 15px;
    }
    
    .left-column {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .photo-album-card, .mood-card {
        flex: 1;
        min-width: 300px;
    }
    
    .diary-card {
        min-height: 500px;
    }
    
    .diary-textarea {
        min-height: 400px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
        gap: 10px;
    }
    
    .left-column {
        flex-direction: column;
    }
    
    /* Reset flex values for mobile to stack properly */
    .photo-album-card, .mood-card {
        flex: 1;
        min-width: auto;
    }
    
    .card {
        padding: 20px;
    }
    
    .card h3 {
        font-size: 1.1rem;
        margin-bottom: 15px;
    }
    
    .photo-preview {
        height: 150px;
    }
    
    .photo-icon {
        font-size: 2.5rem;
    }
    
    .mood-info .current-mood {
        font-size: 1rem;
    }
    
    .mood-info .mood-emoji {
        font-size: 2rem;
    }
    

    
    .diary-navigation {
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .nav-btn {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }
    
    .current-day {
        font-size: 1rem;
        min-width: 120px;
    }
    
    .diary-textarea {
        font-size: 1rem;
        padding: 15px;
        min-height: 300px;
    }
    
    .diary-footer {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .save-btn {
        width: 100%;
        padding: 12px;
        font-size: 1rem;
    }
    

    
    .panda-image {
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 8px;
        gap: 8px;
    }
    
    .card {
        padding: 15px;
        border-radius: 15px;
    }
    
    .card h3 {
        font-size: 1rem;
        margin-bottom: 12px;
    }
    
    .photo-preview {
        height: 120px;
    }
    
    .photo-icon {
        font-size: 2rem;
    }
    
    .music-info h4 {
        font-size: 0.9rem;
    }
    
    .music-info p {
        font-size: 0.8rem;
    }
    

    
    .diary-navigation {
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .nav-btn {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
    
    .current-day {
        font-size: 0.9rem;
        min-width: 100px;
    }
    
    .diary-textarea {
        font-size: 0.9rem;
        padding: 12px;
        min-height: 250px;
        border-radius: 10px;
    }
    
    .diary-footer {
        gap: 12px;
    }
    
    .save-btn {
        padding: 10px;
        font-size: 0.9rem;
        border-radius: 10px;
    }
    

    
    .panda-image {
        width: 40px;
        height: 40px;
    }
    
    .panda-corner {
        top: -8px;
        right: -8px;
    }
}

@media (max-width: 360px) {
    .container {
        padding: 5px;
        gap: 5px;
    }
    
    .card {
        padding: 12px;
        border-radius: 12px;
    }
    
    .card h3 {
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
    
    .photo-preview {
        height: 100px;
    }
    
    .photo-icon {
        font-size: 1.8rem;
    }
    

    
    .diary-navigation {
        gap: 6px;
        margin-bottom: 10px;
    }
    
    .nav-btn {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }
    
    .current-day {
        font-size: 0.8rem;
        min-width: 90px;
    }
    
    .diary-textarea {
        font-size: 0.8rem;
        padding: 10px;
        min-height: 200px;
        border-radius: 8px;
    }
    
    .save-btn {
        padding: 8px;
        font-size: 0.8rem;
        border-radius: 8px;
    }
    

    
    .panda-image {
        width: 35px;
        height: 35px;
    }
    
    .panda-corner {
        top: -6px;
        right: -6px;
    }
}

/* Landscape orientation adjustments for mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        padding: 5px;
        gap: 5px;
    }
    
    .card {
        padding: 10px;
    }
    
    .diary-textarea {
        min-height: 150px;
    }
    
    .current-time {
        font-size: 1.5rem;
    }
    

}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .card {
        border-width: 0.5px;
    }
    

}

/* History Modal Styles */
.history-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.history-modal-content {
    background: rgba(255, 255, 255, 0.95);
    /* Reduced blur for better performance */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    /* Simplified shadow for better performance */
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    animation: slideIn 0.3s ease;
    /* Hardware acceleration */
    transform: translateZ(0);
}

.history-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.1);
}

.history-modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.3rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: #95a5a6;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(149, 165, 166, 0.2);
    color: #7f8c8d;
}

.history-modal-body {
    padding: 20px 25px;
    max-height: 60vh;
    overflow-y: auto;
}

.history-entry {
    padding: 15px;
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.history-entry:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.history-entry-date {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.history-entry-mood {
    font-weight: 500;
    color: #e74c3c;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-style: italic;
}
.history-entry-mood {
    font-weight: 500;
    color: #e74c3c;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-style: italic;
}

.history-entry-content {
    color: #34495e;
    line-height: 1.5;
    font-family: 'Cookie', 'Quicksand', 'Bunch Blossoms', 'Comic Neue', 'Varela Round', cursive;
    font-size: 1.2rem;
    font-weight: normal;
    letter-spacing: 0.3px;
}

.no-entries {
    text-align: center;
    color: #95a5a6;
    font-style: italic;
    padding: 40px 20px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive modal */
@media (max-width: 768px) {
    .history-modal-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .history-modal-header {
        padding: 15px 20px;
    }
    
    .history-modal-header h3 {
        font-size: 1.1rem;
    }
    
    .history-modal-body {
        padding: 15px 20px;
        max-height: 70vh;
    }
    
    .history-entry {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .history-entry-date {
        font-size: 0.8rem;
    }
    
    .history-entry-content {
        font-size: 0.9rem;
    }
    
    .history-entry-mood {
        font-size: 0.8rem;
    }
    
    .emoji-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }
    
    .emoji-btn {
        padding: 10px 6px;
        font-size: 1rem;
        min-width: 35px;
        height: 35px;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    body::before {
        animation: none;
    }
}
