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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

:root {
    /* Light theme */
    --color-red: #C41E3A;
    --color-red-dark: #A01A2E;
    --color-red-hover: #D32F4A;
    --color-black: #000000;
    --color-white: #FFFFFF;
    --color-gray-dark: #333333;
    --color-gray: #666666;
    --color-gray-light: #999999;
    --color-gray-bg: #F5F5F5;
    --color-gray-border: #E0E0E0;
    --color-text-primary: #000000;
    --color-text-secondary: #666666;
    --color-bg-primary: #FFFFFF;
    --color-bg-secondary: #F5F5F5;
    --color-border: #E0E0E0;
    --color-shadow: rgba(0, 0, 0, 0.1);
    /* Logo colors for light theme */
    --logo-text-color: #000000;
    --logo-bar-color: #000000;
    --logo-subtitle-color: #FFFFFF;
}

[data-theme="dark"] {
    --color-text-primary: #FFFFFF;
    --color-text-secondary: #AAAAAA;
    --color-bg-primary: #0F0F0F;
    --color-bg-secondary: #181818;
    --color-border: #303030;
    --color-gray-bg: #181818;
    --color-gray-border: #303030;
    --color-shadow: rgba(0, 0, 0, 0.5);
    /* Logo colors for dark theme */
    --logo-text-color: #FFFFFF;
    --logo-bar-color: #FFFFFF;
    --logo-subtitle-color: #000000;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--color-text-primary);
    background-color: var(--color-bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    width: 100%;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

/* Header */
header {
    background-color: var(--color-bg-primary);
    border-bottom: 1px solid var(--color-border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px var(--color-shadow);
    width: 100%;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

header h1 a {
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s;
    cursor: pointer;
}

header h1 a:hover {
    opacity: 0.7;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-link {
    text-decoration: none;
    display: inline-block;
    transition: opacity 0.2s;
}

.logo-link:hover {
    opacity: 0.8;
}

.logo {
    height: 90px;
    width: auto;
    max-width: 340px;
    display: block;
    transition: filter 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    object-fit: contain;
    object-position: left center;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

[data-theme="dark"] .logo {
    filter: drop-shadow(0 2px 4px rgba(255, 255, 255, 0.1)) invert(1) hue-rotate(180deg);
}

@media (max-width: 1024px) {
    .logo {
        height: 80px;
        max-width: 300px;
    }
}

@media (max-width: 768px) {
    .logo {
        height: 70px;
        max-width: 260px;
    }
    
    .admin-title {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .logo {
        height: 60px;
        max-width: 220px;
    }
    
    .logo-container {
        flex-wrap: wrap;
    }
}

/* Дополнительная поддержка для очень маленьких экранов */
@media (max-width: 360px) {
    .logo {
        height: 50px;
        max-width: 180px;
    }
}

.admin-title {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

nav {
    display: flex;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
}

nav a {
    color: var(--color-text-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: opacity 0.2s;
    padding: 4px 0;
}

nav a:hover {
    opacity: 0.7;
}

#logoutBtn {
    background: var(--color-red);
    color: var(--color-white);
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 18px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

#logoutBtn:hover {
    background: var(--color-red-hover);
}

/* Theme toggle */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.theme-toggle:hover {
    background: var(--color-bg-secondary);
}

/* Main content */
main {
    flex: 1;
    padding: 48px 0 40px 0;
    min-height: calc(100vh - 200px);
}

/* Search section */
.search-section {
    margin-top: 24px;
    margin-bottom: 40px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: stretch;
}

#searchInput {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: 40px;
    font-size: 1rem;
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

#searchInput:focus {
    outline: none;
    border-color: var(--color-red);
    box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.1);
}

#searchBtn, #clearSearch {
    padding: 12px 24px;
    background: var(--color-red);
    color: var(--color-white);
    border: none;
    border-radius: 40px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.2s;
    white-space: nowrap;
}

#searchBtn:hover, #clearSearch:hover {
    background: var(--color-red-hover);
}

/* News list */
.news-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    width: 100%;
}

.news-card {
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 100%;
}

.news-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--color-shadow);
}

.news-card-image {
    width: 100%;
    max-width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--color-gray-bg);
    display: block;
}

.news-card-content {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.news-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--color-text-primary);
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-card-title mark {
    background-color: rgba(196, 30, 58, 0.2);
    color: var(--color-text-primary);
    padding: 2px 0;
    font-weight: 700;
    border-radius: 2px;
}

.news-card-date {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-bottom: 12px;
    font-weight: 400;
}

.news-card-excerpt {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.news-card-link {
    color: var(--color-red);
    font-weight: 500;
    text-decoration: none;
    margin-top: auto;
    display: inline-block;
    font-size: 0.9rem;
}

.news-card-link:hover {
    text-decoration: underline;
}

/* News content page */
.news-content {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.news-article {
    background: var(--color-bg-primary);
    padding: 32px 0;
}

.news-article h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 16px;
    line-height: 1.2;
    color: var(--color-text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

.news-article-date {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: 24px;
    font-weight: 400;
}

.news-article-image {
    width: 100%;
    max-width: 100%;
    max-height: 500px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid var(--color-border);
    display: block;
    height: auto;
}

.news-article-text {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--color-text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

.back-link {
    display: inline-block;
    margin-bottom: 24px;
    color: var(--color-text-primary);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 0;
    transition: opacity 0.2s;
}

.back-link:hover {
    opacity: 0.7;
}

/* Admin panel */
.login-form {
    max-width: 400px;
    margin: 48px auto;
    padding: 32px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-bg-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.login-form h2 {
    margin-bottom: 24px;
    text-align: center;
    color: var(--color-text-primary);
    font-weight: 600;
    font-size: 1.5rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--color-text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-size: 0.95rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    max-width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-red);
    box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.login-form button,
.news-form button {
    width: 100%;
    padding: 12px;
    background: var(--color-red);
    color: var(--color-white);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.login-form button:hover,
.news-form button:hover {
    background: var(--color-red-hover);
}

.error-message {
    color: var(--color-red);
    margin-top: 8px;
    font-size: 0.9rem;
    display: none;
    padding: 8px;
    background: rgba(196, 30, 58, 0.1);
    border-left: 3px solid var(--color-red);
    border-radius: 4px;
}

.error-message.show {
    display: block;
}

.date-error {
    margin-top: 4px;
    font-size: 0.85rem;
}

/* Admin panel spacing */
#adminPanel {
    margin-top: 32px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}

.admin-header h2 {
    font-size: 1.5rem;
    color: var(--color-text-primary);
    font-weight: 600;
}

.btn-primary {
    background: var(--color-red);
    color: var(--color-white);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.2s;
    white-space: nowrap;
}

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

.btn-secondary {
    background: var(--color-text-secondary);
    color: var(--color-white);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background: var(--color-gray-dark);
}

.btn-danger {
    background: var(--color-red-dark);
    color: var(--color-white);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-danger:hover {
    background: var(--color-red);
}

.news-management {
    display: grid;
    gap: 16px;
    width: 100%;
}

.news-item-admin {
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    transition: box-shadow 0.2s;
}

.news-item-admin:hover {
    box-shadow: 0 2px 8px var(--color-shadow);
}

.news-item-admin-content {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.news-item-admin-content h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--color-text-primary);
    font-weight: 600;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.news-item-admin-content p {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.news-item-admin-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    padding: 20px;
}

.modal-content {
    background-color: var(--color-bg-primary);
    margin: 2% auto;
    padding: 32px;
    border-radius: 12px;
    width: 100%;
    max-width: 700px;
    position: relative;
    border: 1px solid var(--color-border);
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: background-color 0.3s ease;
}

.close {
    position: absolute;
    right: 16px;
    top: 16px;
    font-size: 28px;
    font-weight: bold;
    color: var(--color-text-secondary);
    cursor: pointer;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    z-index: 1001;
    border-radius: 50%;
}

.close:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-secondary);
}

.modal-content h2 {
    margin-bottom: 24px;
    color: var(--color-text-primary);
    font-weight: 600;
    font-size: 1.5rem;
    padding-right: 40px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

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

.form-actions button {
    flex: 1;
    min-width: 120px;
}

.image-preview {
    margin-top: 8px;
    width: 100%;
}

.image-preview img {
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 200px;
    border-radius: 8px;
    margin-top: 8px;
    border: 1px solid var(--color-border);
    display: block;
    object-fit: contain;
}

.loading {
    text-align: center;
    padding: 48px;
    color: var(--color-text-secondary);
    font-size: 1rem;
}

.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--color-text-secondary);
    font-size: 1rem;
}

/* Footer */
footer {
    background-color: var(--color-bg-secondary);
    border-top: 1px solid var(--color-border);
    padding: 24px 0;
    margin-top: auto;
    width: 100%;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

footer p {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    font-weight: 400;
}

/* Responsive */
@media (max-width: 1024px) {
    .container {
        padding: 0 20px;
    }
    
    .news-list {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
    }
}

@media (max-width: 768px) {
    header {
        padding: 12px 0;
    }
    
    header .container {
        flex-direction: row;
        gap: 12px;
        align-items: center;
    }
    
    header h1 {
        font-size: 1.25rem;
    }

    nav {
        flex-direction: row;
        gap: 12px;
        margin-left: auto;
        flex-wrap: wrap;
    }
    
    nav a {
        font-size: 0.9rem;
    }
    
    .theme-toggle {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    main {
        padding: 32px 0;
    }
    
    #adminPanel {
        margin-top: 24px;
    }

    .news-list {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .news-card {
        width: 100%;
    }

    .admin-header {
        flex-direction: column;
        align-items: stretch;
        margin-top: 0;
    }
    
    .admin-header h2 {
        font-size: 1.25rem;
    }
    
    #addNewsBtn {
        width: 100%;
    }

    .news-item-admin {
        flex-direction: column;
        gap: 12px;
    }

    .news-item-admin-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .news-item-admin-actions button {
        flex: 1;
    }

    .modal {
        padding: 10px;
    }
    
    .modal-content {
        width: 100%;
        padding: 24px;
        margin: 10px auto;
        max-height: 95vh;
    }
    
    .close {
        right: 12px;
        top: 12px;
    }

    .news-article {
        padding: 24px 0;
    }
    
    .news-article h1 {
        font-size: 1.5rem;
    }
    
    .news-article-image {
        margin-bottom: 20px;
    }
    
    .login-form {
        margin: 32px auto;
        padding: 24px;
    }
    
.form-group input[type="datetime-local"] {
    font-size: 0.95rem;
    cursor: pointer;
}

.form-group input[type="datetime-local"]:invalid {
    border-color: var(--color-red);
}

.form-group input[type="datetime-local"]:valid {
    border-color: var(--color-border);
}
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.1rem;
    }
    
    nav {
        gap: 8px;
        flex-wrap: wrap;
    }
    
    nav a {
        font-size: 0.85rem;
    }
    
    .theme-toggle {
        padding: 6px 8px;
        font-size: 0.8rem;
    }
    
    #logoutBtn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    #adminPanel {
        margin-top: 20px;
    }

    .search-section {
        flex-direction: column;
        gap: 12px;
    }

    #searchInput,
    #searchBtn,
    #clearSearch {
        width: 100%;
    }
    
    .news-card-content {
        padding: 12px;
    }
    
    .news-card-title {
        font-size: 1rem;
    }

    .form-actions {
        flex-direction: column;
    }
    
    .form-actions button {
        width: 100%;
    }
    
    .news-item-admin {
        padding: 16px;
    }
    
    .news-item-admin-actions {
        flex-direction: column;
    }
    
    .news-item-admin-actions button {
        width: 100%;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .modal-content h2 {
        font-size: 1.25rem;
        padding-right: 32px;
        margin-bottom: 20px;
    }
    
    .form-group {
        margin-bottom: 16px;
    }
    
    .form-group input[type="datetime-local"] {
        font-size: 0.9rem;
        padding: 10px 12px;
    }
    
    .news-article h1 {
        font-size: 1.25rem;
    }
    
    .news-article-text {
        font-size: 1rem;
    }
    
    .admin-header {
        margin-bottom: 24px;
        padding-bottom: 12px;
    }
}

@media (max-width: 320px) {
    .container {
        padding: 0 16px;
    }
    
    header h1 {
        font-size: 1rem;
    }
    
    nav {
        gap: 6px;
    }
    
    nav a {
        font-size: 0.8rem;
    }
    
    .theme-toggle {
        padding: 5px 8px;
        font-size: 0.75rem;
    }
    
    #adminPanel {
        margin-top: 16px;
    }
    
    .news-card-title {
        font-size: 0.95rem;
    }
    
    .news-article h1 {
        font-size: 1.1rem;
    }
    
    .admin-header h2 {
        font-size: 1.1rem;
    }
    
    .form-group input[type="datetime-local"] {
        font-size: 0.85rem;
        padding: 8px 10px;
    }
    
    .modal-content {
        padding: 16px;
    }
}

/* Улучшение для планшетов */
@media (min-width: 481px) and (max-width: 768px) {
    .news-list {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

/* Улучшение для больших экранов */
@media (min-width: 1400px) {
    .container {
        max-width: 1400px;
    }
    
    .news-list {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }
}
