:root {
    --primary: #4361ee;
    --sidebar-bg: #1e293b;
    --nav-bg: #ffffff;
    --bg-light: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #334155;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-width: 260px;
}

body.dark-mode {
    --nav-bg: #1e293b; 
    --bg-light: #0f172a; 
    --card-bg: #1e293b;
    --text-main: #f1f5f9; 
    --border: #334155;
}

body { 
    margin: 0; 
    font-family: 'Inter', sans-serif; 
    background: var(--bg-light); 
    display: flex; 
    color: var(--text-main); 
    transition: 0.3s; 
    overflow-x: hidden; /* තිරස් Scroll bar ඉවත් කිරීමට */
}

/* --- Sidebar Styling --- */
.sidebar {
    width: var(--sidebar-width); 
    height: 100vh; 
    background: var(--sidebar-bg);
    position: fixed; 
    left: calc(-1 * var(--sidebar-width)); /* Default Hidden */
    transition: 0.3s; 
    z-index: 2000; /* Header එකට වඩා උඩින් */
}

.sidebar.active { 
    left: 0; 
}

.sidebar-header { 
    height: 65px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    background: #111827; 
    color: white; 
    border-bottom: 1px solid #334155; 
}

.sidebar ul { 
    list-style: none; 
    padding: 0; 
    margin: 20px 0; 
}

.sidebar ul li a { 
    display: flex; 
    align-items: center; 
    padding: 12px 25px; 
    color: #cbd5e1; 
    text-decoration: none; 
    transition: 0.2s; 
}

.sidebar ul li a:hover, .sidebar ul li a.active { 
    background: var(--primary); 
    color: white; 
}

/* Icon Styling inside Sidebar */
.sidebar ul li a i { 
    width: 25px; 
    margin-right: 10px; 
    font-size: 18px; 
    text-align: center;
}

/* --- Content Push Logic (වැදගත්ම කොටස) --- */
.main-content { 
    flex: 1; 
    transition: 0.3s; 
    width: 100%; 
    position: relative; 
    min-height: 100vh;
}

/* Sidebar Active වූ විට Content එක දකුණට තල්ලු වීම */
body.sidebar-active .main-content { 
    margin-left: var(--sidebar-width); 
    width: calc(100% - var(--sidebar-width)); 
}

/* --- Header Styling --- */
.top-nav { 
    height: 65px; 
    background: var(--nav-bg); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 0 20px; 
    border-bottom: 1px solid var(--border); 
    position: sticky; 
    top: 0; 
    z-index: 1000; 
}

/* User Info Box in Header */
.user-info-box {
    display: flex; 
    flex-direction: column; 
    text-align: right; 
    padding-right: 15px; 
    border-right: 1px solid var(--border); 
    margin-right: 15px; 
}
.u-name { font-weight: 700; font-size: 13px; color: var(--primary); }
.u-role { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }

/* --- Footer Styling (Fixed) --- */
.footer-line { 
    position: fixed; 
    bottom: 0; 
    right: 0; 
    left: 0; 
    background: var(--nav-bg); 
    padding: 8px 20px; 
    text-align: center; 
    font-size: 12px; 
    color: var(--text-muted); 
    border-top: 1px solid var(--border); 
    transition: 0.3s; 
    z-index: 900; 
}

/* Sidebar Active වූ විට Footer එකත් තල්ලු වීම */
body.sidebar-active .footer-line { 
    left: var(--sidebar-width); 
}

/* --- POS Layout --- */
.pos-container { 
    display: grid; 
    grid-template-columns: 1fr 380px; 
    gap: 20px; 
    padding: 20px; 
    padding-bottom: 70px; /* Footer එකට ඉඩ */
}

.card { 
    background: var(--card-bg); 
    border-radius: 12px; 
    padding: 20px; 
    border: 1px solid var(--border); 
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); 
}

/* Table & Search */
.cart-table-container { 
    height: 60vh; 
    overflow-y: auto; 
    margin-top: 15px; 
}

.pos-table { width: 100%; border-collapse: collapse; }
.pos-table th { background: var(--bg-light); padding: 12px; text-align: left; position: sticky; top: 0; }
.pos-table td { padding: 12px; border-bottom: 1px solid var(--border); }

.search-bar { position: relative; margin-bottom: 20px; }
.search-bar i { position: absolute; left: 15px; top: 18px; color: var(--primary); font-size: 18px; z-index: 10; }
.search-bar input { width: 100%; padding: 15px 15px 15px 45px; border-radius: 10px; border: 1px solid var(--border); font-size: 16px; box-sizing: border-box; }

/* Payment Section */
.summary-total h1 { font-size: 48px; margin: 0; color: var(--primary); text-align: right; }
.payment-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pay-btn { padding: 15px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-light); cursor: pointer; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.pay-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.btn-checkout { width: 100%; padding: 20px; background: #22c55e; color: white; border: none; border-radius: 10px; font-size: 22px; font-weight: 700; margin-top: 20px; cursor: pointer; }
.btn-primary { background: var(--primary); color: white; border: none; padding: 12px 25px; border-radius: 8px; cursor: pointer; font-weight: 600; }

/* --- Modal Styling --- */
.modal { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.7); 
    display: none; 
    justify-content: center; 
    align-items: center; 
    z-index: 3000; 
}

.modal-content { 
    background: var(--card-bg); 
    padding: 40px; 
    border-radius: 20px; 
    width: 450px; 
    text-align: center; 
    border: 1px solid var(--border); 
}

/* Global Elements */
.icon-btn { 
    background: none; 
    border: none; 
    font-size: 20px; 
    cursor: pointer; 
    color: var(--text-main); 
}

.custom-num-input { 
    font-family: 'Courier New', monospace; 
    font-weight: bold; 
    color: var(--primary); 
}



/* --- Inventory Action Bar (Balanced Layout) --- */
.inventory-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* බටන් 4 සමානව බෙදීම */
    gap: 20px;
    margin-bottom: 30px;
}

.action-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px; /* රවුම් හැඩය */
    padding: 25px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02); /* පොඩි ෂැඩෝ එකක් */
    color: var(--text-main);
    text-align: center;
    height: 100%; /* කාඩ් ඔක්කොම එකම උසට */
}

.action-card i { 
    font-size: 32px; 
    margin-bottom: 12px; 
    transition: 0.3s;
}

.action-card span { 
    font-weight: 600; 
    font-size: 15px; 
    color: var(--text-main);
}

/* Hover Effects (මවුස් එක ගෙනිච්චම උඩට එන්න) */
.action-card:hover { 
    transform: translateY(-5px); 
    box-shadow: 0 10px 20px rgba(0,0,0,0.08); 
    border-color: var(--primary);
}

/* 1. New Product Button (Blue Accent) */
.action-card.add-product { border-bottom: 4px solid #4361ee; }
.action-card.add-product i { color: #4361ee; }

/* 2. Suppliers Button (Green Accent) */
.action-card:nth-child(2) { border-bottom: 4px solid #10b981; }
.action-card:nth-child(2) i { color: #10b981; }

/* 3. Categories Button (Orange Accent) */
.action-card:nth-child(3) { border-bottom: 4px solid #f59e0b; }
.action-card:nth-child(3) i { color: #f59e0b; }

/* 4. Brands Button (Purple Accent) */
.action-card:nth-child(4) { border-bottom: 4px solid #8b5cf6; }
.action-card:nth-child(4) i { color: #8b5cf6; }


/* --- Search Bar Styling --- */
.inventory-search { margin-bottom: 25px; }
.search-input-wrapper { position: relative; max-width: 100%; }
.search-input-wrapper i { 
    position: absolute; 
    left: 20px; 
    top: 50%; 
    transform: translateY(-50%); 
    color: var(--primary); 
    font-size: 18px;
}
.search-input-wrapper input {
    width: 100%;
    padding: 18px 18px 18px 55px; /* Icon එකට ඉඩ */
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: 0.3s;
    box-sizing: border-box; /* Input එක එළියට පනින එක නවත්වන්න */
}
.search-input-wrapper input:focus { 
    border-color: var(--primary); 
    outline: none; 
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.1);
}


/* --- Table Styling (Fix for Clumped Header) --- */
.card .table-responsive {
    border-radius: 12px;
    overflow: hidden; /* කොන් රවුම් වෙන්න */
    border: 1px solid var(--border);
}

.data-table { 
    width: 100%; 
    border-collapse: collapse; 
    background: white;
}

.data-table thead {
    background: #f8fafc; /* හෙඩර් එකට පාටක් */
    border-bottom: 2px solid var(--border);
}

.data-table th { 
    padding: 18px 15px; 
    text-align: left; 
    font-weight: 600; 
    color: var(--text-muted);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td { 
    padding: 15px; 
    border-bottom: 1px solid var(--border); 
    color: var(--text-main);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: #f1f5f9; } /* Row Hover Effect */

/* Badges & Buttons */
.code-badge { background: #e2e8f0; padding: 5px 10px; border-radius: 6px; font-family: 'Courier New', monospace; font-weight: bold; font-size: 13px; color: #334155; }

.btn-icon { width: 32px; height: 32px; border-radius: 6px; border: none; cursor: pointer; margin-right: 5px; display: inline-flex; align-items: center; justify-content: center; transition: 0.2s; }
.btn-edit { background: #e0f2fe; color: #0284c7; } .btn-edit:hover { background: #0284c7; color: white; }
.btn-stock { background: #dcfce7; color: #16a34a; } .btn-stock:hover { background: #16a34a; color: white; }
.btn-delete { background: #fee2e2; color: #dc2626; } .btn-delete:hover { background: #dc2626; color: white; }

/* --- DARK MODE FIXES FOR INVENTORY --- */

/* 1. Action Cards Dark Mode */
body.dark-mode .action-card {
    background: var(--card-bg); /* කාඩ් එකේ පාට කළු */
    border-color: var(--border);
    box-shadow: none;
}
body.dark-mode .action-card:hover {
    background: #1e293b; /* Hover එකට පොඩි වෙනසක් */
    border-color: var(--primary);
}
body.dark-mode .action-card span {
    color: #e2e8f0; /* අකුරු සුදු පාටට හුරු */
}
body.dark-mode .action-card i {
    /* Icon Colors ටික එහෙමම තියමු, ඒවා Dark Mode එකටත් ලස්සනයි */
}

/* 2. Search Bar Dark Mode */
body.dark-mode .search-input-wrapper input {
    background: var(--card-bg); /* Input එකේ පාට කළු */
    color: #fff; /* Input එකේ අකුරු සුදු */
    border-color: var(--border);
}
body.dark-mode .search-input-wrapper input:focus {
    border-color: var(--primary);
    background: #0f172a; /* Focus වුනාම තව ටිකක් කළු */
}
body.dark-mode .search-input-wrapper input::placeholder {
    color: #64748b; /* Placeholder එක අළු පාට */
}

/* 3. Data Table Dark Mode */
body.dark-mode .data-table {
    background: var(--card-bg);
    color: #cbd5e1;
}
body.dark-mode .data-table thead {
    background: #0f172a; /* Header එක තද කළු */
    border-bottom-color: #334155;
}
body.dark-mode .data-table th {
    color: #94a3b8;
}
body.dark-mode .data-table td {
    border-bottom-color: #334155; /* ඉරි පාට වෙනස් කිරීම */
    color: #e2e8f0;
}
body.dark-mode .data-table tr:hover {
    background: #1e293b; /* Row Hover එක */
}

/* 4. Badges Dark Mode */
body.dark-mode .code-badge {
    background: #334155;
    color: #f1f5f9;
}