/**
 * SHADCN UI - КОМПОНЕНТЫ
 * Адаптировано для Telegram Mini App
 * Оригинал: https://ui.shadcn.com/
 */

/* ============================================
   1. BUTTON (КНОПКА)
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid transparent; /* Прозрачный border по умолчанию для предотвращения смещения */
    padding: 0.5rem 1rem;
    height: 44px; /* Фиксированная высота вместо min-height для предотвращения смещения */
    gap: 0.5rem;
    box-sizing: border-box; /* Учитываем border в общей высоте */
    margin: 0; /* Убираем все отступы для предотвращения смещения */
    vertical-align: middle; /* Выравнивание по вертикали */
}

.btn:disabled {
    pointer-events: none;
    opacity: 0.5;
}

.btn:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

/* Primary (основная кнопка) - оригинальный Shadcn стиль */
.btn-primary {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: 1px solid transparent; /* Прозрачный border для предотвращения "прыгания" при переключении с btn-outline */
}

.btn-primary:hover {
    background-color: hsl(var(--primary) / 0.9);
}

.btn-primary:active {
    background-color: hsl(var(--primary) / 0.8);
}

/* Убеждаемся, что SVG иконки в кнопках наследуют цвет */
.btn-primary svg,
.btn-primary .status-icon-wrapper svg,
.btn-ghost svg,
.btn svg {
    stroke: currentColor;
    fill: none;
    color: inherit;
}

/* Убеждаемся, что все SVG иконки в контейнерах с text-primary наследуют цвет */
.text-primary svg,
[class*="text-primary"] svg,
.bg-primary\/10 svg {
    stroke: currentColor;
    fill: none;
    color: inherit;
}

/* Secondary (вторичная кнопка) - оригинальный Shadcn стиль */
.btn-secondary {
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border: 1px solid hsl(var(--input));
}

.btn-secondary:hover {
    background-color: hsl(var(--secondary) / 0.8);
}

.btn-secondary:active {
    opacity: 0.8;
    transform: scale(0.98);
}

/* Destructive (деструктивная кнопка - удаление) */
.btn-destructive {
    background-color: var(--destructive);
    color: var(--destructive-foreground);
}

.btn-destructive:hover {
    opacity: 0.9;
}

.btn-destructive:active {
    opacity: 0.8;
    transform: scale(0.98);
}

/* Outline (контурная кнопка) */
.btn-outline {
    border: 1px solid var(--border);
    background-color: transparent;
    color: var(--foreground);
    box-sizing: border-box; /* Учитываем border в общей высоте */
}

.btn-outline:hover {
    background-color: var(--accent);
    color: var(--accent-foreground);
}

.btn-outline:active {
    opacity: 0.8;
    transform: scale(0.98);
}

/* Ghost (прозрачная кнопка) */
.btn-ghost {
    background-color: transparent;
    color: hsl(var(--foreground));
}

.btn-ghost:hover {
    background-color: hsl(var(--accent) / 0.5);
    color: hsl(var(--primary));
}

.btn-ghost:active {
    opacity: 0.8;
}

/* Убеждаемся, что иконки в btn-ghost наследуют цвет */
.btn-ghost svg {
    stroke: currentColor;
    fill: none;
    color: inherit;
}

/* Link (ссылка-кнопка) */
.btn-link {
    background-color: transparent;
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.btn-link:hover {
    color: var(--primary);
    opacity: 0.8;
}

/* Размеры */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 12px;
    min-height: 36px;
}

.btn-lg {
    padding: 0.625rem 1.25rem;
    font-size: 16px;
    min-height: 48px;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--radius);
}

/* Полная ширина */
.btn-block {
    width: 100%;
}

/* Иконки статуса в карточках категорий */
.status-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.status-icon-wrapper svg {
    stroke: currentColor;
    fill: none;
    width: 20px;
    height: 20px;
    color: inherit;
}

/* ============================================
   2. CARD (КАРТОЧКА)
   ============================================ */

.card {
    border-radius: calc(var(--radius) - 2px); /* Оригинальный Shadcn */
    border: 1px solid hsl(var(--border));
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); /* Оригинальная тень Shadcn */
    transition: all 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    flex-direction: column;
    space-y: 1rem;
    padding: 1rem;
    padding-bottom: 0;
}

.card-title {
    font-size: 1.125rem; /* 18px вместо 24px - более компактно */
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.025em;
    color: var(--foreground);
    margin: 0;
}

.card-description {
    font-size: 0.75rem; /* 12px - уменьшено, т.к. часто дублируется */
    color: var(--muted-foreground);
    margin-top: 0.25rem;
}

.card-content {
    padding: 1rem; /* 16px вместо 24px - более компактно */
}

.card-footer {
    display: flex;
    align-items: center;
    padding: 1rem; /* 16px вместо 24px */
    padding-top: 0;
}

/* ============================================
   3. INPUT (ПОЛЕ ВВОДА)
   ============================================ */

.input {
    display: flex;
    height: 40px; /* h-10 в Shadcn */
    width: 100%;
    border-radius: calc(var(--radius) - 2px); /* Оригинальный Shadcn */
    border: 1px solid hsl(var(--input));
    background-color: hsl(var(--background));
    padding: 8px 12px; /* px-3 py-2 в Tailwind */
    font-size: 14px; /* text-sm */
    transition: all 0.2s;
    color: hsl(var(--foreground));
}

.input::placeholder {
    color: hsl(var(--muted-foreground));
}

.input:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2); /* Оригинальный Shadcn */
}

.input:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.input-error {
    border-color: var(--destructive);
}

.input-error:focus {
    border-color: var(--destructive);
    box-shadow: 0 0 0 2px rgba(var(--destructive), 0.2);
}

/* Label для input */
.label {
    font-size: 14px;
    font-weight: 500;
    color: var(--foreground);
    margin-bottom: 0.5rem;
    display: block;
}

.label-required::after {
    content: " *";
    color: var(--destructive);
}

/* ============================================
   4. BADGE (ЗНАЧОК)
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    padding: 0.125rem 0.625rem;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.badge-default {
    background-color: var(--primary);
    color: var(--primary-foreground);
}

.badge-secondary {
    background-color: var(--secondary);
    color: var(--secondary-foreground);
}

.badge-destructive {
    background-color: var(--destructive);
    color: var(--destructive-foreground);
}

.badge-outline {
    border-color: var(--border);
    color: var(--foreground);
}

/* ============================================
   5. DIALOG (МОДАЛЬНОЕ ОКНО)
   ============================================ */

.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background-color: rgba(0, 0, 0, 0.5);
    animation: overlay-show 150ms cubic-bezier(0.16, 1, 0.3, 1);
}

.dialog-content {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 50;
    display: flex;
    max-height: 85vh;
    width: 90%;
    max-width: 450px;
    transform: translate(-50%, -50%);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--background);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    animation: content-show 150ms cubic-bezier(0.16, 1, 0.3, 1);
}

.dialog-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
}

.dialog-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--foreground);
    margin: 0;
}

.dialog-description {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin-top: 0.5rem;
}

.dialog-footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.dialog-close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    border-radius: var(--radius);
    opacity: 0.7;
    transition: opacity 0.2s;
    cursor: pointer;
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--foreground);
}

.dialog-close:hover {
    opacity: 1;
}

@keyframes overlay-show {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes content-show {
    from {
        opacity: 0;
        transform: translate(-50%, -48%) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ============================================
   6. SHEET (НИЖНЯЯ ПАНЕЛЬ)
   ============================================ */

.sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background-color: rgba(0, 0, 0, 0.5);
    animation: overlay-show 150ms;
}

.sheet-content {
    position: fixed;
    z-index: 50;
    gap: 1rem;
    border: 1px solid var(--border);
    background-color: var(--background);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    animation: sheet-show 200ms;
}

.sheet-content-bottom {
    bottom: 0;
    left: 0;
    right: 0;
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
    border-bottom: none;
    max-height: 85vh;
    overflow-y: auto;
}

.sheet-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
}

.sheet-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--foreground);
    margin: 0;
}

.sheet-description {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin-top: 0.5rem;
}

.sheet-footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

@keyframes sheet-show {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* ============================================
   7. PROGRESS (ПРОГРЕСС-БАР)
   ============================================ */

.progress {
    position: relative;
    height: 8px;
    width: 100%;
    overflow: hidden;
    border-radius: 9999px;
    background-color: hsl(var(--secondary));
}

.progress-bar {
    width: 100%;
    height: 100%;
    background-color: hsl(var(--primary));
    transition: width 0.3s ease;
}

.progress-bar-success {
    background-color: #4CAF50;
}

.progress-bar-warning {
    background-color: #FF9800;
}

.progress-bar-danger {
    background-color: var(--destructive);
}

/* ============================================
   8. ALERT (ПРЕДУПРЕЖДЕНИЕ)
   ============================================ */

.alert {
    position: relative;
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1rem;
    background-color: var(--background);
}

.alert-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 0.25rem;
}

.alert-description {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.alert-destructive {
    border-color: var(--destructive);
    background-color: rgba(var(--destructive), 0.1);
}

.alert-destructive .alert-title {
    color: var(--destructive);
}

/* ============================================
   9. TOAST (УВЕДОМЛЕНИЕ)
   ============================================ */

.toast {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 100;
    display: flex;
    min-width: 300px;
    max-width: 90%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--background);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    animation: toast-show 200ms;
}

.toast-success {
    border-left: 4px solid #4CAF50;
}

.toast-error {
    border-left: 4px solid var(--destructive);
}

.toast-info {
    border-left: 4px solid var(--primary);
}

@keyframes toast-show {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   10. АДАПТИВНОСТЬ
   ============================================ */

@media (max-width: 480px) {
    .dialog-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .sheet-content {
        max-height: 90vh;
    }
    
    .toast {
        right: 0.5rem;
        left: 0.5rem;
        min-width: auto;
    }
}
