/* ========================================
   RANKPULSE DESIGN SYSTEM
   Единая дизайн-система для всего проекта
   ======================================== */

/* ===== CSS Variables ===== */
:root {
    /* Primary */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;

    /* Secondary */
    --secondary: #10b981;
    --secondary-dark: #059669;
    --secondary-light: #34d399;
    --secondary-50: #ecfdf5;

    /* Accent */
    --accent: #f59e0b;
    --accent-light: #fbbf24;

    /* Status */
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --danger-light: #fca5a5;
    --warning: #f59e0b;
    --warning-light: #fde68a;
    --success: #10b981;
    --info: #3b82f6;
    --info-light: #93c5fd;

    /* Backgrounds */
    --bg-white: #ffffff;
    --bg-light: #f8fafc;
    --bg-soft: #f1f5f9;
    --bg-dark: #0f172a;
    --bg-darker: #1e293b;

    /* Text */
    --text-dark: #0f172a;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --text-white: #ffffff;

    /* Border */
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --border-dark: #cbd5e1;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
    --shadow-2xl: 0 25px 50px -12px rgba(0,0,0,0.25);
    --shadow-primary: 0 4px 14px rgba(99,102,241,0.35);

    /* Radius */
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;

    /* Layout */
    --header-height: 64px;
    --sidebar-width: 260px;
}

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; }
[x-cloak] { display: none !important; }

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700; line-height: 1.3; color: var(--text-dark);
}
h1 { font-size: 2.25rem; font-weight: 800; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
.text-muted { color: var(--text-tertiary); }
.text-secondary-clr { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary-clr { color: var(--primary); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius);
    font-weight: 600; font-size: 0.9rem; border: none;
    cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white; box-shadow: var(--shadow-primary);
}
.btn-primary:hover { box-shadow: var(--shadow-2xl); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-soft); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-outline {
    background: transparent; border: 2px solid var(--primary); color: var(--primary);
}
.btn-outline:hover { background: var(--primary-50); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--text-primary); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; }

/* ===== Cards ===== */
.card {
    background: var(--bg-white); border-radius: var(--radius-xl);
    border: 1px solid var(--border); padding: 24px; transition: var(--transition-slow);
}
.card:hover { box-shadow: var(--shadow-lg); border-color: transparent; }

.card-stat {
    background: var(--bg-white); border-radius: var(--radius-xl); padding: 24px;
    border: 1px solid var(--border); transition: var(--transition-slow);
    position: relative; overflow: hidden;
}
.card-stat::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}
.card-stat:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl); border-color: transparent;
}
.card-stat-success::before { background: linear-gradient(90deg, var(--success), var(--secondary-light)); }
.card-stat-warning::before { background: linear-gradient(90deg, var(--warning), var(--accent-light)); }
.card-stat-danger::before { background: linear-gradient(90deg, var(--danger), var(--danger-light)); }
.card-stat-info::before { background: linear-gradient(90deg, var(--info), var(--info-light)); }

/* ===== Forms ===== */
.form-group { margin-bottom: 20px; }
.form-label {
    display: block; margin-bottom: 8px; font-weight: 600;
    font-size: 0.9rem; color: var(--text-primary);
}
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 10px 14px;
    border: 2px solid var(--border); border-radius: var(--radius);
    font-size: 0.95rem; background: var(--bg-white);
    color: var(--text-primary); transition: var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99,102,241,0.1);
}
.form-input::placeholder { color: var(--text-tertiary); }
.form-textarea { resize: vertical; min-height: 100px; }

/* ===== Tables ===== */
.table-wrapper {
    background: var(--bg-white); border-radius: var(--radius-xl);
    border: 1px solid var(--border); overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; }
.table th {
    background: var(--bg-soft); padding: 14px 18px;
    text-align: left; font-weight: 600; font-size: 0.8rem;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-secondary); border-bottom: 2px solid var(--border);
}
.table td {
    padding: 14px 18px; border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem; color: var(--text-primary);
}
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: var(--bg-soft); }
.table tbody tr:last-child td { border-bottom: none; }

/* ===== Badges ===== */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: var(--radius-full);
    font-size: 0.75rem; font-weight: 600; line-height: 1.5;
}
.badge-primary { background: var(--primary-100); color: var(--primary-dark); }
.badge-success { background: var(--secondary-50); color: var(--secondary-dark); }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-info { background: var(--info-light); color: #1e40af; }
.badge-gray { background: var(--bg-soft); color: var(--text-secondary); }

/* ===== Alerts ===== */
.alert {
    padding: 14px 18px; border-radius: var(--radius-lg);
    margin-bottom: 16px; font-size: 0.9rem;
    display: flex; align-items: flex-start; gap: 10px;
}
.alert-success { background: var(--secondary-50); border: 1px solid var(--success); color: var(--secondary-dark); }
.alert-danger { background: #fef2f2; border: 1px solid var(--danger); color: #991b1b; }
.alert-warning { background: #fffbeb; border: 1px solid var(--warning); color: #92400e; }
.alert-info { background: #eff6ff; border: 1px solid var(--info); color: #1e40af; }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.6);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 3000; padding: 20px;
}
.modal {
    background: var(--bg-white); border-radius: var(--radius-2xl);
    padding: 32px; max-width: 560px; width: 100%;
    max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-2xl);
    animation: modalIn 0.25s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 24px;
}
.modal-title { font-size: 1.25rem; font-weight: 700; }
.modal-close {
    background: var(--bg-soft); border: none;
    width: 36px; height: 36px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; color: var(--text-secondary);
    transition: var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text-primary); }
.modal-body { margin-bottom: 24px; }
.modal-footer {
    display: flex; gap: 12px; justify-content: flex-end;
    padding-top: 20px; border-top: 1px solid var(--border);
}

/* ===== Container & Section ===== */
.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.section { padding: 80px 0; }
.section-header { text-align: center; max-width: 700px; margin: 0 auto 60px; }
.section-badge {
    display: inline-block; padding: 6px 16px;
    background: var(--primary-50); color: var(--primary);
    border-radius: var(--radius-full); font-size: 0.8rem;
    font-weight: 600; margin-bottom: 16px;
}
.section-title { font-size: 2.5rem; font-weight: 800; margin-bottom: 16px; }
.section-subtitle { font-size: 1.1rem; color: var(--text-secondary); }
.page-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 32px; flex-wrap: wrap; gap: 16px;
}
.page-title { font-size: 1.75rem; font-weight: 700; }

/* ===== Flex Utilities ===== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.fade-in { animation: fadeIn 0.4s ease-out; }
.slide-in { animation: slideIn 0.3s ease-out; }
.loading-spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.6s linear infinite;
    display: inline-block;
}
