/* Компоненты и UI элементы */

/* Уведомления */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 400px;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-tooltip);
    opacity: 0;
    transform: translateX(100%);
    transition: all var(--transition-normal);
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification--success {
    background: var(--color-success);
    color: var(--color-white);
    border-left: 4px solid #059669;
}

.notification--error {
    background: var(--color-error);
    color: var(--color-white);
    border-left: 4px solid #dc2626;
}

.notification--warning {
    background: var(--color-warning);
    color: var(--color-white);
    border-left: 4px solid #d97706;
}

.notification--info {
    background: var(--color-info);
    color: var(--color-white);
    border-left: 4px solid #2563eb;
}

.notification__content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
}

.notification__message {
    flex-grow: 1;
    font-weight: var(--font-weight-medium);
}

.notification__close {
    background: none;
    border: none;
    color: inherit;
    font-size: var(--font-size-xl);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}

.notification__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Модальные окна */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal__content {
    background: var(--color-white);
    border-radius: var(--radius-xl);
    padding: var(--spacing-2xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

.modal.show .modal__content {
    transform: scale(1);
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--color-gray-200);
}

.modal__title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--color-gray-900);
    margin: 0;
}

.modal__close {
    background: none;
    border: none;
    font-size: var(--font-size-2xl);
    color: var(--color-gray-500);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal__close:hover {
    color: var(--color-gray-700);
    background: var(--color-gray-100);
}

.modal__body {
    margin-bottom: var(--spacing-lg);
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-gray-200);
}

/* Карточки */
.card {
    background: var(--color-white);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-gray-200);
    transition: all var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card__header {
    margin-bottom: var(--spacing-lg);
}

.card__title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--color-gray-900);
    margin-bottom: var(--spacing-sm);
}

.card__subtitle {
    color: var(--color-gray-600);
    margin: 0;
}

.card__body {
    margin-bottom: var(--spacing-lg);
}

.card__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-gray-200);
}

/* Бейджи */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge--primary {
    background: var(--color-primary);
    color: var(--color-white);
}

.badge--success {
    background: var(--color-success);
    color: var(--color-white);
}

.badge--warning {
    background: var(--color-warning);
    color: var(--color-white);
}

.badge--error {
    background: var(--color-error);
    color: var(--color-white);
}

.badge--gray {
    background: var(--color-gray-200);
    color: var(--color-gray-700);
}

/* Аватары */
.avatar {
    display: inline-block;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    overflow: hidden;
    background: var(--color-gray-300);
    position: relative;
}

.avatar--large {
    width: 64px;
    height: 64px;
}

.avatar--small {
    width: 32px;
    height: 32px;
}

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

.avatar__initials {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: var(--font-weight-semibold);
    color: var(--color-white);
    background: var(--color-primary);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Прогресс-бары */
.progress {
    width: 100%;
    height: 8px;
    background: var(--color-gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress__bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
    position: relative;
}

.progress__bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.2) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.2) 75%,
        transparent 75%,
        transparent
    );
    background-size: 1rem 1rem;
    animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
    0% {
        background-position: 1rem 0;
    }
    100% {
        background-position: 0 0;
    }
}

/* Спиннеры */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-gray-300);
    border-radius: 50%;
    border-top-color: var(--color-primary);
    animation: spin 1s ease-in-out infinite;
}

.spinner--large {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

.spinner--small {
    width: 16px;
    height: 16px;
    border-width: 1px;
}

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

/* Тултипы */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip__content {
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-gray-900);
    color: var(--color-white);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-md);
    font-size: var(--font-size-xs);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    z-index: var(--z-tooltip);
}

.tooltip__content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--color-gray-900);
}

.tooltip:hover .tooltip__content {
    opacity: 1;
    visibility: visible;
}

/* Дропдауны */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown__toggle {
    background: var(--color-white);
    border: 2px solid var(--color-gray-200);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: all var(--transition-fast);
}

.dropdown__toggle:hover {
    border-color: var(--color-primary);
}

.dropdown__menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
}

.dropdown.active .dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown__item {
    display: block;
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--color-gray-700);
    text-decoration: none;
    transition: all var(--transition-fast);
    border-bottom: 1px solid var(--color-gray-100);
}

.dropdown__item:last-child {
    border-bottom: none;
}

.dropdown__item:hover {
    background: var(--color-gray-50);
    color: var(--color-primary);
}

/* Табы */
.tabs {
    width: 100%;
}

.tabs__nav {
    display: flex;
    border-bottom: 1px solid var(--color-gray-200);
    margin-bottom: var(--spacing-lg);
}

.tabs__button {
    background: none;
    border: none;
    padding: var(--spacing-md) var(--spacing-lg);
    cursor: pointer;
    font-size: var(--font-size-base);
    color: var(--color-gray-600);
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
}

.tabs__button:hover {
    color: var(--color-primary);
}

.tabs__button.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tabs__content {
    display: none;
}

.tabs__content.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

/* Аккордеон */
.accordion {
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.accordion__item {
    border-bottom: 1px solid var(--color-gray-200);
}

.accordion__item:last-child {
    border-bottom: none;
}

.accordion__header {
    background: var(--color-white);
    border: none;
    width: 100%;
    padding: var(--spacing-lg);
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: var(--color-gray-900);
    transition: background-color var(--transition-fast);
}

.accordion__header:hover {
    background: var(--color-gray-50);
}

.accordion__icon {
    transition: transform var(--transition-fast);
}

.accordion__item.active .accordion__icon {
    transform: rotate(180deg);
}

.accordion__content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-normal);
}

.accordion__item.active .accordion__content {
    max-height: 500px;
}

.accordion__body {
    padding: var(--spacing-lg);
    background: var(--color-gray-50);
}

/* Хлебные крошки */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.breadcrumb__item {
    color: var(--color-gray-600);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.breadcrumb__item:hover {
    color: var(--color-primary);
}

.breadcrumb__item.active {
    color: var(--color-gray-900);
    font-weight: var(--font-weight-medium);
}

.breadcrumb__separator {
    color: var(--color-gray-400);
    font-size: var(--font-size-sm);
}

/* Пагинация */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-sm);
    margin: var(--spacing-2xl) 0;
}

.pagination__item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-md);
    color: var(--color-gray-700);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.pagination__item:hover {
    background: var(--color-primary);
    color: var(--color-white);
    border-color: var(--color-primary);
}

.pagination__item.active {
    background: var(--color-primary);
    color: var(--color-white);
    border-color: var(--color-primary);
}

.pagination__item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination__item.disabled:hover {
    background: transparent;
    color: var(--color-gray-700);
    border-color: var(--color-gray-200);
}

/* PWA стили */
.update-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 350px;
    background: var(--color-primary);
    color: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-tooltip);
    opacity: 0;
    transform: translateX(100%);
    transition: all var(--transition-normal);
}

.update-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.update-notification__content {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
}

.update-notification__message {
    flex-grow: 1;
    font-weight: var(--font-weight-medium);
}

.update-notification__button {
    background: var(--color-white);
    color: var(--color-primary);
    border: none;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.update-notification__button:hover {
    background: var(--color-gray-100);
}

.update-notification__close {
    background: none;
    border: none;
    color: var(--color-white);
    font-size: var(--font-size-lg);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}

.update-notification__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.install-app-btn {
    background: var(--color-success);
    color: var(--color-white);
    border: none;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-md);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.install-app-btn:hover {
    background: #059669;
    transform: translateY(-1px);
}

/* Стили для PWA режима */
@media (display-mode: standalone) {
    .header__top {
        padding-top: env(safe-area-inset-top);
    }
    
    .back-to-top {
        bottom: calc(30px + env(safe-area-inset-bottom));
    }
}

/* Адаптивность для компонентов */
@media (max-width: 768px) {
    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .modal__content {
        padding: var(--spacing-lg);
        width: 95%;
    }
    
    .card {
        padding: var(--spacing-lg);
    }
    
    .tabs__nav {
        flex-wrap: wrap;
    }
    
    .tabs__button {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-sm);
    }
    
    .pagination {
        flex-wrap: wrap;
    }
    
    .pagination__item {
        width: 36px;
        height: 36px;
        font-size: var(--font-size-sm);
    }
}

@media (max-width: 480px) {
    .breadcrumb {
        flex-wrap: wrap;
    }
    
    .dropdown__menu {
        left: 0;
        right: 0;
        min-width: auto;
    }
}
