@import url('home.css');

/* Основные стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: #f4f4f4;
    color: #333;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Шапка сайта */
header {
    background-color: #333;
    color: #fff;
    padding: 14px 0 10px;
}

.nav-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.site-title {
    margin: 0;
    font-size: 2rem;
    text-align: left;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.nav-toggle span {
    display: block;
    width: 26px;
    height: 3px;
    background: #fff;
    transition: transform 0.2s, opacity 0.2s;
}

.nav-toggle.open span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
.nav-toggle.open span:nth-child(2) {
    opacity: 0;
}
.nav-toggle.open span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

nav ul {
    list-style: none;
    padding: 10px 0 0;
    display: flex;
    gap: 18px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

nav ul li {
    margin: 0;
}

nav ul li a {
    color: #fff;
    text-decoration: none;
    font-size: 1rem;
}

nav ul li a:hover {
    text-decoration: underline;
}

/* Мобильное меню */
@media (max-width: 768px) {
    .site-title {
        font-size: 1.6rem;
    }

    .nav-toggle {
        display: flex;
    }

    nav ul {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        display: none;
    }

    nav ul.open {
        display: flex;
    }

    nav ul li a {
        font-size: 1rem;
        padding: 4px 0;
    }
}

/* Основной контент */
main {
    flex: 1; /* Заставляем main занимать всё доступное пространство */
    padding: 40px 0;
}

.intro {
    text-align: center;
    margin-bottom: 50px;
}

.intro h2 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.intro p {
    font-size: 1.2rem;
    color: #666;
}

.blog-posts {
    text-align: left;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.blog-posts h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: #333;
}

.posts-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    padding-bottom: 24px;
}

.post {
    background: #ffffff;
    padding: 24px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.post::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.post:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
    transform: translateY(-2px);
    border-color: rgba(59, 130, 246, 0.15);
}

.post:hover::before {
    opacity: 1;
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}

.post h3 {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.4;
    flex: 1;
    letter-spacing: -0.01em;
}

.post-date {
    font-size: 0.75rem;
    color: #64748b;
    white-space: nowrap;
    padding: 4px 10px;
    background: #f8fafc;
    border-radius: 16px;
    font-weight: 500;
    letter-spacing: 0.01em;
    border: 1px solid #e2e8f0;
}

.post-excerpt {
    color: #64748b;
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 0 0 16px 0;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 400;
}

/* Премиум кнопки действий */
.post-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0;
    text-align: center;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: none;
    width: 36px;
    height: 36px;
    position: relative;
    overflow: hidden;
}

.btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
    transition: transform 0.2s ease;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.btn:hover::before {
    width: 100%;
    height: 100%;
}

.btn:hover svg {
    transform: scale(1.1);
}

/* Первичный стиль (просмотр) */
.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

/* Вторичный стиль (редактирование) */
.btn-secondary {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(100, 116, 139, 0.25);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #475569 0%, #334155 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.35);
}

/* Опасный стиль (удаление) */
.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

/* Кнопки в формах (переопределение компактных .btn для текстовых кнопок) */
.profile-form .btn {
    font-size: 0.875rem !important;
    padding: 8px 16px !important;
    width: auto !important;
    height: auto !important;
    display: inline-flex !important;
    gap: 6px;
}

/* Стили для формы добавления статьи */
/* Страница авторизации */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
    padding: 40px 20px;
    position: relative;
    overflow: hidden;
}

.login-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    top: -200px;
    left: -200px;
    animation-delay: 0s;
}

.orb-2 {
    width: 350px;
    height: 350px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    bottom: -150px;
    right: -150px;
    animation-delay: 5s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 10s;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(30px, -30px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 48px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 8px 24px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    z-index: 1;
}

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

.login-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    margin-bottom: 24px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 12px 32px rgba(102, 126, 234, 0.5);
    }
}

.login-icon {
    color: #ffffff;
    animation: iconRotate 3s ease-in-out infinite;
}

@keyframes iconRotate {
    0%, 100% {
        transform: rotate(0deg);
    }
    50% {
        transform: rotate(5deg);
    }
}

.login-header h1 {
    margin: 0 0 8px 0;
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    animation: textShine 3s ease-in-out infinite;
}

@keyframes textShine {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

.login-subtitle {
    margin: 0;
    font-size: 0.9375rem;
    color: #6b7280;
    font-weight: 400;
}

.error-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    color: #dc2626;
    font-size: 0.875rem;
    margin-bottom: 24px;
    animation: slideIn 0.3s ease-out;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

.error-message svg {
    flex-shrink: 0;
    color: #dc2626;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin: 0;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-icon {
    position: absolute;
    left: 14px;
    color: #9ca3af;
    pointer-events: none;
    z-index: 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-focus-line {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 0;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

.input-wrapper.focused .input-focus-line {
    width: 100%;
}

.input-wrapper.has-value .input-icon {
    color: #667eea;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 14px 14px 14px 44px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 400;
    color: #111827;
    background: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    background: #fafbfc;
    transform: translateY(-1px);
}

.login-form input[type="text"]::placeholder,
.login-form input[type="password"]::placeholder {
    color: #9ca3af;
}

.login-form input[type="text"]:focus + .input-icon,
.login-form input[type="password"]:focus + .input-icon {
    color: #3b82f6;
}

.login-button {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 8px;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    position: relative;
    overflow: hidden;
}

.login-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.login-button:hover::before {
    left: 100%;
}

.login-button:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.5);
}

.login-button:active {
    transform: translateY(0);
}

.login-button:disabled {
    opacity: 0.7;
    cursor: wait;
}

.login-button .button-text,
.login-button .button-icon {
    transition: opacity 0.3s ease;
}

.login-button .button-loader {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.login-button svg {
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.login-button:hover svg {
    transform: translateX(3px);
}

.login-divider {
    display: flex;
    align-items: center;
    margin: 32px 0;
    text-align: center;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, #e5e7eb, transparent);
}

.login-divider span {
    padding: 0 16px;
    color: #9ca3af;
    font-size: 0.875rem;
    font-weight: 500;
}

.telegram-login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 8px;
    min-height: 60px;
}

.telegram-login-wrapper iframe {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.telegram-login-wrapper iframe:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.telegram-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    color: #6b7280;
    font-size: 0.875rem;
}

.telegram-loading .spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@media (max-width: 480px) {
    .login-container {
        padding: 20px 16px;
        min-height: calc(100vh - 150px);
    }
    
    .login-card {
        padding: 32px 24px;
        border-radius: 20px;
    }
    
    .login-header h1 {
        font-size: 1.625rem;
    }
    
    .login-icon-wrapper {
        width: 64px;
        height: 64px;
        margin-bottom: 20px;
    }
    
    .login-icon {
        width: 36px;
        height: 36px;
    }
    
    .gradient-orb {
        filter: blur(60px);
    }
    
    .orb-1, .orb-2, .orb-3 {
        width: 250px;
        height: 250px;
    }
    
    .login-divider {
        margin: 24px 0;
    }
}

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

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input[type="text"],
input[type="password"],
button[type="submit"],
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

textarea {
    resize: vertical;
    height: 100px;
}

.submit-button {
    background: #333;
    color: #ffffff;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.submit-button:hover {
    background: #555;
}

.post-intro {
    margin-bottom: 15px;
}

/* Футер */
footer {
    background-color: #1e293b;
    color: #cbd5e1;
    padding: 32px 20px;
    text-align: center;
    position: relative;
    width: 100%;
    margin-top: 48px;
    box-sizing: border-box;
}

footer .container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

footer p {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 400;
    color: #94a3b8;
    letter-spacing: 0.01em;
}

/* Устаревший класс, заменен на .post-date */
.updated-at {
    display: none;
}

.success-message {
    color: #28a745; /* Зеленый цвет для успеха */
    font-weight: bold;
    margin-bottom: 20px; /* Отступ снизу */
}

/* Изменение стиля для кнопки "Добавить новую статью" */
.add-post-container {
    text-align: left; /* Выровнять по левому краю */
    margin-bottom: 20px; /* Отступ снизу */
}

/* Дополнительные улучшения для общего стиля */
.blog-posts {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

@media (max-width: 768px) {
    .blog-posts {
        padding: 0 16px;
    }
    
    .posts-list {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .post {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .site-title {
        font-size: 2rem;
    }

    .intro h2 {
        font-size: 1.6rem;
    }
}

/* Стили для CodeMirror редактора */
.CodeMirror {
    border: 1px solid #ddd;
    border-radius: 4px;
    height: auto;
    min-height: 300px;
    font-size: 14px;
    line-height: 1.5;
}

.CodeMirror-scroll {
    min-height: 300px;
    max-height: 600px;
}

.CodeMirror-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    z-index: 9999;
}

.CodeMirror-focused {
    outline: none;
    border-color: #007bff;
}

/* Профиль */
.profile-container {
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    max-width: 720px;
    margin: 30px auto;
}

.profile-container h2 {
    margin-bottom: 18px;
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profile-form .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.profile-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-form input {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.profile-form input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.profile-form .form-actions {
    display: flex;
    justify-content: flex-end;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
}

.alert.success {
    background: #ecfdf3;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert.error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecdd3;
}

@media (max-width: 768px) {
    .profile-container {
        margin: 16px auto;
        padding: 16px;
    }
}

/* Стили для кнопок редактора */
#insert-code-btn:hover,
#fullscreen-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

#insert-code-btn:active,
#fullscreen-btn:active {
    transform: translateY(0);
}

/* Стили для блоков кода в предпросмотре */
.code-block {
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.5;
}

.code-block code {
    display: block;
    padding: 0;
    background: transparent;
    border: none;
}
