/* ===== RESET ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== BASE BODY (index & gallery) ===== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

/* ===== LOGIN PAGE ===== */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    position: static;
}

body.login-page::before { content: none; }

/* ===== ADMIN PAGE ===== */
body.admin-page {
    position: static;
}

body.admin-page::before { content: none; }

/* ===== HEADER (index & gallery) ===== */
.header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    font-weight: 700;
}

.header p {
    font-size: 1.2em;
    opacity: 0.9;
}

body.gallery-page .header {
    margin-top: 60px;
}

/* Admin header: title left, actions right */
body.admin-page .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto 30px;
    text-align: left;
    text-shadow: none;
}

body.admin-page .header h1 {
    font-size: 2em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 0;
}

.header-actions { display: flex; gap: 10px; }

/* ===== LOADING & ERRORS ===== */
.loading {
    text-align: center;
    color: white;
    font-size: 1.5em;
    padding: 40px;
}

.error-message {
    background: rgba(255,255,255,0.9);
    color: #d32f2f;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    max-width: 600px;
    margin: 40px auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

body.login-page .error-message {
    background: #ffebee;
    color: #c62828;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    max-width: none;
    margin-top: 0;
    box-shadow: none;
    display: none;
}

body.login-page .error-message.show { display: block; }

/* ===== TOP BUTTONS (index) ===== */
.top-buttons {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.logout-button, .admin-button {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid white;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.logout-button:hover, .admin-button:hover {
    background: rgba(255,255,255,0.3);
}

.admin-button {
    background: rgba(255, 165, 0, 0.3);
    border-color: rgba(255, 220, 100, 0.8);
}

.admin-button:hover { background: rgba(255, 165, 0, 0.5); }

/* ===== GALLERIES GRID (index) ===== */
.galleries-container {
    max-width: 1200px;
    margin: 0 auto;
}

.galleries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    padding: 20px;
}

.gallery-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
    color: inherit;
    display: block;
}

.gallery-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

.gallery-card-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4em;
    color: rgba(255,255,255,0.3);
    position: relative;
}

.gallery-card-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.2);
    transition: background 0.3s ease;
}

.gallery-card:hover .gallery-card-image::after {
    background: rgba(0,0,0,0.1);
}

.gallery-card-content {
    padding: 25px;
}

.gallery-card-title {
    font-size: 1.8em;
    font-weight: 700;
    margin-bottom: 10px;
    color: #333;
}

.gallery-card-info {
    font-size: 1em;
    color: #666;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gallery-card-info::before {
    content: '📸';
    font-size: 1.2em;
}

/* ===== GALLERY VIEW ===== */
.back-button {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid white;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s ease;
    text-decoration: none;
    display: inline-block;
    z-index: 100;
}

.back-button:hover { background: rgba(255,255,255,0.3); }

.back-button::before { content: '← '; }

.download-button {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid white;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s ease, opacity 0.3s ease;
    text-decoration: none;
    display: inline-block;
    z-index: 100;
}

.download-button:hover { background: rgba(255,255,255,0.3); }

.download-button::before { content: '⬇ '; }

.download-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.download-button:disabled:hover { background: rgba(255,255,255,0.2); }

.gallery-container {
    max-width: 1400px;
    margin: 0 auto;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px;
    align-items: start;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: white;
    border: 4px solid #d3d3d3;
    margin: 0 auto;
}

.gallery-item.landscape {
    aspect-ratio: 4/3;
    width: 100%;
}

.gallery-item.portrait {
    aspect-ratio: 3/4;
    width: 75%;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.gallery-item:hover img { transform: scale(1.05); }

.gallery-item .overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    padding: 20px;
    color: white;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .overlay { opacity: 1; }

.tooltip {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.85em;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 10;
    max-width: 90%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    line-height: 1.6;
}

.gallery-item:hover .tooltip { opacity: 1; }

.tooltip div { margin: 3px 0; }

.tooltip strong { color: #a0aec0; }

/* ===== LIGHTBOX ===== */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.lightbox.active { display: flex; }

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: grab;
}

.lightbox-content.dragging { cursor: grabbing; }

.lightbox img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 50px rgba(255,255,255,0.1);
    transition: transform 0.3s ease;
    transform-origin: center center;
}

.lightbox img.zoomed { cursor: move; }

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: white;
    cursor: pointer;
    z-index: 1001;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    transition: background 0.3s ease;
}

.lightbox-close:hover { background: rgba(255,255,255,0.2); }

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 40px;
    color: white;
    cursor: pointer;
    padding: 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    user-select: none;
}

.lightbox-nav:hover { background: rgba(255,255,255,0.2); }

.lightbox-prev { left: 30px; }

.lightbox-next { right: 30px; }

.lightbox-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 18px;
    background: rgba(0,0,0,0.5);
    padding: 10px 20px;
    border-radius: 20px;
}

.zoom-controls {
    position: absolute;
    top: 90px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1001;
}

.zoom-btn {
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.1);
    border: 2px solid white;
    color: white;
    font-size: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    user-select: none;
}

.zoom-btn:hover { background: rgba(255,255,255,0.2); }

.zoom-btn:active { background: rgba(255,255,255,0.3); }

.video-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3em;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 2;
}

#lightbox-video {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 8px;
    box-shadow: 0 0 50px rgba(255,255,255,0.1);
}

/* ===== LOGIN ===== */
.login-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    max-width: 400px;
    width: 100%;
}

.login-container h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2em;
}

.btn-login {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-login:active { transform: translateY(0); }

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
    font-size: 0.9em;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-group .hint {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ===== ADMIN BUTTONS ===== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: #667eea; color: white; }
.btn-success { background: #4caf50; color: white; }
.btn-danger  { background: #e53935; color: white; }
.btn-warning { background: #ff9800; color: white; }
.btn-outline {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid white;
}
.btn-outline:hover { background: rgba(255,255,255,0.3); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ===== ADMIN CARD & TABLE ===== */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    max-width: 1000px;
    margin: 0 auto;
    overflow: hidden;
}

.card-header {
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 { color: #333; font-size: 1.3em; }

table { width: 100%; border-collapse: collapse; }

th {
    background: #f5f5f5;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #555;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-admin  { background: #ede7f6; color: #6a1b9a; }
.badge-user   { background: #e3f2fd; color: #1565c0; }
.badge-guest  { background: #f5f5f5; color: #616161; }
.badge-active   { background: #e8f5e9; color: #2e7d32; }
.badge-inactive { background: #ffebee; color: #c62828; }

.gallery-list {
    font-size: 0.85em;
    color: #666;
    max-width: 200px;
}

.actions { display: flex; gap: 6px; }

.empty-row td {
    text-align: center;
    color: #999;
    padding: 40px;
}

/* ===== ADMIN MODALS ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.show { display: flex; }

.modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { color: #333; font-size: 1.2em; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #999;
    line-height: 1;
}
.modal-close:hover { color: #333; }

.modal-body { padding: 25px; }

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.alert {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
    display: none;
}

.alert.show { display: block; }
.alert-error   { background: #ffebee; color: #c62828; }
.alert-success { background: #e8f5e9; color: #2e7d32; }

.confirm-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1100;
}
.confirm-overlay.show { display: flex; }

.confirm-box {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.confirm-box h3 { margin-bottom: 12px; color: #333; }
.confirm-box p { color: #666; margin-bottom: 25px; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }

.gallery-checklist {
    border: 2px solid #ddd;
    border-radius: 8px;
    max-height: 160px;
    overflow-y: auto;
    padding: 6px;
    transition: border-color 0.2s;
}

.gallery-checklist:focus-within { border-color: #667eea; }

.gallery-checklist label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: normal;
    margin: 0;
    font-size: 14px;
    color: #333;
}

.gallery-checklist label:hover { background: #f5f5f5; }

.gallery-checklist input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    padding: 0;
    border: none;
    flex-shrink: 0;
}

.gallery-checklist .cl-empty,
.gallery-checklist .cl-loading {
    color: #999;
    font-size: 13px;
    padding: 10px;
    text-align: center;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .header h1 { font-size: 2em; }

    .galleries-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 10px;
    }

    .top-buttons { top: 10px; right: 10px; }

    .logout-button, .admin-button {
        padding: 8px 14px;
        font-size: 0.85em;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
        padding: 10px;
    }

    .lightbox-nav { width: 50px; height: 50px; font-size: 30px; }
    .lightbox-prev { left: 10px; }
    .lightbox-next { right: 10px; }

    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 30px;
    }

    .back-button { top: 10px; left: 10px; padding: 8px 16px; font-size: 0.9em; }
    .download-button { top: 10px; right: 10px; padding: 8px 16px; font-size: 0.9em; }

    .zoom-controls { top: 60px; right: 10px; }
    .zoom-btn { width: 40px; height: 40px; font-size: 20px; }

    body.admin-page .header { flex-direction: column; gap: 15px; text-align: center; }
    table { font-size: 14px; }
    th, td { padding: 10px 12px; }
    .gallery-list { max-width: 120px; }
}
