/* --- Константи та змінні --- */
:root {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --error: #ef4444;
    --success: #10b981;
    --glass: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.1);
}

/* --- Загальні стилі --- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at top right, #1e1b4b, transparent),
        radial-gradient(circle at bottom left, #1e1b4b, transparent);
    color: var(--text);
    margin: 0;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Хедер --- */
.header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 40px;
    height: 70px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: -0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* --- Пошук --- */
.search-wrapper {
    flex: 1;
    position: relative;
    min-width: 0;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.search {
    width: 100%;
    padding: 9px 14px 9px 14px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: 0.3s;
}

.search::placeholder {
    color: var(--text-muted);
}

.search:focus {
    border-color: var(--accent);
    background: var(--card-bg);
    outline: none;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

/* --- Права частина хедера --- */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.username {
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clear-link {
    text-decoration: none;
    display: flex;
    align-items: center;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, #6d28d9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder-header {
    font-size: 15px;
    font-weight: 700;
    color: white;
}

.nav-avatar,
.nav-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.nav-avatar-placeholder {
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* --- Main content --- */
.content {
    flex: 1;
    padding: 24px 40px;
}

/* --- Контейнер --- */
.container {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* --- Картки --- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 2.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

/* --- Авторизація --- */
.auth-content {
    display: flex;
    justify-content: center;
    /* align-items: center; */
    /* padding: 2rem 1rem; */
    padding-top: 24px;
    min-height: calc(100vh - 70px);
}

.auth-container {
    width: 100%;
    max-width: 450px;
    height: fit-content;
    background: var(--card-bg);
    padding: 40px;
    border-radius: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-title {
    font-size: 2rem;
    font-weight: 800;
    margin: 0 0 0.5rem;
    text-align: center;
}

.auth-subtitle {
    color: var(--text-muted);
    text-align: center;
    margin: 0 0 2rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.auth-footer {
    margin-top: 24px;
    font-size: 14px;
    text-align: center;
}

.auth-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

/* --- Поля форми --- */
.field-group {
    margin-bottom: 1.25rem;
    position: relative;
    text-align: left;
}

.form-control {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    transition: 0.3s;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.password-container {
    position: relative;
}

.password-eye-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    cursor: pointer;
}

/* --- Кнопки --- */
.btn {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 10px 22px;
    border-radius: 0.75rem;
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.35);
}

.btn-outline {
    background: transparent;
    outline: 1px solid var(--accent);
    outline-offset: -1px;
    color: var(--accent);
}

.btn-outline:hover {
    background: var(--accent);
    color: white;
}

.buttons.l-r-but {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.buttons.l-r-but .btn {
    flex: 1;
    min-width: 120px;
}

/* --- Профіль --- */
.profile-container {
    max-width: 900px;
    margin: 1rem auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.profile-avatar-large {
    width: 100px;
    height: 100px;
    border-radius: 24px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

.avatar-placeholder {
    font-size: 40px;
    font-weight: 700;
    color: var(--text);
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent);
}

.avatar-badge {
    position: absolute;
    bottom: 5px;
    right: 5px;
    padding: 5px;
    border-radius: 50%;
    font-size: 1.2rem;
    border: 2px solid var(--card-bg);
}

.profile-text h1 {
    margin: 0 0 0.25rem;
    font-size: 1.75rem;
    word-break: break-word;
}

.user-role {
    color: var(--accent);
    font-weight: 600;
    margin: 0.2rem 0;
}

.user-joined {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.profile-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.activity-section {
    width: 100%;
}

.activity-placeholder {
    margin-top: 16px;
    padding: 40px;
    border: 2px dashed var(--border);
    border-radius: 12px;
    text-align: center;
    opacity: 0.6;
}

.chart-mockup {
    height: 150px;
    background: linear-gradient(90deg, transparent 0%, var(--border) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: loading 2s infinite;
    margin-top: 20px;
    border-radius: 8px;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* --- Помилки --- */
.form-error {
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 0.4rem;
    list-style: none;
    padding: 0;
}

/* --- Avatar dropdown --- */
.avatar-dropdown {
    position: relative;
}

.avatar-dropdown-trigger {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-radius: 50%;
    transition: opacity 0.2s;
}

.avatar-dropdown-trigger:hover {
    opacity: 0.85;
}

.avatar-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 210px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
    padding: 0.5rem;
    z-index: 200;

    opacity: 0;
    transform: translateY(-6px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    transform-origin: top right;
}

.avatar-dropdown--open .avatar-dropdown-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.avatar-dropdown-header {
    padding: 0.5rem 0.75rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.avatar-dropdown-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar-dropdown-email {
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.35rem 0;
}

.avatar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: 0.6rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.avatar-dropdown-item i {
    width: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: color 0.15s;
}

.avatar-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.avatar-dropdown-item:hover i {
    color: var(--accent);
}

.avatar-dropdown-item--accent {
    color: var(--accent);
    font-weight: 600;
}

.avatar-dropdown-item--accent i {
    color: var(--accent);
}

.avatar-dropdown-item--accent:hover {
    background: rgba(139, 92, 246, 0.12);
}

.avatar-dropdown-item--danger {
    color: #f87171;
}

.avatar-dropdown-item--danger i {
    color: #f87171;
}

.avatar-dropdown-item--danger:hover {
    background: rgba(248, 113, 113, 0.1);
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* --- Tablet ≤ 900px --- */
@media (max-width: 900px) {
    .header {
        padding: 0 24px;
    }

    .content {
        padding: 20px 24px;
    }
}

/* --- Tablet ≤ 768px --- */
@media (max-width: 768px) {
    .header {
        padding: 0 16px;
        height: 60px;
        gap: 10px;
    }

    .logo {
        font-size: 1.15rem;
    }

    .username {
        display: none;
    }

    .content {
        padding: 16px;
    }

    .card {
        padding: 1.5rem;
        border-radius: 1rem;
    }

    .auth-content {
        min-height: calc(100vh - 60px);
        padding: 2rem 1rem;
        align-items: flex-start;
    }

    .auth-container {
        padding: 32px 24px;
    }

    .auth-title {
        font-size: 1.7rem;
    }

    .profile-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .profile-actions {
        width: 100%;
    }

    .profile-actions .btn {
        flex: 1;
        text-align: center;
    }
}

/* --- Mobile ≤ 480px --- */
@media (max-width: 480px) {
    .header {
        padding: 0 12px;
        gap: 8px;
        height: 56px;
    }

    .logo {
        font-size: 1rem;
    }

    .search {
        font-size: 0.82rem;
        padding: 7px 10px 7px 10px;
    }

    .search-icon {
        left: 10px;
        font-size: 0.78rem;
    }

    .header-right .btn {
        padding: 6px 11px;
        font-size: 0.8rem;
        border-radius: 0.55rem;
    }

    .content {
        padding: 12px;
    }

    .card {
        padding: 1.1rem;
        border-radius: 0.875rem;
    }

    .auth-content {
        min-height: calc(100vh - 56px);
        padding: 1.5rem 0.75rem;
        align-items: flex-start;
    }

    .auth-container {
        padding: 24px 16px;
        border-radius: 1.1rem;
    }

    .auth-title {
        font-size: 1.45rem;
    }

    .auth-subtitle {
        font-size: 0.875rem;
        margin-bottom: 1.5rem;
    }

    .form-control {
        font-size: 0.9rem;
        padding: 0.7rem 0.875rem;
    }

    .profile-container {
        margin: 1rem auto;
    }

    .profile-avatar-large {
        width: 76px;
        height: 76px;
        border-radius: 18px;
    }

    .avatar-placeholder {
        font-size: 30px;
    }

    .profile-text h1 {
        font-size: 1.3rem;
    }

    .profile-actions {
        flex-direction: column;
    }

    .profile-actions .btn {
        width: 100%;
    }

    .activity-placeholder {
        padding: 20px 12px;
    }

    .btn {
        padding: 9px 18px;
    }
}

/* --- Very small ≤ 360px --- */
@media (max-width: 360px) {
    .logo {
        font-size: 0.9rem;
    }

    .search-wrapper {
        display: none;
    }

    .auth-title {
        font-size: 1.3rem;
    }

    .card {
        padding: 0.875rem;
    }
}

/* ── Django messages ────────────────────────────────── */
.td-messages {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0px 100px 24px;
}

.td-msg {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.td-msg--success {
    background: rgba(34, 197, 94, .12);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, .25);
}

.td-msg--error {
    background: rgba(239, 68, 68, .12);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, .25);
}

.td-msg--warning {
    background: rgba(234, 179, 8, .12);
    color: #facc15;
    border: 1px solid rgba(250, 204, 21, .25);
}

.td-msg--info {
    background: rgba(59, 130, 246, .12);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, .25);
}

.td-messages {
    margin-bottom: 1rem;
}

.td-msg {
    position: relative;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    animation: td-msg-slide-in 0.4s ease-out;
    transition: opacity 0.4s ease, transform 0.4s ease, max-height 0.4s ease;
    max-height: 200px;
    overflow: hidden;
}

.td-msg--hiding {
    opacity: 0;
    transform: translateX(20px);
    max-height: 0;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
}

.td-msg__close {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    font-size: 1rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.td-msg__close:hover {
    opacity: 1;
}

@keyframes td-msg-slide-in {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (max-width: 480px) {
    .td-messages {
        padding: 0 0 16px;
    }
}