/* style.css */
:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-main: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #bb86fc; /* М'який фіолетовий акцент */
    --accent-hover: #9965f4;
    --danger: #cf6679;
    --border-radius: 12px;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* Header */
.site-header {
    background-color: rgba(30, 30, 30, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid #333;
    padding: 15px 0;
}

.header-content {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--accent);
    letter-spacing: 1px;
}

.sort-menu a {
    color: var(--text-secondary);
    text-decoration: none;
    margin-left: 15px;
    font-size: 0.9rem;
    transition: 0.3s;
}

.sort-menu a.active, .sort-menu a:hover {
    color: var(--text-main);
}

/* Layout */
.container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
}

/* Form Section */
.upload-section {
    background-color: var(--card-bg);
    padding: 25px;
    border-radius: var(--border-radius);
    margin-bottom: 40px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.upload-section h3 {
    margin-top: 0;
    font-weight: 500;
    margin-bottom: 20px;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.input-group {
    display: flex;
    gap: 10px;
}

input[type="text"], textarea {
    background: #2c2c2c;
    border: 1px solid #444;
    color: white;
    padding: 12px;
    border-radius: 8px;
    font-family: inherit;
    width: 100%;
}

input[type="text"]:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Custom File Upload */
.input-file {
    display: none;
}
.file-label {
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: 0.3s;
}
.file-label:hover { background: #444; }

.btn-primary {
    background-color: var(--accent);
    color: #121212;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 10px;
}
.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.photo-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.photo-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.card-image img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
}

.card-content {
    padding: 15px;
}

.card-content h4 {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
}

.card-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #333;
    padding-top: 10px;
    font-size: 0.8rem;
    color: #666;
}

.card-actions a {
    text-decoration: none;
    margin-left: 10px;
    font-size: 1.1rem;
    transition: 0.2s;
}

.icon-btn.edit { color: #aaa; }
.icon-btn.edit:hover { color: white; }
.icon-btn.delete { color: var(--danger); opacity: 0.7; }
.icon-btn.delete:hover { opacity: 1; }

/* Footer */
.site-footer {
    text-align: center;
    padding: 40px 0;
    color: #555;
    font-size: 0.9rem;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Нові стилі для кнопок дій --- */

.card-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* Кнопка Редагувати (Фіолетова тема) */
.btn-edit {
    background-color: transparent;
    border: 1px solid #444;
    color: #aaa;
}

.btn-edit:hover {
    border-color: var(--accent);
    color: var(--accent); /* Фіолетовий текст */
    background-color: rgba(187, 134, 252, 0.1); /* Легкий фон */
    box-shadow: 0 0 10px rgba(187, 134, 252, 0.2);
}

/* Кнопка Видалити (Червона тема) */
.btn-delete {
    background-color: transparent;
    border: 1px solid #444;
    color: #aaa;
}

.btn-delete:hover {
    border-color: var(--danger);
    color: var(--danger); /* Червоний текст */
    background-color: rgba(207, 102, 121, 0.1);
    box-shadow: 0 0 10px rgba(207, 102, 121, 0.2);
}
/* --- Стилі для view.php (Сторінка перегляду) --- */

.view-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--card-bg);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.back-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    display: inline-block;
    margin-bottom: 20px;
}
.back-link:hover { text-decoration: underline; }

.photo-full img {
    width: 100%;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.photo-details { margin-top: 20px; }
.photo-details h2 { margin-bottom: 5px; color: white; }
.divider { border: 0; border-top: 1px solid #333; margin: 30px 0; }

/* Коментарі */
.comment-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 30px;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.comment-item {
    display: flex;
    gap: 15px;
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 10px;
}

.comment-avatar {
    font-size: 24px;
    background: #333;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.comment-body strong { color: var(--accent); display: inline-block; margin-right: 10px; }
.comment-date { font-size: 0.8rem; color: #666; }
.comment-body p { margin: 5px 0 0 0; color: #ddd; }
.no-comments { color: #666; font-style: italic; text-align: center; }

/* --- Стилі для прев'ю завантаження --- */

.file-label {
    /* Оновлюємо існуючий стиль */
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px; /* Трохи зменшимо падінги */
    height: 45px; /* Фіксована висота для краси */
    box-sizing: border-box;
}

#image-preview {
    height: 100%; /* На всю висоту кнопки */
    width: auto;
    border-radius: 4px;
    display: none; /* Ховаємо за замовчуванням */
    border: 1px solid var(--accent);
}

/* Коли картинка показана, ховаємо текст "Вибрати файл" */
.file-label.has-image #label-text {
    display: none;
}
.card-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    
    /* Додаємо це, щоб текст не вилазив за рамки */
    word-wrap: break-word; 
    overflow-wrap: break-word;
}
/* --- Фікс для довгих слів (щоб текст не вилазив) --- */

.card-content h4, 
.card-content p, 
.photo-details h2, 
.photo-details p,
.comment-body p {
    /* Магія, яка ламає довгі слова */
    overflow-wrap: break-word;
    word-wrap: break-word; 
    word-break: break-word;
    
    /* Страховка для різних браузерів */
    hyphens: auto;
    white-space: normal; 
    max-width: 100%;
}
/* --- ГЛОБАЛЬНИЙ ЧАТ --- */

/* Плаваюча кнопка */
.chat-float-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--accent);
    color: #121212;
    border: none;
    padding: 15px 25px;
    border-radius: 50px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(187, 134, 252, 0.4);
    z-index: 999;
    transition: transform 0.3s;
}

.chat-float-btn:hover {
    transform: scale(1.05);
}

/* Висувна панель */
.chat-sidebar {
    position: fixed;
    top: 0;
    right: -350px; /* Схована за екраном */
    width: 320px;
    height: 100%;
    background-color: #1e1e1e;
    box-shadow: -5px 0 20px rgba(0,0,0,0.5);
    z-index: 1000;
    transition: right 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Гарна анімація */
    display: flex;
    flex-direction: column;
    border-left: 1px solid #333;
}

.chat-sidebar.open {
    right: 0; /* Виїжджає */
}

/* Шапка чату */
.chat-header {
    padding: 15px;
    background: #252525;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 { margin: 0; font-size: 1.1rem; color: var(--accent); }
.chat-close { background: none; border: none; color: #fff; font-size: 1.2rem; cursor: pointer; }

/* Область повідомлень */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Одне повідомлення */
.chat-msg {
    background: #2c2c2c;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    animation: fadeIn 0.3s;
}

.msg-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: 4px;
    color: #888;
}

.msg-author { color: var(--accent); font-weight: bold; }
.msg-text { word-wrap: break-word; }

/* Форма внизу */
.chat-form {
    padding: 15px;
    background: #252525;
    border-top: 1px solid #333;
}

.chat-input-sm {
    width: 100%;
    margin-bottom: 8px;
    padding: 8px;
    background: #121212;
    border: 1px solid #444;
    color: white;
    border-radius: 4px;
    font-size: 0.85rem;
}

.chat-input-group {
    display: flex;
    gap: 5px;
}

.chat-input-group input {
    flex: 1;
    padding: 10px;
    background: #121212;
    border: 1px solid #444;
    color: white;
    border-radius: 4px;
}

.chat-input-group button {
    background: var(--accent);
    border: none;
    color: #121212;
    padding: 0 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}