/* Reset and Base Rules */
:root {
    --bg-main: #f4f6f9;
    --bg-card: #ffffff;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --danger: #ef4444;
    --success: #10b981;
    --sidebar-bg: #111827;
    --sidebar-text: #9ca3af;
    --sidebar-active: #ffffff;
    --border-color: #e5e7eb;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Utilities */
.hidden { display: none !important; }

/* Pagination Styling */
.pagination-container {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    margin-top: 24px;
    padding: 12px 0;
}
.page-btn {
    padding: 6px 14px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-main);
    font-weight: 600;
    font-size: 14px;
    min-width: 36px;
}
.page-btn:hover { background: #f8fafc; border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }


/* Toast Notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 10000;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.toast.show { transform: translateX(0); }
.toast.error { background-color: var(--danger); }
.toast.success { background-color: var(--success); }

/* Glassmorphism Login Overlay */
.login-overlay {
    position: fixed;
    inset: 0;
    background: url('https://images.unsplash.com/photo-1490481651871-ab68de25d43d?q=80&w=2670&auto=format&fit=crop') center/cover;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.7);
    backdrop-filter: blur(10px);
}

.login-card {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 40px;
    border-radius: 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    color: white;
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}
.login-header h2 { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.login-header p { color: #d1d5db; margin-top: 8px; }

.input-group { margin-bottom: 20px; }
.input-group label { display: block; margin-bottom: 8px; font-size: 14px; color: #e5e7eb; }
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.input-wrapper i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    width: 20px;
    height: 20px;
}
.input-wrapper input {
    width: 100%;
    padding: 14px 14px 14px 44px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.2);
    color: white;
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
}
.input-wrapper input:focus {
    border-color: var(--primary);
    background: rgba(0,0,0,0.4);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}
.btn-primary:active { transform: translateY(0); }

/* Application Layout */
.app-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.sidebar-brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sidebar-brand span {
    background: var(--primary);
    color: white;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 700;
}
.sidebar-brand h2 { color: white; font-size: 20px; font-weight: 600; }

.sidebar-nav { padding: 24px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 500;
    transition: all 0.2s ease;
}
.nav-item i { width: 20px; height: 20px; }
.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,0.05);
    color: var(--sidebar-active);
}
.nav-item.active { background: var(--primary); }

.logout-btn { margin-top: auto; color: #f87171; }
.logout-btn:hover { background: rgba(248, 113, 113, 0.1); color: #f87171; }

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: 72px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
}

.page-title h1 { font-size: 20px; font-weight: 600; }

.user-profile { display: flex; align-items: center; gap: 12px; }
.user-profile .avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.user-profile .info { display: flex; flex-direction: column; }
.user-profile .name { font-weight: 600; font-size: 14px; }
.user-profile .role { font-size: 12px; color: var(--text-muted); text-transform: capitalize; }

.content-area {
    padding: 32px;
    flex: 1;
    overflow-y: auto;
}

.welcome-box {
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: 16px;
    padding: 32px;
    color: white;
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.2);
}
.welcome-box h2 { font-size: 24px; margin-bottom: 8px; }
.welcome-box p { color: rgba(255,255,255,0.9); line-height: 1.5; }

/* Specific Shared View Styles */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.view-header h2 { font-size: 24px; font-weight: 600; }
.view-header .actions { display: flex; gap: 12px; }

.btn-secondary {
    padding: 10px 16px;
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}
.btn-secondary:hover { background: #f9fafb; border-color: #d1d5db; }
.btn-secondary i { width: 16px; height: 16px; }

.btn-primary {
    padding: 10px 16px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary i { width: 18px; height: 18px; }

.btn-ghost {
    padding: 10px 16px;
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    font-weight: 500;
}
.btn-ghost:hover { color: var(--text-main); }

/* Filters */
.filter-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}
.search-wrapper { flex: 1; max-width: 400px; }
.search-wrapper input {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}
.search-wrapper input:focus { background: white; }

.custom-select {
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: white;
    font-size: 14px;
    color: var(--text-main);
    outline: none;
}
.custom-select:focus { border-color: var(--primary); }

/* Data Tables */
.table-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    overflow: hidden;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    background: #f8fafc;
    padding: 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}
.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }

.img-thumbnail {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.badge {
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
}
.badge.out-of-stock { background: #fee2e2; color: #dc2626; }
.badge.in-stock { background: #d1fae5; color: #059669; }

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}
.modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}
.modal-content {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 500px;
    padding: 32px;
    transform: translateY(20px);
    transition: all 0.3s ease;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    max-height: 90vh;
    overflow-y: auto;
}
.modal:not(.hidden) .modal-content { transform: translateY(0); }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.modal-header h3 { font-size: 20px; font-weight: 600; }
.close-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); }
.close-btn:hover { color: var(--text-main); }

.input-group input[type="text"], .input-group input[type="number"], .input-group input[type="date"] {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    font-size: 15px;
    outline: none;
    transition: all 0.3s;
}
.input-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1); }
.input-group label { color: var(--text-main); font-weight: 500; }

.input-row { display: flex; gap: 16px; }
.input-row .input-group { flex: 1; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
}

/* ==========================================
   PDV SPECIFIC STYLES
========================================== */
.pdv-layout {
    display: flex;
    gap: 24px;
    height: 100%;
}

.pdv-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.06);
    border-color: var(--primary);
}

.product-card img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 8px;
}

.product-card h4 {
    font-size: 14px;
    margin: 0;
    color: var(--text-main);
}

.product-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
}

.product-card .price {
    font-weight: 700;
    color: var(--primary);
    font-size: 16px;
    margin-top: auto;
}

/* Cart Item */
.cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.cart-item-info {
    flex: 1;
}

.cart-item-info strong {
    display: block;
    font-size: 13px;
    color: var(--text-main);
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.cart-item-controls input {
    width: 70px;
    padding: 6px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: center;
}

.btn-remove-item {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 4px;
}

/* Toggle Switch (Catalog Visibility) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background-color: #d1d5db;
    border-radius: 24px;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--success);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Finance Badges */
.badge.pending { background: #fee2e2; color: #dc2626; }
.badge.paid { background: #d1fae5; color: #059669; }

/* Responsive Adjustments */
.sidebar-logo {
    width: 100px;
    height: 100px;
    object-fit: contain;
}

.header-left { display: flex; align-items: center; gap: 16px; }

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 8px;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
    display: none;
    backdrop-filter: blur(4px);
}

@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        z-index: 999;
    }
    .sidebar.active { left: 0; }
    
    .mobile-menu-btn { display: block; }
    
    .top-bar { padding: 0 16px; }
    .content-area { padding: 16px; }
    
    .pdv-layout { flex-direction: column; }
    .pdv-sidebar { width: 100% !important; height: auto !important; }
}

@media (max-width: 768px) {
    .dashboard-grid { grid-template-columns: 1fr !important; }
    .summary-grid { grid-template-columns: 1fr !important; }
    
    .view-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .view-header .actions { width: 100%; }
    .view-header .actions button { flex: 1; }
    
    /* Table Responsive Hack */
    .table-container { overflow-x: auto; }
    .data-table { min-width: 600px; }
    
    .modal-content { padding: 20px; width: 95%; max-width: none; }
    .input-row { flex-direction: column; gap: 0; }
}

