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

:root {
    --primary-color: #00497a;
    --primary-dark: #106ebe;
    --success-color: #107c10;
    --error-color: #d13438;
    --warning-color: #ffb900;
    --light-gray: #f3f2f1;
    --border-color: #d2d0ce;
    --text-color: #323130;
    --text-light: #605e5c;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    color: var(--text-color);
}

/* ===== SHARED COMPONENTS ===== */

.container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 100%;
    padding: 32px;
}

.header {
    text-align: center;
    margin-bottom: 32px;
}

.header h1 {
    font-size: 28px;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.header p {
    color: var(--text-light);
    font-size: 14px;
}

button {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--light-gray);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background-color: #efe6e1;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert.show {
    display: block;
}

.alert-success {
    background-color: #d4edda;
    border-left: 4px solid var(--success-color);
    color: #155724;
}

.alert-error {
    background-color: #f8d7da;
    border-left: 4px solid var(--error-color);
    color: #721c24;
}

.empty-state {
    text-align: center;
    padding: 24px;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 32px;
}

/* ===== INDEX/UPLOAD PAGE ===== */

.upload-page {
    background: #00a9eb;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.logo-container {
    width: 100%;
    max-width: 500px;
    margin-bottom: 16px;
}

.logo {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery-link-container {
    text-align: center;
    padding: 24px 0;
    margin-top: 16px;
    border-top: 1px solid var(--border-color);
}

.gallery-link {
    color: var(--text-light);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

.gallery-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
    font-size: 14px;
}

input[type="text"],
input[type="email"],
textarea,
input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus,
input[type="file"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.form-group {
    margin-bottom: 20px;
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: block;
}

input[type="file"] {
    cursor: pointer;
    padding: 0;
}

.file-input-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: var(--light-gray);
    border: 2px dashed var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s;
    text-align: center;
}

.file-input-label:hover {
    background-color: #f9f8f7;
    border-color: var(--primary-color);
}

.file-input-label.dragover {
    background-color: rgba(0, 120, 212, 0.1);
    border-color: var(--primary-color);
}

.file-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.file-label-text {
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
}

.file-label-hint {
    color: var(--text-light);
    font-size: 12px;
    margin-top: 4px;
}

.selected-file {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f0f6ff;
    border-left: 3px solid var(--primary-color);
    border-radius: 2px;
    font-size: 12px;
    color: var(--text-color);
    display: none;
}

.selected-file.show {
    display: block;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background-color: var(--light-gray);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 12px;
    display: none;
}

.progress-bar.show {
    display: block;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

.uploads-section {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
}

.uploads-section h2 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--text-color);
}

.uploads-list {
    display: grid;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.upload-item {
    padding: 12px;
    background: var(--light-gray);
    border-radius: 4px;
    font-size: 13px;
    border-left: 3px solid var(--primary-color);
}

.upload-item-name {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 4px;
}

.upload-item-desc {
    color: var(--text-light);
    margin-bottom: 4px;
}

.upload-item-time {
    color: #999;
    font-size: 12px;
}

/* ===== GALLERY PAGE ===== */

.gallery-page {
    background: #0086c4;
    min-height: 100vh;
    padding: 16px;
    color: var(--text-color);
}

.gallery-page .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

.gallery-header {
    background: white;
    padding: 24px;
    border-radius: 8px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.gallery-header h1 {
    font-size: 28px;
    color: var(--primary-color);
}

.header-actions {
    display: flex;
    gap: 12px;
}

a.btn {
    display: inline-flex;
    align-items: center;
    padding: 10px 20px;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    transition: background-color 0.3s;
    border: none;
    cursor: pointer;
}

a.btn:hover {
    background-color: var(--primary-dark);
}

a.btn-secondary {
    background-color: var(--light-gray);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

a.btn-secondary:hover {
    background-color: #efe6e1;
}

.gallery-container {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.photo-card {
    background: var(--light-gray);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    position: relative;
}

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

.photo-card.is-video .photo-image {
    cursor: default;
}

.video-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    pointer-events: none;
}

.photo-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--border-color);
    display: block;
    cursor: pointer;
}

.photo-metadata {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.photo-uploader {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-description {
    color: var(--text-light);
    font-size: 13px;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
    line-height: 1.4;
}

.photo-date {
    color: #999;
    font-size: 12px;
    margin-bottom: 12px;
}

.photo-actions {
    display: flex;
    gap: 8px;
}

.photo-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.download-photo {
    background-color: var(--primary-color);
    color: white;
}

.download-photo:hover {
    background-color: var(--primary-dark);
}

.download-metadata {
    background-color: #e7eef7;
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

.download-metadata:hover {
    background-color: #d4e4f0;
}

.loading {
    display: none;
    text-align: center;
    padding: 32px;
    color: var(--text-light);
}

.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state-text {
    font-size: 16px;
    margin-bottom: 24px;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.pagination button {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background-color: white;
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background-color 0.3s, border-color 0.3s;
}

.pagination button:hover:not(:disabled) {
    background-color: var(--light-gray);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination-info {
    color: var(--text-light);
    font-size: 14px;
    text-align: center;
    flex: 1 0 100%;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease-out;
}

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

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    position: relative;
    animation: slideIn 0.3s ease-out;
}

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

.modal-image {
    width: 100%;
    height: auto;
    display: block;
    max-height: 85vh;
    object-fit: contain;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.modal-close:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

#alertContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999;
}

/* ===== ERROR PAGES ===== */

.error-page {
    background: #0086c4;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.error-page.access-denied {
    background: #0086c4;
}

.error-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 100%;
    padding: 48px 32px;
    text-align: center;
}

.error-icon {
    font-size: 64px;
    margin-bottom: 24px;
}

.error-container h1 {
    font-size: 28px;
    color: #d13438;
    margin-bottom: 16px;
}

.error-container p {
    color: #605e5c;
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 32px;
}

.required-group {
    background: #f3f2f1;
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 24px;
    font-family: 'Courier New', monospace;
    color: #323130;
}

.error-details {
    background: #fef8f8;
    border-left: 4px solid #d13438;
    padding: 16px;
    text-align: left;
    margin-bottom: 24px;
    border-radius: 4px;
}

.error-code {
    font-weight: 600;
    color: #323130;
    margin-bottom: 8px;
}

.error-description {
    color: #605e5c;
    font-size: 14px;
}

.error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.error-actions a {
    display: inline-block;
    padding: 12px 24px;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    transition: background-color 0.3s;
}

.error-actions a.btn-primary {
    background-color: #00497a;
    color: white;
}

.error-actions a.btn-primary:hover {
    background-color: var(--primary-dark);
}

.error-actions a.btn-secondary {
    background-color: #f3f2f1;
    color: #323130;
    border: 1px solid #d2d0ce;
}

.error-actions a.btn-secondary:hover {
    background-color: #e1dfdd;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 16px;
    }

    .gallery-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions a {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .upload-page,
    .gallery-page,
    .error-page {
        padding: 8px;
    }

    .container,
    .gallery-container,
    .error-container {
        border-radius: 0;
        padding: 16px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .photo-metadata {
        padding: 12px;
    }

    .photo-uploader {
        font-size: 13px;
    }

    .photo-description {
        font-size: 12px;
    }

    .photo-date {
        font-size: 11px;
    }

    .photo-btn {
        padding: 6px 8px;
        font-size: 11px;
    }

    .header h1 {
        font-size: 24px;
    }

    .form-actions {
        flex-direction: column;
    }

    button {
        width: 100%;
    }
}
