/* --- General & Variables --- */
:root {
    --bg-color: #F8F9FA;
    --text-color: #212529;
    --text-color-light: #6c757d;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-bg-solid: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(255, 255, 255, 0.9);
    --primary-color: #6a11cb;
    --secondary-color: #2575fc;
    --gradient: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --border-radius: 12px;
    font-family: 'Poppins', sans-serif;
}

body.dark-mode {
    --bg-color: #121212;
    --text-color: #E0E0E0;
    --text-color-light: #adb5bd;
    --glass-bg: rgba(30, 30, 30, 0.65);
    --glass-bg-solid: rgba(40, 40, 40, 0.9);
    --glass-border: rgba(255, 255, 255, 0.1);
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    transition: background-color 0.3s, color 0.3s;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: -1;
    background-image: radial-gradient(circle at 10% 20%, rgba(37, 117, 252, 0.2), transparent 40%), radial-gradient(circle at 80% 90%, rgba(106, 17, 203, 0.2), transparent 40%);
    background-size: 200% 200%;
    animation: moveGradient 20s ease-in-out infinite alternate;
}

@keyframes moveGradient {
    0% { background-position: 0% 0%; }
    100% { background-position: 100% 100%; }
}

.hidden { display: none !important; }

/* --- Authentication Section --- */
#auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}
.auth-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.auth-card h2 { margin-top: 0; font-weight: 600; }
.auth-card p { color: var(--text-color-light); margin-bottom: 30px; }
.auth-card input, .auth-card select {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 15px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--text-color);
    box-sizing: border-box;
    font-size: 15px;
}
.auth-card input::placeholder { color: var(--text-color-light); }
.auth-card button {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    background: var(--gradient);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.auth-card button:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.form-switcher { margin-top: 20px; font-size: 14px; }
.form-switcher a { color: var(--primary-color); text-decoration: none; font-weight: 500; }

/* --- Main App Container --- */
header {
    position: sticky;
    top: 15px;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    max-width: 1400px;
    margin: 15px auto;
    box-sizing: border-box;
}
.logo {
    font-size: 24px;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.header-controls { display: flex; align-items: center; gap: 20px; position: relative; }
.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    overflow: hidden;
}
.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.profile-avatar span {
    font-size: 20px;
    line-height: 1;
}
.profile-dropdown {
    position: absolute;
    top: 55px;
    right: 0;
    background: var(--glass-bg-solid);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    width: 180px;
    z-index: 101;
}
.profile-dropdown ul { list-style: none; margin: 0; padding: 5px 0; }
.profile-dropdown li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s;
}
.profile-dropdown li a:hover { background-color: rgba(0,0,0,0.05); }
body.dark-mode .profile-dropdown li a:hover { background-color: rgba(255,255,255,0.05); }

main {
    padding: 20px 30px;
    max-width: 1400px;
    margin: 0 auto 15px;
    box-sizing: border-box;
}
.main-content-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.main-content-header h2 { margin: 0; }

/* --- Gallery Section --- */
#thumbnail-grid {
    display: grid;
    /* UPDATED: This is now the single source of truth for the grid layout.
       It creates as many columns as can fit, with a minimum size for each.
       This is fully responsive to both resizing and zooming. */
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
}

/* REMOVED: The rigid media query is no longer needed, simplifying the code. */

.thumbnail-card {
    position: relative;
    aspect-ratio: 16 / 9;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-radius: var(--border-radius);
}
.thumbnail-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(31, 38, 135, 0.2);
}
.thumbnail-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--border-radius);
}
.thumbnail-card .menu-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.4);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    transition: background-color 0.2s;
    z-index: 11;
}
.thumbnail-card .menu-btn:hover { background: rgba(0, 0, 0, 0.6); }
.thumbnail-card .menu-dropdown {
    position: absolute;
    top: 50px;
    right: 10px;
    background: var(--glass-bg-solid);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 10;
    width: 160px;
}
.thumbnail-card .menu-dropdown ul { list-style: none; padding: 5px 0; margin: 0; }
.thumbnail-card .menu-dropdown li {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}
body.dark-mode .thumbnail-card .menu-dropdown li:hover { background-color: rgba(255,255,255,0.05); }
body:not(.dark-mode) .thumbnail-card .menu-dropdown li:hover { background-color: rgba(0,0,0,0.05); }

/* --- Modals --- */
#modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    z-index: 1000;
}
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    z-index: 1001;
    width: 90%;
    max-width: 450px;
}
.modal h3 { margin-top: 0; }
.modal p { color: var(--text-color-light); }
.modal input, .modal select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    margin-top: 10px;
    box-sizing: border-box;
    background-color: rgba(255,255,255,0.2);
    color: var(--text-color);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal button { padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer; font-weight: 500; transition: transform 0.2s; }
.modal button:hover { transform: translateY(-2px); }

/* --- Button Styling --- */
.btn-primary {
    background: var(--gradient);
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
}
.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
.btn-secondary {
    background-color: var(--glass-border);
    color: var(--text-color);
    border: 1px solid var(--glass-border);
}
body.dark-mode .btn-secondary { background-color: transparent; }

/* --- Notification --- */
#notification {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 25px;
    border-radius: 25px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 2000;
    transition: bottom 0.5s ease-in-out;
}
#notification.show { bottom: 30px; }

/* --- Theme Switch --- */
.theme-switch-wrapper { display: flex; align-items: center; }
.theme-switch { position: relative; display: inline-block; width: 50px; height: 26px; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background: var(--primary-color); }
input:checked + .slider:before { transform: translateX(24px); }

/* --- Settings Modal Styles --- */
#settings-modal { max-width: 500px; }
#close-settings-modal-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-color-light);
    cursor: pointer;
}
.settings-modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 20px;
}
.settings-tab {
    padding: 10px 20px;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text-color-light);
    font-size: 15px;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}
.settings-tab:hover { color: var(--text-color); }
.settings-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 500;
}
.settings-tab-content { display: none; }
.settings-tab-content.active { display: block; }
.avatar-preview-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}
.avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--gradient);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
}
.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
#password-form .modal-actions, #security-form .modal-actions {
    justify-content: flex-start;
}