/* Base Styling - Heritage Theme */
:root {
    --bg-color: #f7f5f0; /* Warm cream */
    --text-color: #2b302c; /* Deep forest slate */
    --primary-color: #2e4a3d; /* Deep forest green */
    --primary-dark: #1b3026;
    --accent-color: #c79e65; /* Warm gold/sepia accent */
    --card-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(200, 180, 150, 0.4);
    --shadow: 0 10px 40px rgba(46, 74, 61, 0.08);
}

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

body {
    font-family: 'Lora', serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    background-image: 
        radial-gradient(at 0% 0%, rgba(199, 158, 101, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(46, 74, 61, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
}

h1, h2, h3 {
    font-family: 'Cinzel', serif;
    font-weight: 600;
}

/* Glassmorphism Utilities */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
}

/* --- Login Page --- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    padding: 3.5rem 4rem;
    border-radius: 8px; /* Sharper corners for a classic look */
    text-align: center;
    max-width: 450px;
    width: 100%;
    animation: fadeIn 0.8s ease-out;
}

.login-card h1 {
    font-size: 2.2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}

.login-card .subtitle {
    font-size: 1rem;
    color: #555;
    margin-bottom: 2.5rem;
    font-style: italic;
}

.error-message {
    color: #8c2a2a;
    background: rgba(140, 42, 42, 0.1);
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d4c8b8;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(199, 158, 101, 0.2);
}

.btn {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1.1rem;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(46, 74, 61, 0.3);
}

/* --- Gallery Page --- */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 5%;
    background: rgba(247, 245, 240, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-content h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.2rem;
}

.header-content p {
    font-size: 0.95rem;
    color: #666;
    font-style: italic;
}

.logout-btn {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
    font-family: 'Cinzel', serif;
    padding: 8px 16px;
    border: 1px solid var(--accent-color);
    border-radius: 4px;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: var(--accent-color);
    color: #fff;
}

.gallery-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 5%;
}

.folder-section {
    margin-bottom: 4rem;
    animation: fadeIn 0.8s ease-out;
}

.folder-title {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-color);
    display: inline-block;
    color: var(--primary-color);
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.photo-card {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 4 / 3; /* Classic photo aspect ratio */
    background: #e8e4db;
    box-shadow: var(--shadow);
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow 0.4s ease;
    border: 6px solid #fff; /* Polaroid/Classic border effect */
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
    filter: sepia(0.2); /* Slight vintage tint */
}

.photo-overlay {
    position: absolute;
    inset: 0;
    background: rgba(46, 74, 61, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.photo-overlay span {
    color: white;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 1.2rem;
    padding: 10px 20px;
    border: 1px solid white;
    transform: translateY(20px);
    transition: transform 0.4s ease;
}

.photo-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

.photo-card:hover img {
    transform: scale(1.05);
    filter: sepia(0); /* Remove tint on hover */
}

.photo-card:hover .photo-overlay {
    opacity: 1;
}

.photo-card:hover .photo-overlay span {
    transform: translateY(0);
}

.empty-state {
    text-align: center;
    padding: 5rem 0;
    color: #666;
    font-size: 1.2rem;
    font-style: italic;
}

/* --- Lightbox --- */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(27, 48, 38, 0.95);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox-content-wrapper {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.lightbox-content {
    max-width: 100%;
    max-height: 90vh;
    border: 10px solid #fff;
    border-radius: 2px;
    box-shadow: 0 0 40px rgba(0,0,0,0.8);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.lightbox.active .lightbox-content {
    transform: scale(1);
}

.close-lightbox {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 1001;
}

.close-lightbox:hover {
    color: var(--accent-color);
}

/* --- Album List View --- */
.album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    animation: fadeIn 0.8s ease-out;
}

.album-card {
    display: flex;
    flex-direction: column;
    height: 100%; /* Ensures standard size across grid rows */
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow 0.4s ease;
    position: relative;
    z-index: 1;
}

.album-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(46, 74, 61, 0.2);
    z-index: 2; /* Bring to front on hover */
}

.album-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    padding: 10px 10px 0 10px; /* Elegant white frame scaled down */
    background: #fff;
    border-radius: 8px 8px 0 0;
}

/* Elegant photo stack effect */
.album-cover::before,
.album-cover::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 0;
    background: #fbfbfb;
    border: 1px solid #eaeaea;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: -1;
    transition: transform 0.4s ease;
}

.album-cover::before {
    transform: rotate(-3deg);
}

.album-cover::after {
    transform: rotate(3deg);
}

.album-card:hover .album-cover::before {
    transform: rotate(-5deg) translate(-2px, 2px);
}

.album-card:hover .album-cover::after {
    transform: rotate(5deg) translate(2px, 2px);
}

.album-cover-img-wrapper {
    width: 100%;
    height: 100%;
    overflow: hidden; /* Contains the zoom effect inside the frame */
    position: relative;
}

.album-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.8s ease, filter 0.6s ease;
    filter: sepia(0.2) contrast(1.05); /* Vintage elegant tint */
}

.album-card:hover .album-cover img {
    transform: scale(1.08);
    filter: sepia(0) contrast(1.1); /* Reveal true colors on hover */
}

.album-info {
    flex-grow: 1; /* Pushes card to standard uniform height */
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 16px 12px;
    text-align: center;
    background: #fff;
    border-radius: 0 0 8px 8px;
    position: relative;
}

.album-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
    opacity: 0.5;
}

.album-info h3 {
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.album-info p {
    font-size: 0.85rem;
    color: #888;
    font-style: italic;
    font-family: 'Cinzel', serif; /* Matching the elegant font */
}

.back-btn {
    display: inline-block;
    padding: 8px 16px;
    color: var(--primary-color);
    text-decoration: none;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: var(--primary-color);
    color: #fff;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Chat Styling --- */
.chat-wrapper {
    max-width: 800px;
    margin: 0 auto;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 600px; /* fixed height for scrollable chat */
    animation: fadeIn 0.8s ease-out;
}

.chat-header {
    background: var(--primary-color);
    color: #fff;
    padding: 15px 20px;
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    letter-spacing: 1px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-message {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    align-self: flex-start;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.chat-message.self {
    align-self: flex-end;
    background: rgba(199, 158, 101, 0.2); /* var(--accent-color) mixed with white */
    border-bottom-right-radius: 4px;
}

.chat-message:not(.self) {
    border-bottom-left-radius: 4px;
}

.chat-meta {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-style: italic;
}

.chat-author {
    font-weight: 600;
    color: var(--primary-color);
    font-style: normal;
}

.chat-text {
    font-size: 0.95rem;
    line-height: 1.4;
    word-break: break-word;
}

.chat-input-area {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.8);
    border-top: 1px solid var(--glass-border);
}

.chat-form {
    display: flex;
    gap: 10px;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d4c8b8;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.chat-input:focus {
    border-color: var(--accent-color);
}

.chat-submit {
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0 20px;
    font-weight: 600;
    font-family: 'Cinzel', serif;
    cursor: pointer;
    transition: background 0.3s;
    letter-spacing: 0.5px;
}

.chat-submit:hover {
    background: var(--primary-dark);
}

/* Responsive */
@media (max-width: 768px) {
    .login-card {
        padding: 2rem;
    }
    .gallery-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    .folder-title {
        font-size: 1.5rem;
    }
    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    .album-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
    .album-info {
        padding: 10px 8px;
    }
    .album-info h3 {
        font-size: 1rem;
    }
    .album-info p {
        font-size: 0.75rem;
    }
    .chat-wrapper {
        height: 500px;
    }
    .chat-message {
        max-width: 90%;
    }
}
