/* Загальні стилі */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f9f9f9;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* Хедер */
header {
    text-align: center;
    padding: 20px 0;
    border-bottom: 1px solid #ddd;
    margin-bottom: 30px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
}

header h1 a {
    color: #007cba;
    text-decoration: none;
}

nav {
    margin-top: 10px;
}

nav a {
    margin: 0 10px;
    text-decoration: none;
    color: #555;
    font-weight: 500;
}

nav a:hover {
    color: #007cba;
}

/* Меню на мобільних */
@media (max-width: 600px) {
    nav {
        display: flex;
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
}

/* Основний контент */
main {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

h2, h3 {
    color: #2c3e50;
    margin: 20px 0 10px;
}

a {
    color: #007cba;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

p {
    margin-bottom: 15px;
}

small {
    color: #777;
    font-style: italic;
}

hr {
    border: 1px solid #eee;
    margin: 20px 0;
}

/* Стаття на головній */
article h3 {
    margin-bottom: 10px;
}

article h3 a {
    color: #2c3e50;
}

article h3 a:hover {
    color: #007cba;
}

/* Форми */
input, textarea, button {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

input:focus, textarea:focus {
    outline: none;
    border-color: #007cba;
}

textarea {
    resize: vertical;
}

button {
    background: #007cba;
    color: white;
    cursor: pointer;
    font-weight: bold;
}

button:hover {
    background: #005a87;
}

/* Таблиця в адмінці */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

table th, table td {
    padding: 12px;
    text-align: left;
    border: 1px solid #ddd;
}

table th {
    background: #f4f4f4;
    font-weight: bold;
}

table tr:hover {
    background: #f9f9f9;
}

/* Мобільна версія таблиці */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    main {
        padding: 15px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    table, thead, tbody, th, td, tr {
        display: block;
    }

    th {
        text-align: right;
        background: #f4f4f4;
        padding: 10px;
    }

    td {
        position: relative;
        padding-left: 50% !important;
        text-align: left;
        border: none;
        border-bottom: 1px solid #eee;
    }

    td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        font-weight: bold;
        text-align: left;
    }

    td:nth-child(1)::before { content: "ID"; }
    td:nth-child(2)::before { content: "Заголовок"; }
    td:nth-child(3)::before { content: "Дата"; }
    td:nth-child(4)::before { content: "Дії"; }
}

/* Футер */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px 0;
    color: #777;
    font-size: 0.9rem;
    border-top: 1px solid #eee;
}

/* === Сторінка входу === */
body.login-page {
    background: #f0f2f5;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.login-container {
    max-width: 400px;
    margin: 60px auto;
    padding: 30px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.login-container h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.5rem;
}

/* Повідомлення про помилку */
.error-message {
    background: #fee;
    color: #c33;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #fcc;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

/* Форма входу */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #444;
}

.form-group input {
    width: 100%;
    padding: 10px;
    font-size: 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
}

.form-group input:focus {
    border-color: #007cba;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

/* Кнопка */
.btn {
    padding: 12px;
    background: #007cba;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn:hover {
    background: #005a87;
}

/* Посилання "Назад" */
.back-link {
    margin-top: 20px;
    font-size: 0.95rem;
}

.back-link a {
    color: #666;
    text-decoration: none;
}

.back-link a:hover {
    color: #007cba;
    text-decoration: underline;
}

/* Адаптивність */
@media (max-width: 480px) {
    .login-container {
        margin: 20px;
        padding: 20px;
    }

    .btn {
        padding: 10px;
    }
}



/* === Темна тема === */
body {
    transition: background 0.3s, color 0.3s;
}

body.dark-theme {
    background: #1a1a1a;
    color: #e0e0e0;
}

body.dark-theme header,
body.dark-theme main {
    background: #242424;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

body.dark-theme h1, 
body.dark-theme h2, 
body.dark-theme h3 {
    color: #ffffff;
}

body.dark-theme a {
    color: #6ec1e4;
}

body.dark-theme a:hover {
    color: #a0d8f1;
}

body.dark-theme input,
body.dark-theme textarea {
    background: #333;
    color: #e0e0e0;
    border-color: #555;
}

body.dark-theme ::placeholder {
    color: #aaa;
}

body.dark-theme footer {
    color: #aaa;
    border-top-color: #444;
}

/* Перемикач теми — відцентровано по вертикалі */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 15px;
    height: 24px; /* Відповідає висоті лінії меню */
}

.theme-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-toggle label {
    display: block;
    width: 50px;
    height: 26px;
    background: #ccc;
    border-radius: 13px;
    cursor: pointer;
    position: relative;
    transition: background 0.3s;
    margin: 0;
    padding: 0;
}

.theme-toggle label::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Темна тема — перемикач увімкнено */
body.dark-theme .theme-toggle label {
    background: #007cba;
}

body.dark-theme .theme-toggle label::before {
    transform: translateX(24px);
}

/* Іконки на перемикачі (сонце/місяць) */
.theme-toggle label::after {
    content: '☀️';
    position: absolute;
    top: 2px;
    right: 6px;
    font-size: 14px;
    opacity: 1;
}

body.dark-theme .theme-toggle label::after {
    content: '🌙';
    left: 8px;
    right: auto;
}

body.dark-theme .theme-toggle label {
    background: #007cba;
}

body.dark-theme .theme-toggle label::before {
    transform: translateX(24px);
}


/* === Сторінка повідомлень === */
.message-card {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body.dark-theme .message-card {
    background: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
}

.message-header {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.message-header strong {
    font-size: 1.1rem;
    color: #007cba;
}

body.dark-theme .message-header strong {
    color: #6ec1e4;
}

.message-header a {
    color: #555;
    text-decoration: underline;
}

body.dark-theme .message-header a {
    color: #aaa;
}

.date {
    margin-left: auto;
    font-style: italic;
    color: #777;
    font-size: 0.9rem;
}

body.dark-theme .date {
    color: #999;
}

.message-content {
    line-height: 1.7;
    white-space: pre-wrap;
    background: white;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #eee;
    font-family: 'Segoe UI', sans-serif;
    font-size: 0.95rem;
}

body.dark-theme .message-content {
    background: #333;
    border-color: #555;
    color: #e0e0e0;
}

.message-actions {
    text-align: right;
    margin-top: 10px;
}

.btn-delete {
    display: inline-block;
    padding: 6px 12px;
    background: #e74c3c;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.btn-delete:hover {
    background: #c0392b;
}