/* --- Variables --- */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --bg-color: #f9fafb;
    --panel-bg: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 8px;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --sidebar-width: 260px;
    --topbar-height: 64px;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
}

svg {
    max-width: 20px !important;
    height: auto !important;
    display: inline-block !important;
}

/* --- Layout Components --- */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: #1e293b;
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: all 0.3s;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.sidebar-header span {
    font-weight: 700;
    font-size: 1.125rem;
}

.sidebar-nav {
    padding: 20px 0;
}

.nav-item {
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
}

.nav-item:hover, .nav-item.active {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    background: var(--bg-color);
    transition: all 0.3s;
}

.topbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-content {
    padding: 32px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
}

/* --- Topbar Helpers --- */
.btn-sync-store {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-sync-store:hover {
    background: #e2e8f0;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* --- Notifications --- */
.notification-bell {
    position: relative;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    color: var(--text-muted);
}

.notification-bell:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

.notification-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 1000;
    display: none;
}

.notification-dropdown.active {
    display: block;
}

.notification-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
}

.notification-list {
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.notification-item:hover {
    background: var(--bg-color);
}

.notification-item.unread {
    background: #f0f9ff;
}

.notification-item i {
    width: 32px;
    height: 32px;
    background: #e0e7ff;
    color: var(--primary-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-item-content {
    flex: 1;
}

.notification-item-title {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.notification-item-message {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    line-height: 1.4;
}

.notification-item-time {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.notification-footer {
    padding: 12px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.notification-footer a {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--primary-color);
    text-decoration: none;
}

/* --- Modern Table Styling --- */
.table-container {
    overflow-x: auto;
    background: var(--panel-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin-top: 24px;
}

.modern-table {
    width: 100% !important;
    border-collapse: collapse;
    text-align: left;
}

.modern-table th {
    padding: 18px 24px !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    color: var(--text-muted) !important;
    text-transform: uppercase !important;
    background: #f8fafc !important;
    border-bottom: 2px solid var(--border-color) !important;
}

.modern-table td {
    padding: 16px 24px !important;
    border-bottom: 1px solid var(--border-color) !important;
    vertical-align: middle !important;
}

.modern-table tr:nth-child(even) {
    background-color: #fbfbfb !important;
}

.modern-table tr:hover {
    background-color: #f1f5f9 !important;
    transition: background-color 0.2s;
}

/* --- Status Badges --- */
.badge {
    padding: 6px 12px !important;
    border-radius: 4px !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
}

.badge-success {
    color: #10b981 !important;
    background: #ecfdf5 !important;
    border: 1px solid #d1fae5 !important;
}

.badge-warning {
    color: #f59e0b !important;
    background: #fffbeb !important;
    border: 1px solid #fef3c7 !important;
}

.badge-danger {
    color: #ef4444 !important;
    background: #fef2f2 !important;
    border: 1px solid #fee2e2 !important;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2), 0 2px 4px -1px rgba(79, 70, 229, 0.1);
    letter-spacing: 0.01em;
}

.btn:hover {
    background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3), 0 4px 6px -2px rgba(79, 70, 229, 0.1);
    transform: translateY(-2px);
}

.btn-secondary {
    background: white !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border-color) !important;
}

/* ... and so on ... */

/* Simplified Grid System and Other Helpers */
.btn-primary {
    background-color: var(--primary-color) !important;
    color: white !important;
}

/* Responsive Grid Fixes */
@media (max-width: 992px) {
    div[style*="display: grid"] {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}

@media (min-width: 768px) {
    .dashboard-header {
        flex-direction: row;
        align-items: center !important;
    }
}

/* --- Forms & Cards --- */
.auth-card {
    background: var(--panel-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 32px;
    border: 1px solid var(--border-color);
}
.form-group {
    margin-bottom: 20px;
}
.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.875rem;
    color: var(--text-main);
}
.form-input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s;
    background-color: #ffffff;
    font-family: inherit;
    outline: none;
    color: var(--text-main);
}
.form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.error-message {
    color: #ef4444;
    font-size: 0.75rem;
    margin-top: 4px;
}

/* --- Auth Layout (Login) --- */
.auth-container {
    display: flex;
    min-height: 100vh;
}

.auth-visual {
    flex: 1;
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-visual::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.85) 0%, rgba(124, 58, 237, 0.85) 100%);
}

.auth-visual-content {
    position: relative;
    z-index: 10;
    color: white;
    max-width: 480px;
    padding: 40px;
}

.auth-visual-content h2 {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 16px;
}

.auth-visual-content p {
    font-size: 1.125rem;
    opacity: 0.9;
}

.auth-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background-color: var(--bg-color);
}

.auth-header {
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .auth-container {
        flex-direction: column;
    }
    .auth-visual {
        min-height: 400px;
    }
}

/* --- Premium Table Action Buttons --- */
.action-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 8px !important;
    background-color: #f8fafc !important;
    color: #64748b !important;
    border: 1px solid #e2e8f0 !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    text-decoration: none !important;
    cursor: pointer !important;
    font-size: 0.875rem !important;
    padding: 0 !important;
    margin: 0 4px !important;
}

.action-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03) !important;
}

.action-btn:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1) !important;
}

/* Delete Action */
button.action-btn.delete, button.action-btn[title="Delete"], button.action-btn.remove-item-btn {
    background-color: #fef2f2 !important;
    border-color: #fee2e2 !important;
    color: #ef4444 !important;
}
button.action-btn.delete:hover, button.action-btn[title="Delete"]:hover, button.action-btn.remove-item-btn:hover {
    background-color: #fee2e2 !important;
    color: #b91c1c !important;
    border-color: #fca5a5 !important;
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.1) !important;
}

/* View Action */
a.action-btn[title="View"] {
    background-color: #f0fdf4 !important;
    border-color: #dcfce7 !important;
    color: #10b981 !important;
}
a.action-btn[title="View"]:hover {
    background-color: #dcfce7 !important;
    color: #047857 !important;
    border-color: #86efac !important;
}

/* Edit Action */
a.action-btn[title="Edit"], a.action-btn[title="Update Stock"] {
    background-color: #eff6ff !important;
    border-color: #dbeafe !important;
    color: #3b82f6 !important;
}
a.action-btn[title="Edit"]:hover, a.action-btn[title="Update Stock"]:hover {
    background-color: #dbeafe !important;
    color: #1d4ed8 !important;
    border-color: #93c5fd !important;
}

/* Download/Email Actions */
a.action-btn[title="Download PDF"], button.action-btn[title="Email to Customer"] {
    background-color: #fdf4ff !important;
    border-color: #fae8ff !important;
    color: #d946ef !important;
}
a.action-btn[title="Download PDF"]:hover, button.action-btn[title="Email to Customer"]:hover {
    background-color: #fae8ff !important;
    color: #a21caf !important;
    border-color: #f0abfc !important;
}

/* --- Global Pagination UI --- */
.pagination {
    display: flex !important;
    gap: 6px !important;
    list-style: none !important;
    padding: 6px !important;
    background: #fff !important;
    border-radius: 50px !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05) !important;
    border: 1px solid var(--border-color) !important;
    margin: 20px auto !important;
    justify-content: center !important;
    width: fit-content !important;
}
.page-item {
    margin: 0 !important;
}
.page-link {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 38px !important;
    height: 38px !important;
    padding: 0 14px !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-muted) !important;
    text-decoration: none !important;
    font-weight: 600 !important;
    font-size: 0.8125rem !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    border-radius: 50px !important;
}
.page-item.active .page-link, .page-item.active .page-link:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3) !important;
    transform: translateY(-1px) !important;
    border: none !important;
}
.page-link:hover:not([disabled]) {
    background: #f1f5f9 !important;
    color: var(--primary-color) !important;
    transform: translateY(-1px) !important;
}
.page-item.disabled .page-link {
    background: transparent !important;
    color: #cbd5e1 !important;
    cursor: not-allowed !important;
    transform: none !important;
    border: none !important;
}