/* ==========================================================================
   SellKaro.io Modern Design System (D1 Foundation)
   ========================================================================== */

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

:root {
    /* Brand & Accent Colors */
    --brand: #0f766e;
    --brand-hover: #115e59;
    --brand-light: #f0fdfa;
    --brand-border: #ccfbf1;
    --brand-ink: #ffffff;

    /* Base Surfaces & Backgrounds */
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-muted: #f1f5f9;
    --surface-subtle: #f8fafc;

    /* Text Colors */
    --text-main: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-disabled: #cbd5e1;

    /* Borders & Lines */
    --border: #e2e8f0;
    --border-subtle: #f1f5f9;
    --border-hover: #cbd5e1;

    /* Feedback & Status Colors */
    --success-bg: #ecfdf5;
    --success-text: #047857;
    --success-border: #a7f3d0;

    --warning-bg: #fffbeb;
    --warning-text: #b45309;
    --warning-border: #fde68a;

    --danger-bg: #fef2f2;
    --danger-text: #b91c1c;
    --danger-border: #fecaca;
    --danger: #dc2626;
    --danger-hover: #b91c1c;

    --info-bg: #eff6ff;
    --info-text: #1d4ed8;
    --info-border: #bfdbfe;

    /* Elevation & Shadows */
    --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--brand);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--brand-hover);
}

/* ==========================================================================
   Application Shell Layout
   ========================================================================== */
.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    transition: transform 0.25s ease;
}

.sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: center;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-main);
    width: 100%;
}

.sidebar-brand-logo {
    height: 72px;
    width: auto;
    display: block;
    margin: 0 auto;
}

.sidebar-brand-text {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.4px;
}

.sidebar-badge {
    margin-left: 0;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    background: var(--brand-light);
    color: var(--brand);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border: 1px solid var(--brand-border);
}

.sidebar-nav-wrap {
    padding: 16px 12px;
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav-heading {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.8px;
    padding: 8px 12px 6px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13.5px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.sidebar-nav-item:hover {
    background: var(--surface-muted);
    color: var(--text-main);
}

.sidebar-nav-item.active {
    background: var(--brand-light);
    color: var(--brand);
    font-weight: 600;
}

.sidebar-nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-width: 2;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-subtle);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.sidebar-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

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

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 7px 12px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-logout:hover {
    background: #fee2e2;
    color: var(--danger);
    border-color: var(--danger-border);
}

/* Content Area */
.main-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    background: var(--bg);
    overflow-x: hidden;
}

.top-navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
    width: 100%;
    max-width: 100%;
}

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

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.mobile-menu-toggle:hover {
    background: var(--surface-muted);
    color: var(--text-main);
}

.breadcrumb {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.breadcrumb-current {
    font-weight: 600;
    color: var(--text-main);
}

.top-navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.content-container {
    padding: 28px;
    max-width: 1320px;
    width: 100%;
    margin: 0 auto;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.6px;
    color: var(--text-main);
    line-height: 1.2;
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 13.5px;
    color: var(--text-secondary);
}

/* ==========================================================================
   Component UI: Buttons, Cards, Badges, Inputs
   ========================================================================== */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13.5px;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-primary, button:not([class]), .button:not([class]) {
    background: var(--brand);
    color: var(--brand-ink);
    border-color: var(--brand);
    box-shadow: var(--shadow-xs);
}

.btn-primary:hover, button:not([class]):hover, .button:not([class]):hover {
    background: var(--brand-hover);
    border-color: var(--brand-hover);
    color: white;
}

.btn-secondary, .button.secondary {
    background: var(--surface);
    color: var(--text-main);
    border-color: var(--border);
    box-shadow: var(--shadow-xs);
}

.btn-secondary:hover, .button.secondary:hover {
    background: var(--surface-muted);
    border-color: var(--border-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--surface-muted);
    color: var(--text-main);
}

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

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

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}

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

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.3px;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 14px 20px;
    background: var(--surface-subtle);
    border-top: 1px solid var(--border-subtle);
}

/* Stat Metrics Grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-sm);
}

.stat-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.stat-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.stat-icon-wrap {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: var(--brand-light);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-number {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.8px;
    line-height: 1.1;
    margin-bottom: 4px;
}

.stat-caption {
    font-size: 12px;
    color: var(--text-muted);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: var(--radius-full);
    line-height: 1.2;
    border: 1px solid transparent;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: var(--success-border);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: var(--warning-border);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: var(--danger-border);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info-text);
    border-color: var(--info-border);
}

.badge-neutral {
    background: var(--surface-muted);
    color: var(--text-secondary);
    border-color: var(--border);
}

/* Flash Messages */
.flash-alert, .flash {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success-text);
}

.flash-alert.error, .flash.error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger-text);
}

/* Form & Input Elements */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-control, input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
    padding: 9px 12px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text-main);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, input:focus, select:focus, textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-checkbox-label, .stack .form-checkbox-label, .stack label.form-checkbox-label {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 9px !important;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
    margin: 0;
}

.form-checkbox-label input[type="checkbox"], .stack .form-checkbox-label input[type="checkbox"], .stack label.form-checkbox-label input[type="checkbox"] {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--brand);
    cursor: pointer;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Table Styling */
.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}

table, .table-modern {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    text-align: left;
    font-size: 13.5px;
}

th {
    background: var(--surface-subtle);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-main);
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: background 0.15s ease;
}

tbody tr:hover {
    background: #fbfcfe;
}

/* Product Row Specifics */
.product-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.product-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    object-fit: cover;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.product-thumb-fallback {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 18px;
    flex-shrink: 0;
}

.product-meta-name {
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2px;
}

.product-meta-sub {
    font-size: 12px;
    color: var(--text-muted);
    font-family: monospace;
}

/* Empty State */
.empty-state {
    padding: 48px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--surface-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
}

.empty-state-text {
    font-size: 13.5px;
    color: var(--text-secondary);
    max-width: 360px;
    margin-bottom: 20px;
}

/* Toolbar */
.toolbar-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-xs);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.toolbar-search-wrap {
    position: relative;
    flex-grow: 1;
    max-width: 360px;
    min-width: 200px;
}

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

.toolbar-search-input {
    padding-left: 36px !important;
}

.toolbar-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Guest & Auth Layouts */
.guest-body {
    min-height: 100vh;
    background: #f8fafc;
}

.login-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(380px, 460px) minmax(0, 1fr);
}

.login-pane {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    background: radial-gradient(circle at 50% 0%, #ecfdf5 0%, #f8fafc 70%);
}

.login-banner {
    min-height: 100vh;
    background: #f4fbf7;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: hidden;
}

.login-banner img {
    width: 100%;
    height: auto;
    max-height: calc(100vh - 48px);
    object-fit: contain;
    object-position: center;
    display: block;
}

.login-back {
    display: block;
    text-align: center;
    margin-bottom: 18px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
}

.login-secure {
    margin-top: 20px;
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.guest-card {
    width: min(440px, 100%);
    background: var(--surface);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px -15px rgba(15, 23, 42, 0.08), 0 0 1px 1px rgba(15, 23, 42, 0.04);
    padding: 38px 34px;
}

.guest-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 6px;
}

.guest-brand img {
    height: 108px;
    width: auto;
    display: block;
    margin: 0 auto;
}

.guest-tagline {
    font-size: 13.5px;
    color: var(--text-muted);
    margin-bottom: 26px;
    font-weight: 500;
    text-align: center;
}

.guest-brand-text {
    font-size: 21px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.guest-card h1 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 22px;
    color: var(--text-main);
    letter-spacing: -0.5px;
    line-height: 1.25;
}

.guest-card .brand {
    font-size: 22px;
    font-weight: 800;
    color: var(--brand);
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.stack label:not(.form-checkbox-label) {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.inline {
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 13px;
    font-weight: 500;
}

.field-error {
    color: var(--danger);
    font-size: 12.5px;
    font-weight: 500;
    margin-top: -4px;
}

/* Mobile Sidebar Drawer Overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 39;
    display: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}
/* Settings Page */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.settings-column {
    display: flex;
    flex-direction: column;
}

.settings-section-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--brand-light);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-form-row {
    display: flex;
    gap: 16px;
}

.settings-readonly-input {
    background: var(--surface-muted) !important;
    color: var(--text-secondary) !important;
    font-family: monospace !important;
    font-size: 12px !important;
    cursor: default;
    border-color: var(--border-subtle) !important;
}

@media (max-width: 980px) {
    .login-layout {
        grid-template-columns: 1fr;
    }

    .login-banner {
        min-height: 0;
        order: -1;
        padding: 16px;
    }

    .login-banner img {
        height: auto;
        max-height: 420px;
    }
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(260px);
    }

    .mobile-menu-toggle {
        display: inline-flex;
    }

    .content-container {
        padding: 16px;
    }

    .top-navbar {
        padding: 12px 16px;
    }

    .toolbar-search-wrap {
        max-width: 100%;
        width: 100%;
    }

    .toolbar-filters {
        width: 100%;
        justify-content: space-between;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .settings-form-row {
        flex-direction: column;
        gap: 0;
    }
}
