/* === RAPIDGRAM THEME v3.0 === */

:root {
    --rg-primary: #4f46e5;
    --rg-primary-dark: #4338ca;
    --rg-success: #10b981;
    --rg-danger: #ef4444;
    --rg-warning: #f59e0b;
    --rg-info: #3b82f6;
    --rg-bg: #f8fafc;
    --rg-card-bg: #ffffff;
    --rg-text: #1e293b;
    --rg-text-muted: #64748b;
    --rg-border: #e2e8f0;
    --rg-radius: 12px;
    --rg-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

html, body {
    background: var(--rg-bg);
    color: var(--rg-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow-x: hidden;
    max-width: 100vw;
}

/* === CARDS === */
.rg-card {
    background: var(--rg-card-bg);
    border-radius: var(--rg-radius);
    box-shadow: var(--rg-shadow);
    border: 1px solid var(--rg-border);
    margin-bottom: 1rem;
    max-width: 100%;
    word-wrap: break-word;
}

.rg-card .card-body {
    padding: 1.25rem;
}

.rg-card.bg-light {
    background: #f1f5f9 !important;
}

.rg-card.border-left-info {
    border-left: 4px solid var(--rg-info);
}

/* === TABLE === */
.table {
    font-size: 0.9rem;
}

.table th {
    font-weight: 600;
    color: var(--rg-text-muted);
    border-bottom: 2px solid var(--rg-border);
    padding: 0.75rem;
    white-space: nowrap;
}

.table td {
    padding: 0.75rem;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: #f8fafc;
}

/* === BADGES === */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: 6px;
}

.badge.bg-success { background: var(--rg-success) !important; }
.badge.bg-info { background: var(--rg-info) !important; }
.badge.bg-danger { background: var(--rg-danger) !important; }
.badge.bg-warning { background: var(--rg-warning) !important; }

/* === BUTTONS === */
.btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--rg-primary);
    border-color: var(--rg-primary);
}

.btn-primary:hover {
    background: var(--rg-primary-dark);
    border-color: var(--rg-primary-dark);
}

.btn-success {
    background: var(--rg-success);
    border-color: var(--rg-success);
}

.btn-danger {
    background: var(--rg-danger);
    border-color: var(--rg-danger);
}

.btn-outline-primary {
    color: var(--rg-primary);
    border-color: var(--rg-primary);
}

.btn-outline-primary:hover {
    background: var(--rg-primary);
    color: white;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
}

/* === FORM === */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--rg-border);
    padding: 0.625rem 0.875rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--rg-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-check-input:checked {
    background-color: var(--rg-primary);
    border-color: var(--rg-primary);
}

/* === DROP ZONE === */
.drop-zone {
    border: 2px dashed var(--rg-border);
    border-radius: var(--rg-radius);
    background: #fafafa;
    transition: all 0.2s;
    cursor: pointer;
}

.drop-zone:hover, .drop-zone.bg-light {
    border-color: var(--rg-primary);
    background: #eef2ff;
}

/* === PROGRESS === */
.progress {
    height: 8px;
    border-radius: 4px;
    background: #e2e8f0;
}

.progress-bar {
    background: var(--rg-primary);
    border-radius: 4px;
}

/* === NAV TABS === */
.nav-tabs {
    border-bottom: 2px solid var(--rg-border);
    gap: 0.25rem;
}

.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--rg-text-muted);
    font-weight: 500;
    padding: 0.75rem 1rem;
    border-radius: 8px 8px 0 0;
}

.nav-tabs .nav-link.active {
    color: var(--rg-primary);
    border-bottom-color: var(--rg-primary);
    background: rgba(79, 70, 229, 0.05);
}

/* === TOAST === */
.toast-container {
    z-index: 1055;
}

.toast {
    border-radius: var(--rg-radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: none;
}

.toast-header {
    background: var(--rg-card-bg);
    border-bottom: 1px solid var(--rg-border);
    border-radius: var(--rg-radius) var(--rg-radius) 0 0;
}

/* === MOBILE === */
@media (max-width: 768px) {
    .rg-card .card-body {
        padding: 1rem;
    }
    
    .table-responsive {
        border-radius: var(--rg-radius);
    }
    
    .nav-tabs .nav-link {
        font-size: 0.8rem;
        padding: 0.5rem 0.5rem;
    }
    
    .btn {
        padding: 0.5rem 0.75rem;
    }
}

/* === STAT ICON === */
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.bg-cyan-soft {
    background: rgba(59, 130, 246, 0.1);
    color: var(--rg-info);
}

/* === DROPDOWN === */
.dropdown-menu {
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border: 1px solid var(--rg-border);
}

.dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: #f8fafc;
}

/* === ALERTS === */
.alert {
    border-radius: var(--rg-radius);
    border: none;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: #1e40af;
}

/* === PAGE TITLE === */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

/* === MOBILE FIX === */
html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    touch-action: pan-y !important;
}

.page-body {
    overflow-x: hidden !important;
}

.container-xl {
    max-width: 100% !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}

.row {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.col-12, [class*="col-md"], [class*="col-lg"] {
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
}

.rg-card, .card {
    max-width: 100% !important;
    word-wrap: break-word !important;
}

.table-responsive {
    overflow-x: auto !important;
    max-width: 100% !important;
}

/* === ВКЛАДКИ НЕ ЕЗДЯТ === */
@media (max-width: 991.98px) {
    .nav-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: hidden !important;
        overflow-y: hidden !important;
        touch-action: none !important;
        -webkit-overflow-scrolling: auto !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
        width: 100% !important;
        justify-content: space-between !important;
    }
    .nav-tabs .nav-item {
        flex: 1 1 auto !important;
        text-align: center !important;
    }
    .nav-tabs .nav-link {
        white-space: nowrap !important;
        font-size: 0.75rem !important;
        padding: 0.5rem 0.25rem !important;
    }
}

/* === DARK THEME FIXES === */
[data-theme="dark"] .rg-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .table-hover tbody tr:hover {
    background: #334155;
}

[data-theme="dark"] .text-muted {
    color: #94a3b8 !important;
}

[data-theme="dark"] .badge,
[data-theme="dark"] .badge.bg-success,
[data-theme="dark"] .badge.bg-info,
[data-theme="dark"] .badge.bg-primary,
[data-theme="dark"] .badge.bg-danger,
[data-theme="dark"] .badge.bg-warning,
[data-theme="dark"] .badge.bg-secondary {
    color: #ffffff !important;
}

[data-theme="dark"] .dropdown-menu {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .dropdown-item {
    color: #e2e8f0;
}

[data-theme="dark"] .dropdown-item:hover {
    background: #334155;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .nav-tabs {
    border-bottom-color: #334155;
}

[data-theme="dark"] .nav-tabs .nav-link {
    color: #94a3b8;
}

[data-theme="dark"] .nav-tabs .nav-link.active {
    color: #818cf8;
    border-bottom-color: #818cf8;
    background: rgba(129, 140, 248, 0.1);
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.rg-card {
    animation: fadeIn 0.3s ease-out;
}

/* === BULK ACTIONS PANEL === */
#bulkActionsPanel {
    animation: fadeIn 0.2s ease-out;
}

/* === DARK THEME FIX: drop-zone and cards === */
[data-theme="dark"] .drop-zone {
    background: #1e293b !important;
    border-color: #475569 !important;
}

[data-theme="dark"] .drop-zone:hover,
[data-theme="dark"] .drop-zone.bg-light {
    background: #334155 !important;
    border-color: #818cf8 !important;
}

[data-theme="dark"] .rg-card {
    background: #1e293b !important;
    border-color: #334155 !important;
}

[data-theme="dark"] .rg-card.bg-light {
    background: #0f172a !important;
    border-color: #334155 !important;
}

[data-theme="dark"] .form-select,
[data-theme="dark"] .form-control {
    background: #1e293b !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .btn-outline-primary {
    color: #818cf8 !important;
    border-color: #818cf8 !important;
}

[data-theme="dark"] .btn-outline-primary:hover {
    background: #818cf8 !important;
    color: #ffffff !important;
}

[data-theme="dark"] .progress {
    background: #334155 !important;
}

[data-theme="dark"] .alert-info {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #93c5fd !important;
    border-color: #3b82f6 !important;
}

[data-theme="dark"] .text-muted {
    color: #94a3b8 !important;
}

[data-theme="dark"] .fa-cloud-arrow-up,
[data-theme="dark"] .fa-folder-open {
    color: #64748b !important;
}

/* === DARK THEME: page background === */
[data-theme="dark"] body,
[data-theme="dark"] html,
[data-theme="dark"] .page-body,
[data-theme="dark"] #app,
[data-theme="dark"] .page-wrapper,
[data-theme="dark"] .page-content,
[data-theme="dark"] .container,
[data-theme="dark"] .container-xl,
[data-theme="dark"] .container-fluid {
    background: #0f172a !important;
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .main-content,
[data-theme="dark"] .content-wrapper,
[data-theme="dark"] .content,
[data-theme="dark"] .layout-page,
[data-theme="dark"] .wrapper {
    background: #0f172a !important;
    background-color: #0f172a !important;
}

/* Убираем белые полосы по краям */
[data-theme="dark"] .row {
    background: transparent !important;
}

[data-theme="dark"] .col-12,
[data-theme="dark"] [class*="col-md"],
[data-theme="dark"] [class*="col-lg"] {
    background: transparent !important;
}

/* === DARK THEME: ALL backgrounds === */
[data-theme="dark"] body,
[data-theme="dark"] html,
[data-theme="dark"] .page-body,
[data-theme="dark"] .page-wrapper,
[data-theme="dark"] .page-content,
[data-theme="dark"] .container,
[data-theme="dark"] .container-xl,
[data-theme="dark"] .container-fluid,
[data-theme="dark"] .main-content,
[data-theme="dark"] .content-wrapper,
[data-theme="dark"] .content,
[data-theme="dark"] .layout-page,
[data-theme="dark"] .layout-wrapper,
[data-theme="dark"] .wrapper,
[data-theme="dark"] #app,
[data-theme="dark"] .app,
[data-theme="dark"] .app-wrapper,
[data-theme="dark"] .app-content,
[data-theme="dark"] .dashboard,
[data-theme="dark"] .dashboard-content,
[data-theme="dark"] .nk-body,
[data-theme="dark"] .nk-wrapper,
[data-theme="dark"] .nk-content,
[data-theme="dark"] .client-body,
[data-theme="dark"] .client-wrapper,
[data-theme="dark"] .client-content,
[data-theme="dark"] .tab-content,
[data-theme="dark"] .tab-pane,
[data-theme="dark"] .fade,
[data-theme="dark"] .show,
[data-theme="dark"] .active,
[data-theme="dark"] .row,
[data-theme="dark"] .col,
[data-theme="dark"] .col-12,
[data-theme="dark"] [class*="col-"] {
    background: #0f172a !important;
    background-color: #0f172a !important;
}

/* Убираем белые полосы */
[data-theme="dark"] .page-body::before,
[data-theme="dark"] .page-body::after,
[data-theme="dark"] .content-wrapper::before,
[data-theme="dark"] .content-wrapper::after {
    background: #0f172a !important;
}

/* Фикс для flex-контейнеров */
[data-theme="dark"] .d-flex,
[data-theme="dark"] .justify-content-center,
[data-theme="dark"] .align-items-center {
    background: transparent !important;
}
