/**
 * StockPilot Pro - Commercial ERP Design System CSS
 */

:root {
    --sp-primary: #2563eb;
    --sp-primary-hover: #1d4ed8;
    --sp-primary-light: #eff6ff;
    --sp-sidebar-bg: #203f30;
    --sp-sidebar-hover: #294738;
    --sp-sidebar-active: #314e40;
    --sp-sidebar-text: #ffffff;
    --sp-sidebar-text-active: #ffffff;
    --sp-body-bg: #f8fafc;
    --sp-card-bg: #ffffff;
    --sp-border-color: #e2e8f0;
    --sp-text-main: #1e293b;
    --sp-text-muted: #64748b;
    --sp-success: #10b981;
    --sp-warning: #f59e0b;
    --sp-danger: #ef4444;
    --sp-info: #06b6d4;
    --sp-font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    font-family: var(--sp-font-sans);
    background-color: var(--sp-body-bg);
    color: var(--sp-text-main);
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

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

/* Sidebar */
.app-sidebar {
    width: 260px;
    background-color: var(--sp-sidebar-bg);
    color: var(--sp-sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: all 0.25s ease;
    z-index: 1000;
}

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.025em;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.1rem;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 0.75rem;
}

.nav-section-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.6);
    padding: 0.75rem 0.75rem 0.35rem 0.75rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem 0.85rem;
    color: var(--sp-sidebar-text);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.15s ease;
    margin-bottom: 2px;
}

.sidebar-link span {
    color: #ffffff;
}

.sidebar-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    color: #ffffff;
    transition: color 0.15s ease;
}

.sidebar-link:hover {
    color: #ffffff;
    background-color: var(--sp-sidebar-hover);
}

.sidebar-link:hover i,
.sidebar-link:hover span {
    color: #ffffff;
}

.sidebar-link.active {
    color: #ffffff;
    background-color: var(--sp-sidebar-active);
    font-weight: 600;
}

.sidebar-link.active i,
.sidebar-link.active span {
    color: #ffffff;
}

.sidebar-link .badge {
    margin-left: auto;
    font-size: 0.72rem;
}

/* Main Content Area */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Top Navbar */
.app-navbar {
    height: 70px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--sp-border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 99;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--sp-text-muted);
    font-size: 1.15rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 6px;
}

.sidebar-toggle-btn:hover {
    background-color: #f1f5f9;
    color: var(--sp-text-main);
}

.global-search {
    position: relative;
    width: 320px;
}

.global-search input {
    width: 100%;
    padding: 0.45rem 0.85rem 0.45rem 2.2rem;
    font-size: 0.88rem;
    border: 1px solid var(--sp-border-color);
    border-radius: 6px;
    background-color: #f8fafc;
    transition: all 0.15s ease;
}

.global-search input:focus {
    outline: none;
    border-color: var(--sp-primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

.navbar-right {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.nav-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 6px;
    text-decoration: none;
}

.pos-btn {
    background-color: #203f30;
    color: #ffffff;
    font-weight: 600;
    border: none;
    box-shadow: 0 2px 4px rgba(32, 63, 48, 0.2);
}

.pos-btn:hover {
    background-color: #294738;
    color: #ffffff;
}

/* User Menu & Notification */
.nav-icon-btn {
    position: relative;
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.1rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
}

.nav-icon-btn:hover {
    background-color: #f1f5f9;
    color: var(--sp-text-main);
}

.nav-icon-btn .badge-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background-color: var(--sp-danger);
    border-radius: 50%;
    border: 2px solid #ffffff;
}

.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
}

.user-profile-btn:hover {
    background-color: #f1f5f9;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background-color: var(--sp-primary-light);
    color: var(--sp-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
}

.user-info {
    text-align: left;
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--sp-text-main);
    line-height: 1.2;
}

.user-role {
    font-size: 0.72rem;
    color: var(--sp-text-muted);
}

/* Content Container */
.app-content {
    flex: 1;
    padding: 1.75rem;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--sp-text-main);
    margin: 0;
}

.breadcrumb {
    margin-bottom: 0;
    font-size: 0.8rem;
}

.breadcrumb-item a {
    color: var(--sp-text-muted);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--sp-primary);
}

/* Cards & Surfaces */
.card {
    background-color: var(--sp-card-bg);
    border: 1px solid var(--sp-border-color);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--sp-border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 1.25rem;
}

/* Stat KPI Cards */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.35rem 1.25rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.stat-icon.primary { background-color: var(--sp-primary-light); color: var(--sp-primary); }
.stat-icon.success { background-color: #ecfdf5; color: var(--sp-success); }
.stat-icon.warning { background-color: #fffbeb; color: var(--sp-warning); }
.stat-icon.danger { background-color: #fef2f2; color: var(--sp-danger); }
.stat-icon.info { background-color: #ecfeff; color: var(--sp-info); }

.stat-value {
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--sp-text-main);
}

.stat-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--sp-text-muted);
    margin-bottom: 2px;
}

/* Tables */
.table {
    margin-bottom: 0;
    font-size: 0.88rem;
    vertical-align: middle;
}

.table th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--sp-border-color);
}

.table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--sp-border-color);
}

.table-hover tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.badge-status {
    padding: 0.35em 0.75em;
    font-weight: 600;
    font-size: 0.75rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-status.active,
.badge-status.completed,
.badge-status.paid,
.badge-status.received {
    background-color: #ecfdf5;
    color: #065f46;
}

.badge-status.partial,
.badge-status.pending,
.badge-status.in_transit {
    background-color: #fffbeb;
    color: #92400e;
}

.badge-status.draft {
    background-color: #f1f5f9;
    color: #475569;
}

.badge-status.cancelled,
.badge-status.unpaid,
.badge-status.inactive {
    background-color: #fef2f2;
    color: #991b1b;
}

/* Buttons */
.btn-primary {
    background-color: var(--sp-primary);
    border-color: var(--sp-primary);
}

.btn-primary:hover {
    background-color: var(--sp-primary-hover);
    border-color: var(--sp-primary-hover);
}

/* Forms */
.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.35rem;
}

.form-control, .form-select {
    border-color: var(--sp-border-color);
    font-size: 0.88rem;
    padding: 0.55rem 0.85rem;
    border-radius: 6px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--sp-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Footer */
.app-footer {
    height: 50px;
    background-color: #ffffff;
    border-top: 1px solid var(--sp-border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    font-size: 0.78rem;
    color: var(--sp-text-muted);
}

/* Responsive */
@media (max-width: 992px) {
    .app-sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
    }
    .app-sidebar.show {
        left: 0;
    }
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 999;
    }
}
