/* ============================================================
   ТРЕЗВЫЙ ВОДИТЕЛЬ — Основные стили + Анимации v2.0
   ============================================================ */

/* --- Базовые стили --- */
body {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: #9ca3af; text-decoration: none; }
a:hover { color: #fff; }

/* ============================================================
   АНИМАЦИИ — Ключевые кадры
   ============================================================ */

/* Плавное появление снизу */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Плавное появление сверху */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Появление слева */
@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Появление справа */
@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Простое появление */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Масштабирование */
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to   { opacity: 1; transform: scale(1); }
}

/* Пульсация */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}

/* Мерцание */
@keyframes shimmer {
    0%   { background-position: -200% center; }
    100% { background-position: 200% center; }
}

/* Вращение (для лоадера) */
@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Подпрыгивание */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

/* Свечение */
@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(249, 115, 22, 0.3); }
    50%      { box-shadow: 0 0 20px rgba(249, 115, 22, 0.6), 0 0 40px rgba(249, 115, 22, 0.2); }
}

/* Плавное подчёркивание */
@keyframes underlineExpand {
    from { width: 0; }
    to   { width: 100%; }
}

/* Волнообразное появление для элементов списка */
@keyframes slideInStagger {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   КЛАССЫ АНИМАЦИЙ
   ============================================================ */

.anim-fade-in      { animation: fadeIn 0.6s ease-out forwards; }
.anim-fade-in-up   { animation: fadeInUp 0.7s ease-out forwards; }
.anim-fade-in-down { animation: fadeInDown 0.6s ease-out forwards; }
.anim-fade-in-left { animation: fadeInLeft 0.6s ease-out forwards; }
.anim-fade-in-right{ animation: fadeInRight 0.6s ease-out forwards; }
.anim-scale-in     { animation: scaleIn 0.5s ease-out forwards; }
.anim-pulse        { animation: pulse 2s ease-in-out infinite; }
.anim-glow         { animation: glow 2s ease-in-out infinite; }
.anim-bounce       { animation: bounce 1.5s ease-in-out infinite; }

/* Задержки для каскадного появления */
.anim-delay-1 { animation-delay: 0.1s; opacity: 0; }
.anim-delay-2 { animation-delay: 0.2s; opacity: 0; }
.anim-delay-3 { animation-delay: 0.3s; opacity: 0; }
.anim-delay-4 { animation-delay: 0.4s; opacity: 0; }
.anim-delay-5 { animation-delay: 0.5s; opacity: 0; }
.anim-delay-6 { animation-delay: 0.6s; opacity: 0; }
.anim-delay-7 { animation-delay: 0.7s; opacity: 0; }
.anim-delay-8 { animation-delay: 0.8s; opacity: 0; }

/* ============================================================
   КНОПКИ — Анимации при наведении
   ============================================================ */

.btn-animated {
    position: relative;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: translateZ(0);
}
.btn-animated:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(249, 115, 22, 0.4);
}
.btn-animated:active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}
/* Блик при наведении */
.btn-animated::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(255,255,255,0.1) 50%,
        transparent 100%
    );
    transform: rotate(45deg) translateX(-100%);
    transition: transform 0.6s ease;
}
.btn-animated:hover::after {
    transform: rotate(45deg) translateX(100%);
}

/* ============================================================
   КАРТОЧКИ — Hover-эффекты
   ============================================================ */

.card-hover {
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: translateZ(0);
}
.card-hover:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(249, 115, 22, 0.15);
    border-color: rgba(249, 115, 22, 0.3) !important;
}

/* Карточка с подсветкой */
.card-glow-hover {
    transition: all 0.4s ease;
    position: relative;
}
.card-glow-hover::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(249,115,22,0), rgba(249,115,22,0));
    z-index: -1;
    transition: background 0.4s ease;
}
.card-glow-hover:hover::before {
    background: linear-gradient(135deg, rgba(249,115,22,0.15), rgba(251,138,70,0.08));
}

/* ============================================================
   ПОЛЯ ВВОДА — Анимации при фокусе
   ============================================================ */

.input-animated {
    transition: all 0.3s ease;
    border: 1px solid rgba(255,255,255,0.1);
}
.input-animated:focus {
    border-color: #f97316 !important;
    box-shadow: 0 0 0 3px rgba(249,115,22,0.15), 0 4px 12px rgba(0,0,0,0.2);
    transform: translateY(-1px);
    outline: none;
}
.input-animated:hover:not(:focus) {
    border-color: rgba(255,255,255,0.2);
}

/* Лейбл, который поднимается при фокусе */
.input-group {
    position: relative;
}
.input-group .floating-label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    transition: all 0.3s ease;
    pointer-events: none;
    font-size: 0.9rem;
}
.input-group input:focus ~ .floating-label,
.input-group input:not(:placeholder-shown) ~ .floating-label {
    top: -8px;
    font-size: 0.7rem;
    color: #f97316;
    background: #0f172a;
    padding: 0 4px;
}

/* ============================================================
   ИНДИКАТОР ЗАГРУЗКИ
   ============================================================ */

.loader {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(249, 115, 22, 0.2);
    border-top-color: #f97316;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loader-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}
.loader-lg {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

/* Полноэкранный оверлей загрузки */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}
.loading-overlay .loader-text {
    color: #9ca3af;
    font-size: 0.9rem;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Скелетон-загрузка для карточек */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 400% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

/* ============================================================
   СТАТУС-БЕЙДЖИ
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    gap: 5px;
    transition: all 0.3s ease;
}
.badge-active {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.2);
}
.badge-inactive {
    background: rgba(251, 146, 60, 0.15);
    color: #fb923c;
    border: 1px solid rgba(251, 146, 60, 0.2);
}
.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s ease-in-out infinite;
}

/* ============================================================
   ПЛАВНЫЕ ПЕРЕХОДЫ НА ВСЕХ ЭЛЕМЕНТАХ
   ============================================================ */

*, *::before, *::after {
    transition-property: color, background-color, border-color, box-shadow, opacity;
    transition-duration: 0.2s;
    transition-timing-function: ease;
}

/* Исключения — элементы с собственными переходами */
.btn-animated, .card-hover, .input-animated, .loader, [class*="anim-"] {
    transition-property: none; /* Управляются своими анимациями */
}

/* ============================================================
   ТАБЛИЦА (для admin.php)
   ============================================================ */

.table-animated tbody tr {
    animation: fadeInUp 0.4s ease-out both;
    transition: background-color 0.2s ease;
}
.table-animated tbody tr:hover {
    background-color: rgba(249, 115, 22, 0.05) !important;
}
/* Каскадная задержка для строк таблицы */
.table-animated tbody tr:nth-child(1)  { animation-delay: 0.05s; }
.table-animated tbody tr:nth-child(2)  { animation-delay: 0.10s; }
.table-animated tbody tr:nth-child(3)  { animation-delay: 0.15s; }
.table-animated tbody tr:nth-child(4)  { animation-delay: 0.20s; }
.table-animated tbody tr:nth-child(5)  { animation-delay: 0.25s; }
.table-animated tbody tr:nth-child(6)  { animation-delay: 0.30s; }
.table-animated tbody tr:nth-child(7)  { animation-delay: 0.35s; }
.table-animated tbody tr:nth-child(8)  { animation-delay: 0.40s; }
.table-animated tbody tr:nth-child(9)  { animation-delay: 0.45s; }
.table-animated tbody tr:nth-child(10) { animation-delay: 0.50s; }

/* ============================================================
   УВЕДОМЛЕНИЯ (toast)
   ============================================================ */

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 22px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 10000;
    animation: fadeInRight 0.4s ease-out, fadeIn 0.3s ease;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.toast-success {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}
.toast-error {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.toast-exit {
    animation: fadeInRight 0.3s ease reverse forwards;
}

/* ============================================================
   КАРТОЧКИ ВОДИТЕЛЕЙ (drivers.php)
   ============================================================ */

.driver-card {
    animation: slideInStagger 0.5s ease-out both;
    transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.driver-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 16px 50px rgba(0,0,0,0.3);
    border-color: rgba(249, 115, 22, 0.25) !important;
}
/* Каскадная задержка */
.driver-card:nth-child(1)  { animation-delay: 0.05s; }
.driver-card:nth-child(2)  { animation-delay: 0.12s; }
.driver-card:nth-child(3)  { animation-delay: 0.19s; }
.driver-card:nth-child(4)  { animation-delay: 0.26s; }
.driver-card:nth-child(5)  { animation-delay: 0.33s; }
.driver-card:nth-child(6)  { animation-delay: 0.40s; }
.driver-card:nth-child(7)  { animation-delay: 0.47s; }
.driver-card:nth-child(8)  { animation-delay: 0.54s; }
.driver-card:nth-child(9)  { animation-delay: 0.61s; }
.driver-card:nth-child(10) { animation-delay: 0.68s; }

/* Фото водителя */
.driver-photo {
    transition: transform 0.4s ease, filter 0.4s ease;
}
.driver-card:hover .driver-photo {
    transform: scale(1.05);
    filter: brightness(1.1);
}

/* ============================================================
   ТАРИФНЫЕ КАРТОЧКИ
   ============================================================ */

.plan-card-animated {
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
}
.plan-card-animated:hover {
    transform: translateY(-8px);
    border-color: var(--accent-start) !important;
    box-shadow: 0 20px 60px rgba(249, 115, 22, 0.15);
}
.plan-card-animated::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(249,115,22,0.04), transparent);
    transition: left 0.7s ease;
}
.plan-card-animated:hover::after {
    left: 100%;
}

/* ============================================================
   АДАПТИВНОСТЬ
   ============================================================ */

@media (max-width: 768px) {
    .anim-fade-in-left,
    .anim-fade-in-right {
        animation-name: fadeInUp; /* На мобильных — всё снизу */
    }
}

/* Уважение к настройкам пользователя */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
