@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;700&display=swap');

/* ── CSS Custom Properties ──────────────────────────────── */
:root {
    --primary-gradient:   linear-gradient(135deg, #2563eb, #3b82f6);
    --primary-color:      #2563eb;
    --secondary-color:    #3b82f6;
    --bg-color:           #f8fafc;
    --card-bg:            rgba(255, 255, 255, 0.95);
    --text-main:          #0f172a;
    --text-muted:         #64748b;
    --border-color:       rgba(226, 232, 240, 0.8);
    --glass-shadow:       0 8px 32px 0 rgba(31, 38, 135, 0.07);

    /* Alert status colors */
    --status-loss:        #ef4444;
    --status-commission:  #f59e0b;
    --status-up-price:    #3b82f6;
    --status-battery:     #ef4444;
    --status-promo:       #22c55e;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow-x: hidden;
    line-height: 1.5;
}

/* ── App Layout ─────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid var(--border-color);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 1.25rem;
    margin-bottom: 30px;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-menu { flex: 1; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 14px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    margin-bottom: 8px;
    transition: all 0.25s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    font-family: inherit;
    font-size: 0.95rem;
}

.nav-link:hover, .nav-link.active {
    background: #eff6ff;
    color: var(--primary-color);
}

.nav-link svg { width: 20px; height: 20px; flex-shrink: 0; }

.nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-badge.hidden { display: none; }

/* ── User Info (Bottom of Sidebar) ─────────────────────── */
.user-info {
    padding: 12px;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 16px;
    cursor: pointer;
    transition: 0.2s;
}

.user-info:hover { background: #f8fafc; }

.avatar {
    width: 44px;
    height: 44px;
    background: var(--primary-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.user-details { min-width: 0; }
.user-name  { font-weight: 700; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 0.75rem; color: var(--text-muted); }

/* ── Main Content ───────────────────────────────────────── */
.main-content {
    margin-left: 280px;
    flex: 1;
    padding: 40px;
    min-width: 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title h1 {
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.page-title p { color: var(--text-muted); font-size: 0.875rem; margin-top: 2px; }

/* ── Tab Content ────────────────────────────────────────── */
.tab-content { display: none; }
.tab-content.active {
    display: block;
    animation: fadeIn 0.35s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Stats Grid ─────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--border-color);
}

.stat-header  { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.stat-icon    { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.stat-value   { font-size: 1.5rem; font-weight: 800; }
.stat-label   { color: var(--text-muted); font-size: 0.875rem; font-weight: 500; }

/* ── Alert Badges ───────────────────────────────────────── */
.alert-badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.alert-red    { background: #fee2e2; color: #dc2626; }
.alert-orange { background: #fef3c7; color: #d97706; }
.alert-blue   { background: #dbeafe; color: #2563eb; }
.alert-green  { background: #dcfce7; color: #16a34a; }
.alert-purple { background: #ede9fe; color: #7c3aed; }

/* ── Grid Layouts ───────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
    background: white;
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title.link-title { cursor: pointer; transition: 0.2s; }
.card-title.link-title:hover { color: var(--primary-color); }

/* ── Search Bar ─────────────────────────────────────────── */
.search-bar { position: relative; margin-bottom: 24px; }

.search-input {
    width: 100%;
    padding: 14px 48px;
    border-radius: 14px;
    border: 1.5px solid var(--border-color);
    background: #f1f5f9;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: all 0.25s;
}

.search-input:focus {
    outline: none;
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* ── Data Table ─────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    vertical-align: middle;
}

.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary  { background: var(--primary-color); color: white; }
.btn-primary:hover  { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
.btn-secondary { background: #f1f5f9; color: var(--text-main); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger   { background: #fee2e2; color: #dc2626; }
.btn-danger:hover   { background: #fecaca; }

/* ── Tag Grid ───────────────────────────────────────────── */
.tag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.tag-card {
    background: white;
    border-radius: 18px;
    padding: 16px;
    border: 1px solid var(--border-color);
    transition: all 0.25s;
    cursor: pointer;
}

.tag-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px -8px rgba(0,0,0,0.12);
    border-color: var(--primary-color);
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-backdrop.active { display: flex; }

.modal {
    background: white;
    border-radius: 28px;
    width: 100%;
    max-width: 650px;
    padding: 32px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-xl { max-width: 900px; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.92) translateY(20px); }
    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.2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Info Grid ──────────────────────────────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.info-item   { display: flex; flex-direction: column; gap: 4px; }
.info-label  { font-size: 0.72rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.info-value  { font-weight: 700; font-size: 0.95rem; }

/* ── Pagination ─────────────────────────────────────────── */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 24px; flex-wrap: wrap; }

.page-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1.5px solid var(--border-color);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.page-btn:hover { background: #f1f5f9; border-color: var(--primary-color); }
.page-btn.active { background: var(--primary-color); color: white; border-color: var(--primary-color); }

/* ── Loading Skeleton ───────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 37%, #f0f0f0 63%);
    background-size: 400% 100%;
    animation: skeleton-pulse 1.4s ease infinite;
    border-radius: 8px;
}

@keyframes skeleton-pulse {
    0%   { background-position: 100% 50%; }
    100% { background-position: 0    50%; }
}

/* ── Battery Bar ────────────────────────────────────────── */
.battery-bar {
    width: 60px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

.battery-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ── Alert List ─────────────────────────────────────────── */
.alert-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.alert-list-item:last-child { border-bottom: none; }

/* ── Spinner ────────────────────────────────────────────── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(37,99,235,0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar { width: 240px; }
    .main-content { margin-left: 240px; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 20px; }
    .grid-2 { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
}
