/* ===== БАЗОВЫЕ СБРОСЫ ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f8f9fa;
    color: #212529;
    line-height: 1.6;
    padding: 20px 15px;
}

a {
    color: #007bff;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

h1, h2, h3 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* ===== КОНТЕЙНЕР ===== */
.container {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* ===== ШАПКА ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}
.header h1 {
    font-size: 1.8rem;
    margin: 0;
}
.header .menu {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 15px;
    font-size: 0.95rem;
}
.header .menu a {
    color: #495057;
}
.header .menu a:hover {
    color: #007bff;
    text-decoration: none;
}

/* ===== ФОРМЫ ===== */
.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 5px;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-group textarea {
    min-height: 120px;
    resize: vertical;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25);
}
select[multiple] {
    height: auto;
    min-height: 100px;
}

/* ===== КНОПКИ ===== */
button, .btn {
    display: inline-block;
    font-weight: 500;
    text-align: center;
    vertical-align: middle;
    padding: 10px 20px;
    font-size: 1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    background: #007bff;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}
button:hover, .btn:hover {
    background: #0069d9;
    text-decoration: none;
}
.btn-danger {
    background: #dc3545;
}
.btn-danger:hover {
    background: #c82333;
}
.btn-sm {
    padding: 5px 12px;
    font-size: 0.875rem;
}

/* ===== СООБЩЕНИЯ ===== */
.msg {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}
.msg-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}
.msg-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* ===== ЗАПИСИ (ЛЕНТА) ===== */
.post {
    border-bottom: 1px solid #e9ecef;
    padding: 20px 0;
}
.post:last-child {
    border-bottom: none;
}
.post-meta {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 8px;
}
.post-content {
    white-space: pre-wrap;
    word-break: break-word;
}
.post-tags {
    margin: 8px 0 12px;
}
.post-tags a {
    display: inline-block;
    background: #e9ecef;
    padding: 2px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: #495057;
    margin: 2px 4px 2px 0;
}
.post-tags a:hover {
    background: #dee2e6;
    text-decoration: none;
}
.attachments {
    margin: 12px 0;
}
.attachments a {
    display: inline-block;
    background: #f1f3f5;
    padding: 4px 12px;
    border-radius: 6px;
    margin: 2px 8px 2px 0;
    font-size: 0.9rem;
}
.attachments img {
    max-width: 100px;
    max-height: 100px;
    vertical-align: middle;
    border-radius: 4px;
}
.delete-link {
    color: #dc3545;
    font-size: 0.85rem;
    margin-left: 12px;
}

/* ===== ПОИСК И ТЕГИ ===== */
.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
}
.search-form input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 1rem;
}
.search-form button {
    padding: 10px 24px;
}
.clear-filter {
    display: inline-block;
    padding: 10px 16px;
}
.tag-cloud {
    margin: 15px 0;
}
.tag-cloud a {
    display: inline-block;
    margin: 4px 8px 4px 0;
    padding: 4px 12px;
    background: #e9ecef;
    border-radius: 20px;
    font-size: 0.9rem;
}
.tag-cloud a.active {
    background: #007bff;
    color: #fff;
}
.tag-cloud a:hover {
    text-decoration: none;
    background: #dee2e6;
}
.tag-cloud a.active:hover {
    background: #0069d9;
}

/* ===== КАЛЕНДАРЬ ===== */
.calendar {
    margin: 20px 0;
}
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2rem;
    padding: 10px 0;
}
.calendar-header a {
    font-size: 1.8rem;
    font-weight: 300;
    padding: 0 10px;
    color: #495057;
}
.calendar-header a:hover {
    color: #007bff;
    text-decoration: none;
}
.calendar-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.calendar-table th,
.calendar-table td {
    text-align: center;
    padding: 6px 0;
    border: 1px solid #dee2e6;
    font-size: 0.95rem;
}
.calendar-table td a {
    display: block;
    padding: 6px 0;
    border-radius: 50%;
    color: #212529;
}
.calendar-table td a:hover {
    background: #f1f3f5;
    text-decoration: none;
}
.calendar-table td.today a {
    background: #e2f0ff;
    font-weight: 700;
}
.calendar-table td.has-plan a {
    background: #d4edda;
}
.calendar-table td.selected a {
    background: #007bff;
    color: #fff;
}

/* ===== ПЛАНЫ (список) ===== */
.plans-section {
    margin-top: 30px;
}
.plan-item {
    border-bottom: 1px solid #e9ecef;
    padding: 12px 0;
}
.plan-item:last-child {
    border-bottom: none;
}
.plan-item .title {
    font-weight: 600;
    font-size: 1.05rem;
}
.plan-item .desc {
    color: #6c757d;
    margin: 4px 0;
}

/* ===== ПАГИНАЦИЯ ===== */
.pagination {
    text-align: center;
    margin: 25px 0 10px;
}
.pagination a,
.pagination span {
    display: inline-block;
    padding: 6px 14px;
    margin: 0 3px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    color: #007bff;
}
.pagination a:hover {
    background: #e9ecef;
    text-decoration: none;
}
.pagination .current {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 768px) {
    .container {
        padding: 16px;
        border-radius: 8px;
    }
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .header h1 {
        font-size: 1.5rem;
        text-align: center;
    }
    .header .menu {
        justify-content: center;
        font-size: 0.9rem;
        gap: 8px 12px;
    }
    .search-form input[type="text"] {
        min-width: 150px;
    }
    .calendar-table th,
    .calendar-table td {
        padding: 4px 0;
        font-size: 0.8rem;
    }
    .calendar-table td a {
        padding: 4px 0;
    }
    .calendar-header {
        font-size: 1rem;
    }
    .calendar-header a {
        font-size: 1.5rem;
    }
    .post {
        padding: 15px 0;
    }
    .attachments img {
        max-width: 70px;
        max-height: 70px;
    }
    button, .btn {
        padding: 8px 16px;
        font-size: 0.95rem;
        width: 100%;
        margin-top: 5px;
    }
    .form-group input[type="text"],
    .form-group input[type="password"],
    .form-group input[type="date"],
    .form-group textarea,
    .form-group select {
        font-size: 16px; /* предотвращает зум на iOS */
    }
    .pagination a,
    .pagination span {
        padding: 4px 10px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px 8px;
    }
    .container {
        padding: 12px;
    }
    .header h1 {
        font-size: 1.3rem;
    }
    .header .menu {
        font-size: 0.8rem;
        gap: 6px 10px;
    }
    .search-form {
        flex-direction: column;
    }
    .search-form input[type="text"] {
        width: 100%;
    }
    .calendar-table th,
    .calendar-table td {
        font-size: 0.7rem;
        padding: 2px 0;
    }
    .calendar-table td a {
        padding: 2px 0;
    }
    .post-meta {
        font-size: 0.8rem;
    }
    .post-content {
        font-size: 0.95rem;
    }
}

/* ===== МАКЕТ ПЛАНОВ (2 колонки) ===== */
.plans-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    margin-top: 20px;
}
@media (max-width: 768px) {
    .plans-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* ===== КАЛЕНДАРЬ (уменьшенный) ===== */
.calendar-wrapper {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 12px 10px;
}
.calendar {
    margin: 0;
}
.calendar-header {
    font-size: 1rem;
    padding: 6px 0;
}
.calendar-header a {
    font-size: 1.2rem;
    padding: 0 6px;
}
.calendar-table {
    font-size: 0.8rem;
}
.calendar-table th,
.calendar-table td {
    padding: 2px 0;
    border: 1px solid #dee2e6;
    font-size: 0.8rem;
}
.calendar-table td a {
    padding: 4px 0;
    border-radius: 50%;
    display: block;
    color: #212529;
}
.calendar-table td.today a {
    background: #e2f0ff;
    font-weight: 700;
}
.calendar-table td.has-plan a {
    background: #d4edda;  /* зелёный фон для дней с планами */
    font-weight: 600;
}
.calendar-table td.selected a {
    background: #007bff;
    color: #fff;
}
.calendar-table td a:hover {
    background: #e9ecef;
    text-decoration: none;
}

/* ===== ПРАВАЯ ЧАСТЬ (планы) ===== */
.plans-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.plans-list {
    order: 1; /* список сверху */
}
.plan-form {
    order: 2; /* форма снизу */
    border-top: 1px solid #e9ecef;
    padding-top: 20px;
}

/* ===== УМЕНЬШЕННЫЕ ПОЛЯ ВВОДА ===== */
.plan-form .form-group {
    margin-bottom: 10px;
}
.plan-form .form-group label {
    font-size: 0.9rem;
    margin-bottom: 2px;
}
.plan-form .form-group input[type="text"],
.plan-form .form-group textarea {
    padding: 6px 10px;
    font-size: 0.9rem;
    border-radius: 6px;
}
.plan-form .form-group textarea {
    min-height: 60px;
}
.plan-form button {
    padding: 6px 16px;
    font-size: 0.9rem;
    width: auto;
}

/* Админка */
.admin-section {
    margin-top: 30px;
    border-top: 2px solid #dee2e6;
    padding-top: 20px;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
}
.admin-table th, .admin-table td {
    border: 1px solid #dee2e6;
    padding: 8px 12px;
    text-align: left;
}
.admin-table th {
    background: #f8f9fa;
}
.admin-form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}
.admin-form-inline input[type="text"],
.admin-form-inline input[type="password"] {
    padding: 5px 8px;
    font-size: 0.9rem;
}
.admin-form-inline button {
    padding: 5px 12px;
    font-size: 0.9rem;
}
.page-edit-form {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
}
.page-edit-form .form-group {
    margin-bottom: 8px;
}
.page-edit-form .form-group label {
    display: inline-block;
    width: 120px;
}
.page-edit-form .form-group input[type="text"],
.page-edit-form .form-group textarea {
    width: 70%;
    padding: 5px 8px;
}

/* Фильтр по тегам */
.tag-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
    align-items: center;
}
.tag-filter input[type="text"] {
    flex: 1;
    min-width: 150px;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 0.95rem;
}
.tag-filter select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 0.95rem;
    min-width: 200px;
    max-height: 200px;
    overflow-y: auto;
}
@media (max-width: 600px) {
    .tag-filter select {
        min-width: 100%;
    }
}