/* ========================================
   Market Mega Admin Panel — Modern Clean UI
   ======================================== */
:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --text-muted: #6b7280;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 1px 3px rgba(17, 24, 39, 0.06), 0 1px 2px rgba(17, 24, 39, 0.04);
    --shadow-lg: 0 10px 30px rgba(17, 24, 39, 0.1);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
body { min-height: 100vh; }
.sidebar {
    position: fixed; top: 0; left: 0; width: 260px; height: 100vh;
    background: linear-gradient(180deg, #1e1b4b, #312e81);
    color: #fff; padding: 24px 16px; display: flex; flex-direction: column;
    box-shadow: var(--shadow-lg);
}
.main { margin-left: 260px; padding: 32px 40px; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar-brand {
    display: flex; align-items: center; gap: 12px; padding-bottom: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1); margin-bottom: 20px;
}
.brand-logo {
    width: 44px; height: 44px; border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; letter-spacing: 1px; font-size: 16px;
}
.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; opacity: 0.6; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav a {
    color: rgba(255,255,255,0.75); padding: 10px 14px; border-radius: 10px;
    font-weight: 500; display: flex; align-items: center; gap: 12px;
    transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.sidebar-nav a.active {
    background: rgba(255,255,255,0.12); color: #fff;
    box-shadow: inset 3px 0 0 #8b5cf6;
}
.nav-ic { width: 18px; text-align: center; opacity: 0.9; }

.sidebar-footer { padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: #8b5cf6; display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.user-name { font-weight: 600; font-size: 13px; }
.logout-link { color: rgba(255,255,255,0.6); font-size: 12px; }

/* ===== Page ===== */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 28px; gap: 20px;
}
.page-header h1 { margin: 0; font-size: 24px; font-weight: 700; }
.muted { color: var(--text-muted); margin: 4px 0 0; }

/* ===== Stats ===== */
.stats-grid {
    display: grid; gap: 16px; margin-bottom: 32px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.stat-card {
    background: var(--surface); border-radius: var(--radius-lg); padding: 20px;
    box-shadow: var(--shadow); border-left: 4px solid var(--primary);
    position: relative; overflow: hidden;
}
.stat-value { font-size: 32px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--text-muted); margin-top: 6px; font-size: 13px; }
.stat-blue { border-left-color: #3b82f6; }
.stat-green { border-left-color: #10b981; }
.stat-purple { border-left-color: #8b5cf6; }
.stat-orange { border-left-color: #f59e0b; }
.stat-red { border-left-color: #ef4444; }

/* ===== Quick actions ===== */
.quick-actions {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.action-tile {
    background: var(--surface); border-radius: var(--radius-lg); padding: 20px;
    box-shadow: var(--shadow); color: var(--text) !important;
    display: flex; align-items: flex-start; gap: 14px;
    transition: transform 0.15s, box-shadow 0.15s;
}
.action-tile:hover {
    text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg);
}
.action-ic {
    width: 44px; height: 44px; border-radius: 10px;
    background: var(--primary-soft); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.action-tile strong { display: block; font-size: 15px; }
.action-tile p { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }

/* ===== Cards / Forms ===== */
.card {
    background: var(--surface); border-radius: var(--radius-lg); padding: 20px;
    box-shadow: var(--shadow); margin-bottom: 16px;
}
.card h3 { margin: 0 0 16px; font-size: 16px; }
.hidden { display: none; }

.cards-grid {
    display: grid; gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.form-grid {
    display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr);
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid .btn-row { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.row { flex-direction: row; align-items: center; }
.field span { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.field input, .field select, .field textarea {
    border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px;
    font-size: 14px; font-family: inherit; background: #fff; transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}
.field textarea { resize: vertical; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* ===== Buttons ===== */
.btn-primary, .btn-secondary, .btn-danger {
    border: none; border-radius: 8px; padding: 10px 16px; font-weight: 600;
    cursor: pointer; font-size: 14px; transition: background 0.15s, transform 0.05s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #f3f4f6; color: var(--text); }
.btn-secondary:hover { background: #e5e7eb; }
.btn-danger { background: var(--danger); color: #fff; margin-top: 8px; width: 100%; }
.btn-danger:hover { background: var(--danger-hover); }
button:active { transform: translateY(1px); }

.btn-row { display: flex; gap: 8px; margin-top: 8px; }

/* ===== Category / Product cards ===== */
.cat-image, .prod-image {
    width: 100%; height: 160px; border-radius: var(--radius); overflow: hidden;
    background: #f3f4f6; margin-bottom: 14px;
    display: flex; align-items: center; justify-content: center;
}
.cat-image img, .prod-image img { width: 100%; height: 100%; object-fit: cover; }
.image-placeholder { font-size: 56px; color: #d1d5db; }

/* ===== Orders ===== */
.orders-list { display: flex; flex-direction: column; gap: 16px; }
.order-card { padding: 22px; }
.order-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 16px; margin-bottom: 14px; flex-wrap: wrap;
}
.order-head h3 { margin: 0; font-size: 16px; }
.order-total {
    font-size: 20px; font-weight: 700; color: var(--primary);
    white-space: nowrap;
}
.order-items {
    border-top: 1px solid var(--border); padding-top: 12px; margin-bottom: 12px;
}
.order-item {
    display: grid; grid-template-columns: 1fr auto auto; gap: 16px;
    padding: 6px 0; align-items: center;
}
.order-location {
    padding: 10px 12px; background: var(--primary-soft); border-radius: 8px;
    margin-bottom: 12px; font-size: 13px;
}
.order-location.muted { background: #f9fafb; color: var(--text-muted); }

.order-status-form {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    border-top: 1px solid var(--border); padding-top: 12px;
}

.status-chip {
    padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
    background: #e5e7eb;
}
.status-chip.status-new { background: #dbeafe; color: #1e40af; }
.status-chip.status-confirmed { background: #d1fae5; color: #065f46; }
.status-chip.status-delivered { background: #dcfce7; color: #166534; }
.status-chip.status-canceled { background: #fee2e2; color: #991b1b; }
.status-chip.status-pending_location { background: #fef3c7; color: #92400e; }

.filter-bar select {
    border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
    background: #fff; font-size: 14px;
}

/* ===== Empty state ===== */
.empty-state {
    text-align: center; padding: 60px 20px; color: var(--text-muted);
    background: var(--surface); border-radius: var(--radius-lg);
    grid-column: 1/-1;
}

/* ===== Login ===== */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    padding: 20px;
}
.login-card {
    background: #fff; padding: 40px; border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px;
}
.login-logo {
    width: 60px; height: 60px; border-radius: 16px; margin: 0 auto;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 22px; letter-spacing: 1px;
}
.login-title { margin: 0; text-align: center; font-size: 22px; }
.login-sub { margin: -12px 0 8px; text-align: center; color: var(--text-muted); }
.alert-error {
    background: #fee2e2; color: #991b1b; padding: 10px 14px;
    border-radius: 8px; font-size: 13px;
}

/* ===== Category tiles (Mahsulotlar bo'limining 1-bosqichi) ===== */
.cat-tile {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); padding: 14px 18px;
    display: flex; align-items: center; gap: 12px;
    color: var(--text) !important;
    transition: transform 0.1s, box-shadow 0.15s, border-color 0.15s;
    border-left: 3px solid var(--primary);
}
.cat-tile:hover {
    text-decoration: none; transform: translateX(2px);
    box-shadow: var(--shadow);
}
.cat-tile-body { flex: 1; min-width: 0; }
.cat-tile-name {
    font-weight: 600; font-size: 15px; margin-bottom: 4px;
    display: flex; align-items: center; flex-wrap: wrap;
}
.cat-tile-count {
    display: flex; align-items: center; gap: 6px;
    color: var(--text-muted); font-size: 12px;
}
.count-badge {
    background: var(--primary-soft); color: var(--primary);
    border-radius: 999px; padding: 1px 9px; font-weight: 700; font-size: 11px;
}
.cat-tile-arrow {
    font-size: 22px; color: var(--text-muted); padding-right: 4px;
    line-height: 1; font-weight: 300; opacity: 0.6;
}

/* Breadcrumb */
.breadcrumb { font-size: 13px; margin-bottom: 6px; }
.breadcrumb a {
    color: var(--text-muted); text-decoration: none;
    display: inline-flex; align-items: center; gap: 4px;
}
.breadcrumb a:hover { color: var(--primary); text-decoration: none; }

/* ===== Chat ===== */
.chat-users-list { display: flex; flex-direction: column; gap: 8px; }
.chat-user-row {
    display: flex; align-items: center; gap: 14px; padding: 14px;
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); color: var(--text) !important;
    transition: transform 0.1s;
}
.chat-user-row:hover { text-decoration: none; transform: translateX(2px); }
.chat-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; flex-shrink: 0;
}
.chat-user-info { flex: 1; min-width: 0; }
.chat-user-name { font-weight: 600; }
.chat-user-name .muted { font-weight: 400; margin-left: 6px; font-size: 13px; }
.chat-user-sub { color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.unread-badge {
    background: var(--primary); color: #fff; border-radius: 999px;
    padding: 2px 10px; font-size: 12px; font-weight: 700; min-width: 24px;
    text-align: center;
}

.chat-window {
    background: var(--surface); border-radius: var(--radius-lg); padding: 20px;
    height: calc(100vh - 320px); min-height: 400px; overflow-y: auto;
    box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
    margin-bottom: 16px;
}
.chat-empty { color: var(--text-muted); text-align: center; margin: auto; }
.chat-bubble {
    max-width: 70%; padding: 10px 14px; border-radius: 14px;
    word-wrap: break-word; position: relative; line-height: 1.4;
}
.bubble-user {
    background: #f3f4f6; align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.bubble-admin {
    background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
    align-self: flex-end; border-bottom-right-radius: 4px;
}
.bubble-text { white-space: pre-wrap; }
.bubble-time {
    font-size: 11px; opacity: 0.7; margin-top: 4px; text-align: right;
}

.chat-form {
    display: flex; gap: 10px;
    background: var(--surface); padding: 14px; border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.chat-form input {
    flex: 1; border: 1px solid var(--border); border-radius: 10px;
    padding: 11px 14px; font-size: 14px; font-family: inherit;
}
.chat-form input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .sidebar {
        position: relative; width: 100%; height: auto; padding: 16px;
        flex-direction: row; flex-wrap: wrap;
    }
    .sidebar-brand { margin: 0; border: none; padding: 0 12px 0 0; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; flex: 1; }
    .sidebar-nav a { padding: 8px 12px; }
    .sidebar-footer { width: 100%; padding: 12px 0 0; border-top: 1px solid rgba(255,255,255,0.1); }
    .main { margin-left: 0; padding: 20px; }
    .form-grid { grid-template-columns: 1fr; }
}

/* ===== Users section (dashboard) ===== */
.users-section { margin-top: 36px; }
.section-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px; gap: 16px;
}
.section-head h2 { margin: 0; font-size: 18px; font-weight: 700; }

.table-wrap {
    background: var(--surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); overflow-x: auto;
}
.data-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table thead th {
    text-align: left; font-weight: 600; color: var(--text-muted);
    background: #f9fafb; padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f9fafb; }
.data-table code {
    background: #f3f4f6; padding: 2px 6px; border-radius: 6px;
    font-size: 12px; font-family: ui-monospace, SFMono-Regular, monospace;
}
.data-table a { color: var(--primary); text-decoration: none; }
.data-table a:hover { text-decoration: underline; }
.data-table .small { font-size: 12px; }

.badge {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
}
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-orange { background: #ffedd5; color: #9a3412; }

.btn-mini {
    display: inline-block; padding: 5px 12px; border-radius: 8px;
    background: var(--primary-soft); color: var(--primary) !important;
    font-size: 12px; font-weight: 600;
    text-decoration: none !important;
}
.btn-mini:hover { background: var(--primary); color: #fff !important; }

.empty-state {
    background: var(--surface); border-radius: var(--radius-lg);
    padding: 32px; text-align: center; color: var(--text-muted);
    box-shadow: var(--shadow);
}
