/* =========================================
   Khema Admin Portal Styles
   ========================================= */

:root {
    --admin-sidebar-width: 260px;
    --admin-sidebar-collapsed: 70px;
    --admin-primary: #1a56db;
    --admin-primary-dark: #1342b5;
    --admin-bg: #f1f5f9;
    --admin-sidebar-bg: #f8fafc;
    --admin-sidebar-hover: #eff6ff;
    --admin-sidebar-active: #1a56db;
    --admin-text-muted: #64748b;
    --admin-border: #e2e8f0;
    --admin-card-bg: #ffffff;
    --admin-success: #10b981;
    --admin-warning: #f59e0b;
    --admin-danger: #ef4444;
    --admin-info: #3b82f6;
}

* { box-sizing: border-box; }

body.admin-body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--admin-bg);
    color: #1e293b;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--admin-sidebar-width);
    height: 100vh;
    background: var(--admin-sidebar-bg);
    color: #374151;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.3s ease;
    overflow: hidden;
    border-right: 1px solid var(--admin-border);
}

.admin-sidebar .sidebar-brand {
    display: block;
    padding: 16px 20px;
    border-bottom: 1px solid var(--admin-border);
    text-decoration: none;
}

.admin-sidebar .sidebar-brand img {
    width: 100%;
    height: auto;
    max-height: 56px;
    object-fit: contain;
    display: block;
}


.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.nav-section-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    padding: 14px 10px 5px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    cursor: pointer;
    color: #64748b;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s;
    border-radius: 8px;
    margin-bottom: 2px;
    white-space: nowrap;
}

.sidebar-nav-item:hover {
    background: var(--admin-sidebar-hover);
    color: var(--admin-primary);
}

.sidebar-nav-item.active {
    background: #dbeafe;
    color: var(--admin-primary);
    font-weight: 600;
}

.sidebar-nav-item .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    color: #94a3b8;
    transition: color 0.15s;
}

.sidebar-nav-item:hover .nav-icon,
.sidebar-nav-item.active .nav-icon {
    color: var(--admin-primary);
}

.sidebar-nav-item .nav-badge {
    margin-left: auto;
    background: var(--admin-primary);
    color: white;
    font-size: 0.65rem;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--admin-border);
    background: #f1f5f9;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--admin-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.875rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-name {
    color: #1e293b;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-role {
    color: #94a3b8;
    font-size: 0.7rem;
    white-space: nowrap;
}

.sidebar-logout-btn {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s;
}

.sidebar-logout-btn:hover { color: #ef4444; }

/* ---- Main Content ---- */
.admin-main {
    margin-left: var(--admin-sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* ---- Topbar ---- */
.admin-topbar {
    background: white;
    border-bottom: 1px solid var(--admin-border);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-page-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.topbar-breadcrumb {
    font-size: 0.8rem;
    color: var(--admin-text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-btn {
    background: none;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.8rem;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.topbar-btn:hover {
    background: var(--admin-bg);
    border-color: #cbd5e1;
    color: #1e293b;
}

/* ---- Page Content ---- */
.admin-content {
    flex: 1;
    padding: 28px;
}

/* ---- Stat Cards ---- */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--admin-border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.stat-icon.blue   { background: #eff6ff; color: #1a56db; }
.stat-icon.green  { background: #f0fdf4; color: #10b981; }
.stat-icon.orange { background: #fff7ed; color: #f59e0b; }
.stat-icon.purple { background: #faf5ff; color: #8b5cf6; }
.stat-icon.red    { background: #fef2f2; color: #ef4444; }
.stat-icon.teal   { background: #f0fdfa; color: #14b8a6; }

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--admin-text-muted);
    font-weight: 500;
}

/* ---- Data Tables ---- */
.admin-card {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--admin-border);
    overflow: hidden;
}

.admin-card-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.admin-table thead th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--admin-text-muted);
    border-bottom: 1px solid var(--admin-border);
    white-space: nowrap;
}

.admin-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s;
}

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

.admin-table tbody td {
    padding: 13px 16px;
    vertical-align: middle;
    color: #374151;
}

.admin-table .col-actions {
    white-space: nowrap;
    text-align: right;
}

/* ---- Badges ---- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-badge.active, .status-badge.approved, .status-badge.completed, .status-badge.paid {
    background: #f0fdf4; color: #16a34a;
}
.status-badge.inactive, .status-badge.rejected, .status-badge.cancelled {
    background: #fef2f2; color: #dc2626;
}
.status-badge.pending {
    background: #fffbeb; color: #d97706;
}
.status-badge.closed, .status-badge.draft {
    background: #f1f5f9; color: #64748b;
}
.status-badge.processing {
    background: #eff6ff; color: #1d4ed8;
}

/* ---- Action Buttons ---- */
.btn-action {
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-action:hover { opacity: 0.85; transform: translateY(-1px); }

.btn-action.edit   { background: #eff6ff; color: #1d4ed8; }
.btn-action.delete { background: #fef2f2; color: #dc2626; }
.btn-action.view   { background: #f0fdf4; color: #16a34a; }
.btn-action.approve{ background: #f0fdf4; color: #16a34a; }
.btn-action.reject { background: #fef2f2; color: #dc2626; }
.btn-action.close  { background: #f1f5f9; color: #64748b; }

/* ---- Modal Overrides ---- */
.admin-modal .modal-content {
    border-radius: 14px;
    border: none;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.admin-modal .modal-header {
    background: var(--admin-primary);
    color: white;
    border-radius: 14px 14px 0 0;
    padding: 16px 20px;
}

.admin-modal .modal-title { font-weight: 700; font-size: 1rem; }
.admin-modal .btn-close { filter: brightness(10); }

.admin-modal .modal-body {
    padding: 24px;
    max-height: 65vh;
    overflow-y: auto;
}

.admin-modal .modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--admin-border);
}

/* ---- Forms ---- */
.admin-form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}

.admin-form-control {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 9px 13px;
    font-size: 0.875rem;
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: white;
    color: #1e293b;
}

.admin-form-control:focus {
    outline: none;
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.admin-form-control.is-invalid { border-color: var(--admin-danger); }

/* ---- Search & Filter Bar ---- */
.admin-filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.admin-search {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.admin-search input {
    padding-left: 36px;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    height: 38px;
    font-size: 0.875rem;
    width: 100%;
    background: white;
    color: #1e293b;
}

.admin-search input:focus {
    outline: none;
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.admin-search i {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.85rem;
}

/* ---- Empty State ---- */
.admin-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--admin-text-muted);
}

.admin-empty i { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.admin-empty h4 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; color: #374151; }
.admin-empty p { font-size: 0.875rem; margin: 0; }

/* ---- Loading Spinner ---- */
.admin-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--admin-text-muted);
}

.admin-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--admin-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-bottom: 12px;
}

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

/* ---- Login Page ---- */
.admin-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
}

.admin-login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
}

.admin-login-card .login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 32px;
    text-align: center;
}

.admin-login-card .login-logo img {
    height: 52px;
    border-radius: 10px;
    margin-bottom: 10px;
}

.admin-login-card .login-logo h2 {
    font-size: 1.2rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 2px;
}

.admin-login-card .login-logo p {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0;
}

.admin-login-card .login-badge {
    background: #eff6ff;
    color: var(--admin-primary);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ---- Image Preview ---- */
.img-preview-wrap {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    border: 2px dashed var(--admin-border);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    flex-shrink: 0;
}

.img-preview-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---- Pagination ---- */
.admin-pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 16px 20px;
    border-top: 1px solid var(--admin-border);
    justify-content: space-between;
    flex-wrap: wrap;
}

.admin-pagination .page-info {
    font-size: 0.8rem;
    color: var(--admin-text-muted);
}

.admin-pagination .page-btns { display: flex; gap: 4px; }

.admin-pagination .page-btn {
    border: 1px solid var(--admin-border);
    background: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    color: #374151;
    transition: all 0.1s;
}

.admin-pagination .page-btn:hover { background: var(--admin-bg); }
.admin-pagination .page-btn.active {
    background: var(--admin-primary);
    color: white;
    border-color: var(--admin-primary);
}

/* ---- Alert Toast ---- */
.admin-toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.admin-toast {
    background: white;
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px;
    max-width: 360px;
    pointer-events: all;
    animation: slideInRight 0.3s ease;
    border-left: 4px solid;
}

.admin-toast.success { border-color: var(--admin-success); }
.admin-toast.error   { border-color: var(--admin-danger); }
.admin-toast.warning { border-color: var(--admin-warning); }
.admin-toast.info    { border-color: var(--admin-info); }

.admin-toast .toast-icon { font-size: 1rem; }
.admin-toast.success .toast-icon { color: var(--admin-success); }
.admin-toast.error   .toast-icon { color: var(--admin-danger); }
.admin-toast.warning .toast-icon { color: var(--admin-warning); }
.admin-toast.info    .toast-icon { color: var(--admin-info); }

.admin-toast .toast-msg { font-size: 0.875rem; font-weight: 500; flex: 1; }

.admin-toast .toast-close {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0;
}

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

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }
    .admin-sidebar.open {
        transform: translateX(0);
    }
    .admin-main {
        margin-left: 0;
    }
    .admin-content { padding: 16px; }
    .topbar-page-title { font-size: 1rem; }
}

/* ---- Utility ---- */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fw-600 { font-weight: 600; }
.cursor-pointer { cursor: pointer; }

.btn-admin-primary {
    background: var(--admin-primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 9px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: background 0.15s, transform 0.1s;
}

.btn-admin-primary:hover {
    background: var(--admin-primary-dark);
    transform: translateY(-1px);
}

.btn-admin-secondary {
    background: white;
    color: #374151;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: all 0.15s;
}

.btn-admin-secondary:hover { background: var(--admin-bg); }

.divider { border: none; border-top: 1px solid var(--admin-border); margin: 0; }

.product-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    background: #f1f5f9;
}
