/* ============================================================
   MAIN STYLESHEET — Portfolio CMS
   Тёмная тема по умолчанию, светлая через класс .light-mode
   ============================================================ */

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #0a0a1a; color: #e2e8f0; min-height: 100vh; line-height: 1.6; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }
button, input, textarea, select { font: inherit; }

/* ─── CSS Variables (Dark Theme Defaults) ──────────────────── */
:root {
    --bg-primary: #0a0a1a;
    --bg-card: rgba(15, 15, 40, 0.6);
    --bg-glass: rgba(15, 15, 40, 0.5);
    --border-color: rgba(99, 102, 241, 0.15);
    --text-primary: #e2e8f0;
    --text-muted: #94a3b8;
    --accent-indigo: #6366f1;
    --accent-purple: #8b5cf6;
    --accent-cyan: #22d3ee;
    --accent-orange: #f97316;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-yellow: #eab308;
}

/* ─── Light Mode Override ─────────────────────────────────── */
.light-mode {
    --bg-primary: #f8fafc;
    --bg-card: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.8);
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-muted: #64748b;
}
.light-mode { background: #f8fafc; color: #0f172a; }

/* ─── Layout ──────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }
.main-content { flex: 1; padding: 24px; overflow-y: auto; }
.page-container { max-width: 1200px; margin: 0 auto; }

/* ─── Glassmorphism ───────────────────────────────────────── */
.glass { background: var(--bg-glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--border-color); }
.glass-strong { background: rgba(15, 15, 40, 0.7); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid rgba(99, 102, 241, 0.2); }

/* ─── Neon Effects ────────────────────────────────────────── */
.neon-glow { box-shadow: 0 0 15px rgba(99, 102, 241, 0.3), 0 0 45px rgba(99, 102, 241, 0.1); }
.neon-glow-hover:hover { box-shadow: 0 0 20px rgba(99, 102, 241, 0.5), 0 0 60px rgba(99, 102, 241, 0.2); transform: translateY(-2px); }

/* ─── Gradient Text ───────────────────────────────────────── */
.gradient-text { background: linear-gradient(135deg, #6366f1, #3b82f6, #8b5cf6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* ─── Grid Background ─────────────────────────────────────── */
.grid-bg { background-image: linear-gradient(rgba(99, 102, 241, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(99, 102, 241, 0.05) 1px, transparent 1px); background-size: 20px 20px; }

/* ─── Animations ──────────────────────────────────────────── */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-6px); }
}
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(99, 102, 241, 0.3); }
    50% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.6); }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes checkmark {
    0% { stroke-dashoffset: 50; }
    100% { stroke-dashoffset: 0; }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-float { animation: float 3s ease-in-out infinite; }
.animate-pulse-glow { animation: pulse-glow 2s ease-in-out infinite; }
.animate-fade-in-up { animation: fadeInUp 0.5s ease-out forwards; opacity: 0; }
.animate-fade-in { animation: fadeIn 0.3s ease-out forwards; }
.animate-scale-in { animation: scaleIn 0.2s ease-out forwards; }
.animate-slide-up { animation: slideUp 0.3s ease-out forwards; }

/* Задержки для каскадных анимаций */
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }

/* ─── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.5); }

/* ─── Form Elements ───────────────────────────────────────── */
.form-input {
    background: rgba(15, 15, 40, 0.6);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: #e2e8f0;
    padding: 10px 14px;
    border-radius: 8px;
    outline: none;
    transition: all 0.2s;
    width: 100%;
    font-size: 14px;
}
.form-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.form-input::placeholder { color: #64748b; }
textarea.form-input { resize: vertical; min-height: 80px; }
select.form-input { cursor: pointer; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; color: var(--text-primary); }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
    font-size: 14px;
}
.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
    background: rgba(99, 102, 241, 0.1);
    color: #c7d2fe;
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}
.btn-secondary:hover { background: rgba(99, 102, 241, 0.2); }

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; border-radius: 8px; }

/* ─── Light Mode Form Overrides ───────────────────────────── */
.light-mode .form-input {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #0f172a;
}
.light-mode .form-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.light-mode .glass { box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.light-mode .btn-secondary { color: #4f46e5; border-color: #c7d2fe; background: #eef2ff; }
.light-mode .btn-danger { color: #dc2626; border-color: #fca5a5; background: #fef2f2; }

/* ─── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s;
}
.card:hover { border-color: rgba(99, 102, 241, 0.3); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.card-body { color: var(--text-muted); font-size: 14px; }
.card-footer { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-color); }

/* ─── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}
.badge-indigo { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #c4b5fd; }
.badge-cyan { background: rgba(34, 211, 238, 0.15); color: #67e8f9; }
.badge-green { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.badge-yellow { background: rgba(234, 179, 8, 0.15); color: #fde047; }
.badge-red { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.badge-orange { background: rgba(249, 115, 22, 0.15); color: #fdba74; }

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(99, 102, 241, 0.15);
    background: rgba(10, 10, 30, 0.9);
    backdrop-filter: blur(20px);
    transition: width 0.3s ease;
    overflow: hidden;
    flex-shrink: 0;
}
.sidebar-collapsed { width: 72px; }
.sidebar-expanded { width: 260px; }
.sidebar-header { padding: 16px; border-bottom: 1px solid rgba(99, 102, 241, 0.1); display: flex; align-items: center; gap: 12px; min-height: 64px; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid rgba(99, 102, 241, 0.1); }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    text-decoration: none;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
}
.nav-item:hover { background: rgba(99, 102, 241, 0.1); color: #e2e8f0; }
.nav-item.active { background: rgba(99, 102, 241, 0.15); color: #6366f1; }
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: #6366f1;
    border-radius: 0 4px 4px 0;
}
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.nav-label { font-size: 14px; font-weight: 500; }

.light-mode .sidebar { background: rgba(255, 255, 255, 0.95); border-right-color: #e2e8f0; }
.light-mode .nav-item { color: #64748b; }
.light-mode .nav-item:hover { background: #f1f5f9; color: #0f172a; }
.light-mode .nav-item.active { background: #eef2ff; color: #4f46e5; }

/* ─── Chat Widget ─────────────────────────────────────────── */
.chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    z-index: 100;
    transition: transform 0.2s;
}
.chat-bubble:hover { transform: scale(1.1); }
.chat-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 360px;
    max-height: 480px;
    border-radius: 16px;
    overflow: hidden;
    z-index: 100;
    transition: all 0.3s;
    display: none;
}
.chat-panel.open { display: flex; flex-direction: column; }
.chat-header { padding: 14px 16px; background: rgba(99, 102, 241, 0.15); border-bottom: 1px solid var(--border-color); font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: space-between; }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 300px; max-height: 360px; }
.chat-input-area { padding: 12px; border-top: 1px solid var(--border-color); display: flex; gap: 8px; }
.chat-input-area .form-input { flex: 1; }

.msg { max-width: 80%; padding: 8px 12px; border-radius: 12px; font-size: 14px; word-wrap: break-word; }
.msg-sent { align-self: flex-end; background: rgba(99, 102, 241, 0.3); border-bottom-right-radius: 4px; }
.msg-received { align-self: flex-start; background: rgba(99, 102, 241, 0.1); border-bottom-left-radius: 4px; }
.msg-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.msg-unread { font-weight: 600; }

/* Индикатор непрочитанных сообщений */
.unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-red);
    color: white;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ─── Tables ──────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border-color); }
table { width: 100%; border-collapse: collapse; }
th { background: rgba(99, 102, 241, 0.08); padding: 10px 14px; text-align: left; font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border-color); }
td { padding: 10px 14px; font-size: 14px; border-bottom: 1px solid var(--border-color); color: var(--text-primary); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(99, 102, 241, 0.04); }

/* ─── Flash / Toast Messages ──────────────────────────────── */
.flash { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; animation: fadeInUp 0.3s ease-out; }
.flash-success { background: rgba(34, 197, 94, 0.15); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.2); }
.flash-error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.2); }
.flash-warning { background: rgba(234, 179, 8, 0.15); color: #fde047; border: 1px solid rgba(234, 179, 8, 0.2); }
.flash-info { background: rgba(34, 211, 238, 0.15); color: #67e8f9; border: 1px solid rgba(34, 211, 238, 0.2); }

/* Тост-уведомления */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: 8px; font-size: 14px; color: white; animation: slideInLeft 0.3s ease-out; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
.toast-info { background: #6366f1; }

/* ─── Modal ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.2s ease-out;
}
.modal {
    background: rgba(15, 15, 40, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 480px;
    animation: scaleIn 0.2s ease-out;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; padding: 4px; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { margin-bottom: 20px; color: var(--text-muted); font-size: 14px; line-height: 1.6; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; }

.light-mode .modal { background: #ffffff; box-shadow: 0 4px 24px rgba(0,0,0,0.15); }

/* ─── Hero Section ────────────────────────────────────────── */
.hero { padding: 80px 24px; text-align: center; position: relative; overflow: hidden; }
.hero h1 { font-size: 48px; font-weight: 800; margin-bottom: 16px; line-height: 1.2; }
.hero p { font-size: 18px; color: var(--text-muted); max-width: 600px; margin: 0 auto 32px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ─── Portfolio Grid ──────────────────────────────────────── */
.portfolio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; padding: 24px 0; }
.project-card { border-radius: 16px; overflow: hidden; transition: all 0.3s; }
.project-card:hover { transform: translateY(-4px); }
.project-card img { width: 100%; height: 200px; object-fit: cover; }
.project-card-body { padding: 20px; }
.project-card-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.project-card-desc { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.project-card-footer { display: flex; align-items: center; justify-content: space-between; }

/* ─── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-color); margin-bottom: 20px; }
.tab { padding: 10px 16px; font-size: 14px; font-weight: 500; color: var(--text-muted); cursor: pointer; border: none; background: none; border-bottom: 2px solid transparent; transition: all 0.2s; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-indigo); border-bottom-color: var(--accent-indigo); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Stats ───────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { padding: 20px; text-align: center; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--accent-indigo); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ─── Loading / Spinner ───────────────────────────────────── */
.spinner { width: 24px; height: 24px; border: 3px solid rgba(99, 102, 241, 0.2); border-top-color: #6366f1; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.3); display: flex; align-items: center; justify-content: center; z-index: 999; }

/* ─── Empty State ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 16px; opacity: 0.5; }
.empty-state p { font-size: 15px; }

/* ─── Login Page ──────────────────────────────────────────── */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; padding: 32px; }
.login-card h2 { text-align: center; margin-bottom: 24px; font-size: 24px; }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar-expanded { width: 260px; position: fixed; z-index: 50; }
    .sidebar-collapsed { width: 0; overflow: hidden; }
    .chat-panel { width: calc(100vw - 32px); right: 16px; }
    .hero h1 { font-size: 32px; }
    .hero p { font-size: 15px; }
    .portfolio-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .main-content { padding: 16px; }
    .modal { width: 95%; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .hero { padding: 48px 16px; }
    .hero h1 { font-size: 26px; }
}

/* ─── Utility Classes ─────────────────────────────────────── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-indigo); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.w-full { width: 100%; }
.hidden { display: none; }
.rounded { border-radius: 8px; }
.rounded-lg { border-radius: 12px; }
.overflow-hidden { overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transition { transition: all 0.3s; }
.cursor-pointer { cursor: pointer; }