/* Карточки */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

/* Сетка статистики */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--accent-blue);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Список заметок */
.notes-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.note-item {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
}

.note-item:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.note-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    margin-right: 1rem;
}

.note-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.note-item:hover .note-actions {
    opacity: 1;
}

.action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}

.note-content {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.note-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.note-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Сетка пространств */
.spaces-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.space-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    min-height: 280px;
    display: flex;
    flex-direction: column;
}

.space-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-lg);
}

.space-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.space-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
}

.space-info {
    flex: 1;
}

.space-name {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.space-type {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.space-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 1.5rem 0;
    flex-grow: 1;
}

.space-stat {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
}

.space-stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.space-stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.space-actions {
    margin-top: auto;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.space-actions .btn-small {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
}

/* Стили для ID элементов */
.item-id {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    flex-shrink: 0;
}

.item-id:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    transform: scale(1.05);
}

.item-id.note-id {
    color: var(--accent-blue);
}

.item-id.goal-id {
    color: var(--accent-orange);
}

.item-id.goal-id:hover {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--accent-orange);
}

.item-id:active {
    transform: scale(0.95);
}

/* Стиль для ID в метаданных */
.note-meta-item .fa-hashtag {
    color: var(--text-muted);
    margin-right: 4px;
}

@media (max-width: 768px) {
    .spaces-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Стили для контейнеров графиков */
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.chart-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    margin-top: 1rem;
}

.chart-card h3 {
    margin: 0 0 1rem 0;
    font-size: 1.2rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Карточка профиля */
.profile-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: var(--transition);
}

.profile-card:hover {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-md);
}

/* Статус токена */
.token-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.token-status.active {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--accent-green);
}

.token-status.warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: var(--accent-orange);
}

.token-status.expired {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

/* Поле токена */
.token-field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.token-input {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: 'Courier New', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.token-copy-btn {
    position: absolute;
    right: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.token-copy-btn:hover {
    background: var(--bg-primary);
    color: var(--accent-blue);
}

/* ===== КРАСИВЫЕ СТИЛИ ДЛЯ ССЫЛОК ===== */

/* Карточка ссылки */
.note-item.note-type-link {
    border-left: 4px solid #9c27b0;
    background: linear-gradient(135deg, var(--bg-surface), rgba(156, 39, 176, 0.05));
}

/* Контейнер ссылки */
.note-link-container {
    margin: 8px 0;
    word-break: break-all;
}

.note-link {
    color: #9c27b0;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-block;
    padding: 4px 0;
    font-size: 0.9rem;
}

.note-link:hover {
    color: #7b1fa2;
    text-decoration: underline;
}

/* Превью ссылки */
.link-preview {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-top: 12px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(156, 39, 176, 0.2);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.link-preview:hover {
    background: rgba(156, 39, 176, 0.08);
    border-color: rgba(156, 39, 176, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(156, 39, 176, 0.2);
}

/* Иконка с градиентом */
.link-preview-icon {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.link-preview:hover .link-preview-icon {
    transform: scale(1.05) rotate(5deg);
}

/* Картинка в иконке */
.link-preview-image,
.link-preview-favicon {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.link-preview-favicon {
    object-fit: contain;
    padding: 8px;
    background: rgba(255, 255, 255, 0.9);
}

/* Текст в иконке (заглушка) */
.link-preview-icon-text {
    font-size: 28px;
    font-weight: bold;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    line-height: 1;
}

/* Контент превью */
.link-preview-content {
    flex: 1;
    min-width: 0;
}

.link-preview-title {
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 4px;
    font-size: 1rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s;
}

.link-preview:hover .link-preview-title {
    color: #9c27b0;
}

.link-preview-description {
    font-size: 0.85rem;
    color: #a0a0a0;
    margin-bottom: 8px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.link-preview-domain {
    font-size: 0.8rem;
    color: rgba(156, 39, 176, 0.7);
    display: flex;
    align-items: center;
    gap: 4px;
}

.domain-icon {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Адаптация для мобильных */
@media (max-width: 480px) {
    .link-preview {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 14px;
    }
    
    .link-preview-icon {
        width: 48px;
        height: 48px;
        border-radius: 14px;
    }
    
    .link-preview-icon-text {
        font-size: 24px;
    }
    
    .link-preview-title {
        font-size: 0.95rem;
    }
    
    .link-preview-description {
        font-size: 0.8rem;
    }
}

/* Анимация появления */
@keyframes previewAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.link-preview {
    animation: previewAppear 0.3s ease;
}


/* ===== УЛУЧШЕННЫЕ СТИЛИ ДЛЯ ФОТО ===== */

/* Контейнер для фото-заметки */
.note-image-container {
    width: 100%;
}

/* Подпись к фото */
.note-caption {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    padding: 0 4px;
}

/* Галерея фото */
.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

/* Элемент галереи */
.photo-gallery-item {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
}

.photo-gallery-item:hover {
    transform: translateY(-2px);
    border-color: #f44336;
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.2);
}

/* Контейнер для миниатюры */
.photo-thumbnail {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Миниатюра фото - теперь фото занимает всю область без обрезания */
.photo-thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: contain;  /* Изменено с cover на contain */
    background: var(--bg-primary);
    display: block;
    transition: transform 0.2s ease;
}

.photo-gallery-item:hover .photo-thumbnail-image {
    transform: scale(1.05);
}

/* Обработка ошибок загрузки */
.photo-error {
    background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f44336;
    font-size: 2rem;
    border: 1px dashed #f44336;
}

.photo-error-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Адаптация для маленьких экранов */
@media (max-width: 480px) {
    .photo-gallery {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 6px;
    }
}

/* Анимация появления */
@keyframes photoAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.photo-gallery-item {
    animation: photoAppear 0.2s ease;
}

/* ===== ЕДИНАЯ СИСТЕМА ПОЛОС ДЛЯ ВСЕХ ТИПОВ ЗАМЕТОК ===== */

/* Обычные текстовые заметки - синяя полоса */
.note-item.note-type-text {
    border-left: 4px solid var(--accent-blue, #3B82F6);
    background: linear-gradient(135deg, var(--bg-surface), rgba(59, 130, 246, 0.05));
}

/* Ссылки - фиолетовая полоса */
.note-item.note-type-link {
    border-left: 4px solid #9c27b0;
    background: linear-gradient(135deg, var(--bg-surface), rgba(156, 39, 176, 0.05));
}

/* Фото - красная полоса */
.note-item.note-type-image {
    border-left: 4px solid #f44336;
    background: linear-gradient(135deg, var(--bg-surface), rgba(244, 67, 54, 0.05));
}

/* Для будущих аудио - зеленая полоса */
.note-item.note-type-transcription {
    border-left: 4px solid #4caf50;
    background: linear-gradient(135deg, var(--bg-surface), rgba(76, 175, 80, 0.05));
}

/* Базовая карточка заметки */
.note-item {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    border-left-width: 4px;  /* Это обеспечит единую толщину */
    transition: all 0.3s ease;
    position: relative;
}

/* Убираем старый border-left из .note-item, если он там был */
.note-item {
    /* border-left: 1px solid var(--border-color); - удалите эту строку если есть */
}

/* Адаптация для мобильных */
@media (max-width: 480px) {
    .note-item {
        border-left-width: 4px;  /* Та же толщина на мобильных */
    }
}

/* ===== ВЫДЕЛЕНИЕ ПРИ НАВЕДЕНИИ ПО ТИПАМ ===== */

/* Текст - синее выделение */
.note-item.note-type-text:hover {
    border-color: #3B82F6;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

.note-item.note-type-text .note-header {
    border-bottom-color: rgba(59, 130, 246, 0.2);
}

/* Ссылки - фиолетовое выделение */
.note-item.note-type-link:hover {
    border-color: #9c27b0;
    box-shadow: 0 8px 20px rgba(156, 39, 176, 0.3);
}

.note-item.note-type-link .note-header {
    border-bottom-color: rgba(156, 39, 176, 0.2);
}

/* Фото - красное выделение */
.note-item.note-type-image:hover {
    border-color: #f44336;
    box-shadow: 0 8px 20px rgba(244, 67, 54, 0.3);
}

.note-item.note-type-image .note-header {
    border-bottom-color: rgba(244, 67, 54, 0.2);
}

/* Аудио - зеленое выделение */
.note-item.note-type-transcription:hover {
    border-color: #4caf50;
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.3);
}

.note-item.note-type-transcription .note-header {
    border-bottom-color: rgba(76, 175, 80, 0.2);
}

/* Общий стиль при наведении */
.note-item:hover {
    transform: translateY(-2px);
}

/* ===== ГОЛОСОВЫЕ ЗАМЕТКИ ===== */

/* Контейнер голосовой заметки */
.voice-note-container {
    width: 100%;
}

/* Текст транскрибации */
.voice-transcript {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    padding: 12px;
    background: rgba(76, 175, 80, 0.05);
    border-radius: var(--radius-md);
    border-left: 3px solid #4caf50;
}

/* Плеер */
.voice-player {
    background: rgba(76, 175, 80, 0.08);
    border-radius: var(--radius-lg);
    padding: 16px;
    border: 1px solid rgba(76, 175, 80, 0.2);
    transition: all 0.3s ease;
}

.voice-player:hover {
    background: rgba(76, 175, 80, 0.12);
    border-color: rgba(76, 175, 80, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.2);
}

/* Контролы плеера */
.voice-player-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Кнопка воспроизведения - ОПТИМИЗИРОВАННАЯ */
.voice-play-btn {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4caf50, #45a049);
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
    transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.2s ease;
    position: relative;
    z-index: 10;
    /* Оптимизация для устранения моргания */
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
    transform: translateZ(0);
    will-change: transform;
    outline: none;
}

.voice-play-btn:hover {
    transform: scale(1.1) translateZ(0);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.5);
    background: linear-gradient(135deg, #4caf50, #45a049); /* Фиксируем фон */
}

.voice-play-btn:active {
    transform: scale(0.95) translateZ(0);
    transition: transform 0.05s ease;
}

.voice-play-btn.playing {
    background: linear-gradient(135deg, #f44336, #e53935);
}

.voice-play-btn.playing:hover {
    background: linear-gradient(135deg, #f44336, #e53935); /* Фиксируем фон для playing */
    box-shadow: 0 8px 20px rgba(244, 67, 54, 0.5);
}

/* Визуализация (плейсхолдер) */
.voice-waveform {
    flex: 1;
    height: 48px;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 24px;
    overflow: hidden;
    position: relative;
}

.waveform-placeholder {
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        90deg,
        rgba(76, 175, 80, 0.2) 0px,
        rgba(76, 175, 80, 0.2) 4px,
        transparent 4px,
        transparent 8px
    );
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 16px;
}

.waveform-placeholder .duration {
    color: #4caf50;
    font-size: 0.9rem;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Истекшее аудио */
.voice-expired {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
}

.voice-expired i {
    color: #f44336;
    font-size: 1.1rem;
}

/* Модальное окно для голосовых */
.voice-modal .audio-player {
    width: 100%;
    margin: 20px 0;
}

.voice-modal audio {
    width: 100%;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}

.voice-modal .full-transcript {
    background: rgba(76, 175, 80, 0.05);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin: 20px 0;
    border-left: 4px solid #4caf50;
}

.voice-modal .full-transcript h3 {
    color: #4caf50;
    margin-top: 0;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.voice-modal .full-transcript p {
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 1rem;
    white-space: pre-wrap;
}

/* Адаптация для мобильных */
@media (max-width: 480px) {
    .voice-player-controls {
        gap: 12px;
    }
    
    .voice-play-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .voice-waveform {
        height: 40px;
    }
    
    .voice-transcript {
        font-size: 0.9rem;
        padding: 10px;
    }
}