/* ============================================================
   🎨 PLECHO DESIGN SYSTEM — ПОЛНЫЙ ФАРШ
   ============================================================
   Технологии: CSS Custom Properties, CSS Grid, Flexbox,
   Анимации @keyframes, prefers-reduced-motion,
   Bootstrap 5.3 совместимость, mobile-first адаптация.
   ============================================================ */

/* ----- 1. DESIGN TOKENS (переменные) ----- */
:root {
    /* Основная палитра */
    --pl-primary: #2563eb;
    --pl-primary-dark: #1d4ed8;
    --pl-primary-light: #3b82f6;
    --pl-primary-bg: #dbeafe;

    /* Акценты */
    --pl-accent: #f59e0b;
    --pl-accent-light: #fef3c7;
    --pl-success: #16a34a;
    --pl-success-bg: #dcfce7;
    --pl-danger: #dc2626;
    --pl-danger-bg: #fee2e2;

    /* Нейтралы */
    --pl-gray-50: #f8fafc;
    --pl-gray-100: #f1f5f9;
    --pl-gray-200: #e2e8f0;
    --pl-gray-300: #cbd5e1;
    --pl-gray-400: #94a3b8;
    --pl-gray-500: #64748b;
    --pl-gray-600: #475569;
    --pl-gray-700: #334155;
    --pl-gray-800: #1e293b;
    --pl-gray-900: #0f172a;

    /* Поверхности */
    --pl-surface: #ffffff;
    --pl-surface-secondary: #f8fafc;
    --pl-border: #e2e8f0;
    --pl-text-muted: #6c757d;
    --pl-border-color: #e2e8f0;

    /* Типографика */
    --pl-font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --pl-radius: 12px;
    --pl-radius-sm: 8px;
    --pl-radius-lg: 16px;
    --pl-radius-xl: 24px;
    --pl-radius-full: 9999px;

    /* Тени */
    --pl-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --pl-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --pl-shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --pl-shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --pl-shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);

    /* Анимации */
    --pl-transition: 200ms ease;
    --pl-transition-slow: 350ms ease;

    /* Z-индексы */
    --z-toast: 1060;
    --z-bottom-nav: 1050;
    --z-fab: 1040;
}

/* ----- 2. DARK MODE (data-bs-theme="dark") ----- */
[data-bs-theme="dark"] {
    --pl-surface: #1e293b;
    --pl-surface-secondary: #0f172a;
    --pl-border: #334155;
    --pl-text-muted: #94a3b8;
    --pl-border-color: #334155;
    --pl-gray-50: #1e293b;
    --pl-gray-100: #334155;
    --pl-gray-200: #475569;
    --pl-gray-600: #94a3b8;
    --pl-gray-700: #cbd5e1;
    --pl-gray-800: #e2e8f0;
    --pl-gray-900: #f8fafc;
    --pl-shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --pl-shadow: 0 1px 3px rgba(0,0,0,0.4);
    --pl-shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --pl-shadow-lg: 0 10px 15px rgba(0,0,0,0.5);
    --pl-shadow-xl: 0 20px 25px rgba(0,0,0,0.6);
}

[data-bs-theme="dark"] body {
    background: var(--pl-surface-secondary);
    color: var(--pl-gray-800);
}

[data-bs-theme="dark"] .card {
    background: var(--pl-surface);
    border-color: var(--pl-border);
}

[data-bs-theme="dark"] .text-muted {
    color: var(--pl-gray-400) !important;
}

[data-bs-theme="dark"] .bg-light {
    background-color: var(--pl-surface-secondary) !important;
}

[data-bs-theme="dark"] .border-bottom {
    border-color: var(--pl-border) !important;
}

[data-bs-theme="dark"] .navbar.bg-primary {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%) !important;
}

[data-bs-theme="dark"] .dropdown-menu {
    background: var(--pl-surface);
    border-color: var(--pl-border);
}

[data-bs-theme="dark"] .dropdown-item {
    color: var(--pl-gray-800);
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background: var(--pl-gray-100);
}

[data-bs-theme="dark"] .page-link {
    background: var(--pl-surface);
    border-color: var(--pl-border);
    color: var(--pl-gray-700);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background: var(--pl-surface);
    border-color: var(--pl-border);
    color: var(--pl-gray-800);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background: var(--pl-surface);
    color: var(--pl-gray-800);
}

/* ----- 3. GLOBAL RESETS ----- */
body {
    font-family: var(--pl-font);
    background: var(--pl-surface-secondary);
    color: var(--pl-gray-800);
    transition: background var(--pl-transition), color var(--pl-transition);
    padding-bottom: 80px; /* space for mobile bottom nav */
}

.card {
    border-radius: var(--pl-radius);
    border: 1px solid var(--pl-border);
    box-shadow: var(--pl-shadow-sm);
    transition: box-shadow var(--pl-transition), transform var(--pl-transition);
    background: var(--pl-surface);
}

.card:hover {
    box-shadow: var(--pl-shadow-md);
}

/* ----- 4. AVATARS ----- */
.avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--pl-radius-full);
    object-fit: cover;
    background: var(--pl-primary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--pl-primary);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.avatar-sm { width: 36px; height: 36px; font-size: 0.85rem; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.5rem; }
.avatar-xl { width: 120px; height: 120px; font-size: 2.5rem; }

.avatar-online {
    box-shadow: 0 0 0 3px var(--pl-success);
}

/* ----- 5. BADGES ----- */
.badge-status {
    padding: 4px 10px;
    border-radius: var(--pl-radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-open {
    background: var(--pl-primary-bg);
    color: var(--pl-primary);
}

.badge-progress {
    background: var(--pl-accent-light);
    color: #92400e;
}

.badge-done {
    background: var(--pl-success-bg);
    color: var(--pl-success);
}

.badge-canceled {
    background: var(--pl-danger-bg);
    color: var(--pl-danger);
}

/* ----- 6. RATING STARS ----- */
.stars {
    display: inline-flex;
    gap: 2px;
    color: var(--pl-accent);
    font-size: 1rem;
}

.stars-sm { font-size: 0.8rem; }
.stars-lg { font-size: 1.25rem; }

.stars .bi-star-fill { color: var(--pl-accent); }
.stars .bi-star-half { color: var(--pl-accent); }
.stars .bi-star { color: var(--pl-gray-300); }

/* ----- 7. TOASTS ----- */
.toast-container-float {
    position: fixed;
    top: 80px;
    right: 16px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 380px;
}

.toast-custom {
    background: var(--pl-surface);
    border: 1px solid var(--pl-border);
    border-radius: var(--pl-radius);
    box-shadow: var(--pl-shadow-lg);
    padding: 14px 18px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: toastSlideIn 0.35s ease;
    font-size: 0.9rem;
}

.toast-custom.removing {
    animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100px); }
}

/* ----- 8. SKELETON LOADING ----- */
.skeleton {
    background: linear-gradient(90deg, var(--pl-gray-200) 25%, var(--pl-gray-100) 50%, var(--pl-gray-200) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: var(--pl-radius-sm);
}

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

.skeleton-text { height: 16px; margin-bottom: 8px; }
.skeleton-title { height: 24px; width: 60%; margin-bottom: 12px; }
.skeleton-avatar { width: 48px; height: 48px; border-radius: var(--pl-radius-full); }
.skeleton-card { height: 120px; }

/* ----- 9. COUNTER ANIMATION ----- */
@keyframes countUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.stat-number {
    animation: countUp 0.6s ease both;
}

.stat-number:nth-child(1) { animation-delay: 0.1s; }

/* ----- 10. PULSE DOT (live indicator) ----- */
.pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--pl-radius-full);
    background: var(--pl-success);
    display: inline-block;
    position: relative;
}

.pulse-dot::after {
    content: '';
    position: absolute;
    top: -3px; left: -3px;
    width: 16px; height: 16px;
    border-radius: var(--pl-radius-full);
    background: var(--pl-success);
    opacity: 0.4;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%   { transform: scale(1); opacity: 0.4; }
    50%  { transform: scale(2); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

/* ----- 11. MOBILE BOTTOM NAV ----- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--pl-surface);
    border-top: 1px solid var(--pl-border);
    z-index: var(--z-bottom-nav);
    padding: 6px 0 env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

@media (max-width: 767.98px) {
    .bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    body { padding-bottom: 80px; }
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    color: var(--pl-gray-500);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    transition: color var(--pl-transition);
    border-radius: var(--pl-radius);
}

.bottom-nav-item i {
    font-size: 1.3rem;
    transition: transform var(--pl-transition);
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
    color: var(--pl-primary);
}

.bottom-nav-item:active i {
    transform: scale(0.85);
}

.bottom-nav-item .badge-notification {
    position: absolute;
    top: 2px;
    right: -4px;
    width: 8px;
    height: 8px;
    background: var(--pl-danger);
    border-radius: var(--pl-radius-full);
    border: 2px solid var(--pl-surface);
}

/* ----- 12. FLOATING ACTION BUTTON ----- */
.fab {
    display: none;
    position: fixed;
    bottom: 96px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: var(--pl-radius-full);
    background: var(--pl-primary);
    color: #fff;
    font-size: 1.5rem;
    border: none;
    box-shadow: var(--pl-shadow-lg);
    z-index: var(--z-fab);
    cursor: pointer;
    transition: transform var(--pl-transition), box-shadow var(--pl-transition);
    align-items: center;
    justify-content: center;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: var(--pl-shadow-xl);
}

.fab:active {
    transform: scale(0.95);
}

@media (max-width: 767.98px) {
    .fab { display: flex; }
}

/* ----- 13. HERO (расширенный) ----- */
.hero-section {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 40%, #1e40af 100%);
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -15%;
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 70%);
    border-radius: 50%;
}

.hero-section::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255,255,255,0.04) 0%, transparent 70%);
    border-radius: 50%;
}

.hero-decor-circle {
    position: absolute;
    border-radius: var(--pl-radius-full);
    background: rgba(255,255,255,0.06);
    animation: heroFloat 6s ease-in-out infinite;
}

.hero-decor-circle:nth-child(1) { width: 80px; height: 80px; top: 10%; left: 5%; animation-delay: 0s; }
.hero-decor-circle:nth-child(2) { width: 120px; height: 120px; bottom: 20%; right: 25%; animation-delay: 2s; }
.hero-decor-circle:nth-child(3) { width: 50px; height: 50px; top: 50%; right: 10%; animation-delay: 4s; }

@keyframes heroFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-20px); }
}

/* ----- 14. FEATURE ICONS ----- */
.feature-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    transition: transform var(--pl-transition), box-shadow var(--pl-transition);
}

.feature-icon:hover {
    transform: translateY(-3px);
    box-shadow: var(--pl-shadow-md);
}

.feature-icon-blue  { background: #dbeafe; color: #2563eb; }
.feature-icon-green { background: #dcfce7; color: #16a34a; }
.feature-icon-amber { background: #fef3c7; color: #d97706; }
.feature-icon-red   { background: #fee2e2; color: #dc2626; }
.feature-icon-indigo { background: #e0e7ff; color: #4f46e5; }

/* ----- 15. STEP CIRCLES ----- */
.step-circle {
    width: 64px;
    height: 64px;
    border-radius: var(--pl-radius-full);
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    font-size: 1.75rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3);
    transition: transform var(--pl-transition);
    position: relative;
}

.step-circle:hover {
    transform: scale(1.1) rotate(-5deg);
}

.step-connector {
    display: none;
}

@media (min-width: 768px) {
    .step-connector {
        display: block;
        position: absolute;
        top: 32px;
        left: calc(50% + 32px);
        width: calc(100% - 64px);
        height: 2px;
        background: var(--pl-gray-200);
    }
}

/* ----- 16. GLASS CARD ----- */
.glass-card {
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--pl-radius-lg);
}

[data-bs-theme="dark"] .glass-card {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255,255,255,0.1);
}

/* ----- 17. MEDIA QUERIES ----- */
@media (max-width: 768px) {
    .hero-section h1 { font-size: 1.75rem !important; }
    .stat-number { font-size: 1.5rem; }
    .step-circle { width: 52px; height: 52px; font-size: 1.35rem; }
}

@media (max-width: 576px) {
    .hero-section { padding: 2.5rem 0 !important; }
    .hero-section h1 { font-size: 1.5rem !important; }
    .toast-container-float { right: 8px; left: 8px; max-width: none; }
}

/* ----- 18. REDUCED MOTION ----- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ----- 19. PRINT STYLES ----- */
@media print {
    .navbar, .bottom-nav, .fab, .toast-container-float, .btn { display: none !important; }
    body { padding-bottom: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ----- 20. APP POLISH (общий редизайн страниц) ----- */
.page-shell {
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.page-title {
    margin: 0;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.page-subtitle {
    margin: .25rem 0 0;
    color: var(--pl-gray-500);
}

.app-card {
    border: 1px solid var(--pl-border);
    border-radius: var(--pl-radius-lg);
    background: var(--pl-surface);
    box-shadow: var(--pl-shadow-sm);
}

.app-card .card-header {
    border-bottom: 1px solid var(--pl-border);
    background: transparent;
    font-weight: 700;
}

.stat-tile {
    border-radius: var(--pl-radius);
    padding: 1rem;
    border: 1px solid var(--pl-border);
    background: var(--pl-surface);
    box-shadow: var(--pl-shadow-sm);
    height: 100%;
}

.stat-tile .value {
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1;
}

.stat-tile .label {
    margin-top: .35rem;
    color: var(--pl-gray-500);
    font-size: .86rem;
}

.form-shell {
    max-width: 760px;
    margin-inline: auto;
}

.form-shell .card-body {
    padding: 1.5rem;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--pl-gray-500);
}

.empty-state i {
    font-size: 2.25rem;
    color: var(--pl-gray-300);
}

.table-soft thead th {
    border-bottom: 1px solid var(--pl-border);
    color: var(--pl-gray-500);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.table-soft td {
    vertical-align: middle;
}

.btn-pill {
    border-radius: var(--pl-radius-full);
    padding-left: 1rem;
    padding-right: 1rem;
}

[data-bs-theme="dark"] .page-subtitle {
    color: var(--pl-gray-400);
}

[data-bs-theme="dark"] .table-soft thead th {
    color: var(--pl-gray-400);
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-shell {
        padding-top: 1rem;
    }
}

/* ----- 21. FOOTER ----- */
.pl-footer {
    background: var(--pl-surface);
    color: var(--pl-text-muted);
    border-color: var(--pl-border-color) !important;
}

.pl-footer-brand {
    color: var(--pl-text-muted);
    font-weight: 700;
    font-size: 1.125rem;
}

.pl-footer-brand i {
    font-size: 1.25rem;
}

.pl-footer-title {
    color: var(--pl-text-muted);
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.pl-footer-text {
    color: var(--pl-text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.pl-footer-link {
    color: var(--pl-text-muted);
    text-decoration: none;
    display: inline-block;
    padding: 0.2rem 0;
    min-height: 44px;
    line-height: 1.8;
}

.pl-footer-link:hover,
.pl-footer-link:focus,
.pl-footer-brand:hover,
.pl-footer-brand:focus {
    color: var(--pl-primary);
}

.pl-footer-social {
    color: var(--pl-text-muted);
    font-size: 1.25rem;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--pl-border-color);
    border-radius: 50%;
    text-decoration: none;
    transition: all .2s ease;
}

.pl-footer-social:hover,
.pl-footer-social:focus {
    color: var(--pl-primary);
    border-color: var(--pl-primary);
}

.pl-footer-bottom {
    border-color: var(--pl-border-color) !important;
    color: var(--pl-text-muted);
    font-size: 0.9rem;
}

/* ----- 22. JOB CREATE WIZARD ----- */
.wizard-progress {
    height: 12px;
    border-radius: 999px;
    background: var(--pl-gray-100);
}

.wizard-progress .progress-bar {
    transition: width .35s ease;
}

.service-card {
    min-height: 132px;
    border: 2px solid var(--pl-border);
    border-radius: var(--pl-radius);
    padding: 1rem;
    background: var(--pl-surface);
    box-shadow: var(--pl-shadow-sm);
    transition: all var(--pl-transition);
}

.service-card:hover {
    border-color: var(--pl-primary);
    box-shadow: var(--pl-shadow-md);
    transform: translateY(-1px);
}

.service-card:focus-visible {
    outline: 0;
    border-color: var(--pl-primary);
    box-shadow: 0 0 0 .25rem rgba(37,99,235,.2);
}

.service-card.active-card {
    border-color: var(--pl-primary);
    background: rgba(37,99,235,.05);
    box-shadow: 0 0 0 .25rem rgba(37,99,235,.12);
}

.service-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,107,53,.12);
    color: #FF6B35;
    font-size: 1.35rem;
}

.wizard-map {
    height: 250px;
    width: 100%;
    background: var(--pl-gray-100);
}

@media (max-width: 767.98px) {
    .wizard-progress-wrap {
        margin-bottom: 1rem;
    }

    .service-card {
        min-height: 104px;
        padding: .9rem;
    }
}
