/* style.css - Unified Application Styles */
:root {
  --background: #f4f7fa;
  --card: #fff;
  --border: #e0e0e0;
  --primary: #2c3e50;
  --primary-light: #34495e;
  --gray-txt: #757575;
  --blue: #54A0FF; /* Soft Sky Blue for Links/Accents */
  --green: #6CC790; /* Muted Sage Green for Success */
  --amber: #FFB95B; /* Dusty Orange-Gold for Warning/Pending */
  --red: #FF8C8C; /* Gentle Rose Red for Danger/Out of Stock */
  --radius: 12px;
  --input-bg: #f8f8f8;
  --shadow: 0 2px 18px rgba(99, 102, 241, .09);
  --pill-dark: #364756;
  --pill-gray: #888;
  --pill-red: #E87A7A; /* Darker variant of new --red */
}

html,
body {
  background: var(--background);
  color: var(--primary);
  font-family: 'Inter', Roboto, sans-serif;
  margin: 0;
  min-height: 100vh;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: 230px;
  background: var(--primary);
  color: #fff;
  padding: 40px 0 28px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.sidebar-logo {
  text-align: center;
  margin-bottom: 26px;
}

.sidebar-logo svg {
  height: 40px;
  width: 40px;
}

.sidebar-title {
  font-weight: 700;
  font-size: 1.17rem;
  margin-bottom: 4px;
  text-align: center;
}

.sidebar-role {
  font-size: .97rem;
  color: #bbc;
  text-align: center;
  margin-bottom: 18px;
}

.sidebar-tabs {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-tabs li {
  margin-bottom: 10px;
}

.sidebar-link {
  color: #fff;
  text-decoration: none;
  font-weight: 500;
  font-size: 1rem;
  padding: 10px 22px 10px 12px;
  margin: 0 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 7px;
  transition: background 0.13s;
}

.sidebar-link.active,
.sidebar-link:hover {
  background: var(--primary-light);
}

.sidebar-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 22px 18px;
}

.logout-btn {
  color: var(--red);
  background: none;
  border: none;
  font-weight: 600;
  font-size: 1.07rem;
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 11px;
  cursor: pointer;
  border-radius: 6px;
  width: 100%;
}
.logout-btn:hover {
  background: rgba(231, 76, 60, .1);
}

.logout-btn svg {
  width: 21px;
  height: 21px;
}

/* --- Main Content Area --- */
.main {
  flex: 1;
  background: var(--background);
  padding: 34px 28px 32px 28px;
  min-width: 0;
  overflow-y: auto;
}

.main-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.main-header {
  font-size: 2.1rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.main-sub {
  font-size: 1.09rem;
  color: var(--gray-txt);
  margin-bottom: 22px;
}

/* --- General Components --- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
  border: 1px solid var(--border);
  padding: 24px 27px;
}

.top-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search-input {
  width: 170px;
  padding: 10px 38px 10px 19px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f6f6f6;
  font-size: 1.05rem;
}

.filter-select {
  padding: 9px 18px 9px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 1.04rem;
  color: var(--primary);
}

.add-btn {
  background: var(--pill-dark);
  color: #fff;
  font-weight: 600;
  border: none;
  border-radius: 5px;
  padding: 10px 23px;
  cursor: pointer;
  font-size: 1.04rem;
  box-shadow: 0 2px 8px rgba(60, 60, 70, .04);
}
.add-btn:hover {
  background: #000;
}

/* --- Tables --- */
.materials-table,
.user-table,
.reports-table,
.cart-table,
.sales-history-table,
.supplier-table,
.txn-table,
.materials-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.materials-table th, .user-table th, .reports-table th,
.cart-table th, .sales-history-table th, .supplier-table th,
.txn-table th, .materials-table th {
  background: #f5f5f5;
  color: var(--gray-txt);
  font-weight: 600;
  padding: 13px 9px;
  font-size: 1.01rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.materials-table td, .user-table td, .reports-table td,
.cart-table td, .sales-history-table td, .supplier-table td,
.txn-table td, .materials-table td {
  padding: 13px 7px;
  font-size: 1.01rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.materials-table tr:last-child td, .user-table tr:last-child td,
.reports-table tr:last-child td, .cart-table tr:last-child td,
.sales-history-table tr:last-child td, .supplier-table tr:last-child td,
.txn-table tr:last-child td, .materials-table tr:last-child td {
    border-bottom: none;
}

/* --- Pills (Status) --- */
.status-pill {
  border-radius: 13px;
  padding: 6px 19px;
  font-size: .97rem;
  font-weight: 700;
  display: inline-block;
  color: #fff;
}
.status-pill.instock { background: var(--green); }
.status-pill.lowstock { background: var(--amber); }
.status-pill.outofstock { background: var(--pill-red); }
.status-pill.verified { background: var(--green); }
.status-pill.pending { background: var(--amber); }

/* --- Buttons --- */
.action-cell { display: flex; gap: 11px; }
.icon-btn { background: none; border: none; cursor: pointer; padding: 4px; border-radius: 7px; }
.icon-btn:focus, .icon-btn:hover { background: var(--blue); color: #fff; }
.icon-btn:focus svg, .icon-btn:hover svg { stroke: #fff; }
.action-btn { border: none; background: none; padding: 7px 13px; font-weight: 600; border-radius: 7px; color: var(--primary); cursor: pointer; }
.action-btn.verify { background: var(--green); color: #fff; }
.action-btn.delete { background: var(--red); color: #fff; }
.icon-btn svg {
  width: 18px;
  height: 18px;
  display: inline-block;
}

/* --- Modals --- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(40, 40, 80, 0.09);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal {
  background: #fff;
  box-shadow: var(--shadow);
  border-radius: 17px;
  padding: 30px 28px 23px 28px;
  width: 400px;
  max-width: 95vw;
  position: relative;
}

.modal-header {
  font-size: 1.18rem;
  font-weight: 700;
  margin-bottom: 17px;
}

.modal-close {
  position: absolute;
  top: 19px;
  right: 23px;
  background: none;
  border: none;
  font-size: 1.37rem;
  color: var(--gray-txt);
  cursor: pointer;
}

.modal label {
  display: block;
  font-size: 1.02rem;
  font-weight: 500;
  margin: 10px 0 6px 0;
}

.modal input[type="text"],
.modal input[type="number"],
.modal input[type="email"],
.modal select,
.modal textarea {
  width: 100%;
  background: var(--input-bg);
  border-radius: 7px;
  border: 1px solid var(--border);
  font-size: 1.01rem;
  padding: 8px 12px;
  margin-bottom: 2px;
  box-sizing: border-box;
}

.modal textarea {
  min-height: 55px;
  resize: vertical;
}
.modal .two-cols, .modal .row2 { display: flex; gap: 8px; }
.modal .two-cols > *, .modal .row2 > * { flex: 1; }
.modal .modal-footer { margin-top: 19px; text-align: right; }
.modal .btn-cancel { background: #ebebeb; border: none; color: var(--gray-txt); padding: 9px 18px; border-radius: 6px; font-weight: 600; margin-right: 10px; cursor:pointer; }
.modal .btn-primary { background: var(--primary); border: none; color: #fff; padding: 9px 21px; border-radius: 6px; font-weight: 600; cursor:pointer; }

/* Category Modal List */
.modal .cat-list { list-style: none; padding: 0; margin: 9px 0; }
.modal .cat-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px; }
.modal .cat-actions { display: inline-flex; gap: 8px; }
.modal .cat-action { background: none; border: none; cursor: pointer; padding: 3px; }
.modal .cat-action svg { width: 17px; height: 17px; color: var(--gray-txt); }
.modal .new-cat-row { display: flex; gap: 6px; }
.modal .new-cat-input { flex: 1; }

/* --- Page: Dashboard --- */
.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 38px;
}
.metric-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  padding: 26px 22px 22px 22px;
  position: relative;
}
.card-icon { position: absolute; top: 22px; right: 22px; }
.metric-label { font-size: .98rem; color: var(--gray-txt); font-weight: 500; margin-bottom: 3px; }
.metric-value { font-size: 2.45rem; font-weight: 800; }
.metric-value.green { color: var(--green); }
.metric-value.amber { color: var(--amber); }
.metric-link { font-size: 1.01rem; color: var(--blue); font-weight: 600; text-decoration: none; margin-top: 13px; display: inline-block; }
.metric-link:hover { text-decoration: underline; }
.dashboard-row { display: grid; grid-template-columns: 2fr 3fr; gap: 26px; }
.card-title { font-size: 1.23rem; font-weight: 700; margin-bottom: 13px; }
.quick-actions { display: flex; flex-direction: column; gap: 13px; }
.quick-btn { display: flex; align-items: center; gap: 10px; background: #f8fafc; padding: 13px 0 13px 10px; border-radius: 8px; border: 1px solid var(--border); font-weight: 600; cursor: pointer; transition: background 0.13s; color: var(--primary); text-decoration: none;}
.quick-btn:hover { background: #edeef6; }
.quick-btn svg { width: 20px; height: 20px; }
.recent-list { border-top: 1px solid var(--border); }
.recent-item { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--border); }
.recent-item:last-child { border-bottom: none; }
.recent-message { font-size: 1.07rem; color: var(--primary); }
.recent-time { font-size: .97rem; color: var(--gray-txt); }
.recent-footer { text-align: right; margin-top: 5px; }
.recent-link { color: var(--blue); font-weight: 600; font-size: 1.02rem; text-decoration: none; }
.recent-link:hover { text-decoration: underline; }

/* --- Page: User Management --- */
.counters-row { display: flex; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.counter-box { background: #f5f5f5; border-radius: 12px; padding: 23px 30px; flex: 1; min-width: 180px; box-shadow: 0 2px 13px rgba(0, 0, 0, 0.03); }
.counter-title { font-size: 1.07rem; color: var(--gray-txt); margin-bottom: 8px; }
.counter-value { font-size: 2rem; font-weight: 700; }

/* --- Page: Reports --- */
.reports-summary { display: flex; gap: 23px; margin-bottom: 30px; flex-wrap: wrap; }
.sum-card { background: var(--card); border-radius: 10px; padding: 19px 23px 13px 23px; min-width: 152px; box-shadow: 0 2px 8px rgba(85, 85, 85, .06); }
.sum-title { font-size: 1.01rem; color: var(--gray-txt); margin-bottom: 7px; }
.sum-value { font-weight: 700; font-size: 1.42rem; color: var(--primary); }
.filter-row { display: flex; gap: 13px; align-items: center; margin-bottom: 23px; flex-wrap: wrap; }
.filter-row select, .filter-row input[type="date"] { font-size: 1.02rem; padding: 7px 16px; border-radius: 7px; border: 1px solid var(--border); background: #f6f6f8; }
.filter-row .filter-btn { background: var(--gray-txt); color: #fff; font-weight: 600; border: none; border-radius: 7px; padding: 9px 16px; cursor: pointer; font-size: .97rem; }
.filter-row .filter-tab { background: none; border: none; color: var(--primary); font-weight: 600; font-size: 1.01rem; padding: 7px 17px; border-radius: 8px; cursor: pointer; margin-left: 4px; }
.filter-row .filter-tab.active { background: var(--card); border: 1.4px solid var(--border); }
.filter-row .filter-clear { background: none; border: none; color: var(--blue); padding: 8px 13px; cursor: pointer; font-size: 1rem; text-decoration: underline; margin-left: 8px; }
.txn-type.Stock\ In { color: var(--green); font-weight: 600; }
.txn-type.Stock\ Out { color: var(--red); font-weight: 600; }
.txn-type.Sale { color: var(--blue); font-weight: 600; }
.view-btn { background: none; border: 1.5px solid var(--blue); color: var(--blue); font-weight: 600; border-radius: 8px; padding: 8px 16px; cursor: pointer; font-size: .97rem; }
.modal-field { background: #f7f7f7; border-radius: 7px; border: 1px solid var(--border); font-size: .98rem; padding: 7px 13px; margin-bottom: 3px; }


/* --- Page: Profile --- */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-bottom: 32px; }
.card-title-row { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.icon-user { width: 27px; height: 27px; color: var(--primary); }
.form-label { font-weight: 500; color: var(--primary); font-size: 1rem; margin-bottom: 8px; }
.field-row { margin-bottom: 19px; }
.input-readonly { width: 100%; box-sizing: border-box; background: var(--input-bg); border-radius: 7px; border: 1px solid var(--border); color: var(--gray-txt); font-size: 1.04rem; padding: 13px 12px; }
.input-helper { font-size: 0.92rem; color: var(--gray-txt); margin: 6px 0 0 2px; }
.status-verified { color: var(--green); font-weight: 600; font-size: 1.02rem; }
.input-editable { width: 100%; box-sizing: border-box; background: var(--card); border-radius: 7px; border: 1px solid var(--border); color: var(--primary); font-size: 1.04rem; padding: 13px 12px; }
.profile-actions { margin-top: 24px; }
.edit-btn { width: 100%; background: var(--primary); color: #fff; border-radius: 8px; padding: 13px 0; font-weight: 600; font-size: 1.1rem; border: none; cursor: pointer; }
.edit-btn:hover { background: #000; }
.card-change { margin: 0 auto; max-width: 520px; margin-bottom: 12px; }
.change-title { font-size: 1.07rem; font-weight: 600; margin-bottom: 9px; }
.change-desc { color: var(--gray-txt); font-size: .97rem; margin-bottom: 17px; }
.change-btn { background: var(--primary); color: #fff; border-radius: 8px; padding: 12px 34px; font-weight: 600; font-size: 1.07rem; border: none; cursor: pointer; }
.change-btn:hover { background: #000; }

/* --- Page: Stock --- */
.tabs-row { display: flex; gap: 22px; margin-bottom: 18px; }
.tab-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 0; background: none; border: none; font-weight: 600; font-size: 1.08rem; color: var(--primary); border-radius: 18px 18px 0 0; position: relative; transition: background .16s; cursor: pointer; }
.tab-btn.active { background: #f5f5f5; box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.03); }
.tab-btn .tab-icon { display: flex; align-items: center; }
.tab-btn svg { width: 20px; height: 20px; }
.tab-btn .tab-label { position: relative; z-index: 2; }
.stock-layout { display: flex; gap: 18px; }
.col-left { flex: 0 0 350px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 27px 20px 22px 27px; box-sizing: border-box; }
.form-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 19px; display: flex; align-items: center; gap: 8px; }
.form-title.in { color: var(--green); }
.form-title.out { color: var(--red); }
.form-label { font-size: .99rem; font-weight: 500; margin-bottom: 8px; }
.form-req { color: var(--red); margin-left: 3px; font-size: 1em; }
.form-group { margin-bottom: 19px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 10px 12px; border-radius: 4px; border: 1px solid var(--border); font-size: 1rem; box-sizing: border-box; }
.form-textarea { resize: vertical; min-height: 38px; }
.form-btn { width: 100%; background: var(--green); color: #fff; border-radius: 6px; font-weight: 600; border: none; padding: 13px 0; cursor: pointer; font-size: 1.01rem; display: flex; align-items: center; justify-content: center; gap: 7px; }
.form-btn svg { width: 18px; height: 18px; }
.form-btn.out { background: var(--red); }
.col-right { flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 22px 14px 18px 24px; box-sizing: border-box; }
.table-title { font-size: 1.18rem; font-weight: 700; margin-bottom: 14px; }
.mat-namecell { font-weight: 600; }
.mat-code { font-size: .99em; color: var(--gray-txt); margin-top: 3px; display: block; }
.mat-stock { font-weight: 600; text-align: center; }
.mat-stock.low { color: var(--amber); }
.mat-unit { font-weight: 500; text-align: right; }

/* --- Page: Sales (POS) --- */
.sales-summary { display: flex; gap: 23px; margin-bottom: 30px; flex-wrap: wrap; }
.sales-sum-card { background: var(--card); border-radius: 10px; padding: 19px 23px 13px 23px; min-width: 152px; box-shadow: 0 2px 8px rgba(85, 85, 85, .06); flex: 1; }
.sales-sum-title { font-size: 1.01rem; color: var(--gray-txt); margin-bottom: 7px; }
.sales-sum-value { font-weight: 700; font-size: 1.5rem; color: var(--primary); }
.add-sale-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 24px 19px; margin-bottom: 27px; }
.add-sale-row { display: flex; gap: 17px; align-items: flex-end; }
.add-sale-row select, .add-sale-row input[type="number"] { font-size: 1.08rem; padding: 8px 13px; border-radius: 6px; border: 1px solid var(--border); }
.add-sale-row select { flex: 1; }
.cart-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 24px 19px; }
.remove-btn { background: none; color: var(--red); border: none; font-size: 1.17rem; cursor: pointer; padding: 4px; }
.cart-sum { font-size: 1.07rem; font-weight: 700; text-align: right; padding-top: 8px; }
.cart-checkout-btn { background: var(--green); color: #fff; font-weight: 600; border: none; border-radius: 8px; padding: 11px 24px; cursor: pointer; font-size: 1.05rem; float: right; margin-top: 8px; }
.sales-history-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 24px 19px; margin-top: 28px; }
.sales-history-title { font-size: 1.13rem; font-weight: 700; margin-bottom: 10px; }
.empty { color: var(--gray-txt); font-size: 1.08rem; text-align: center; padding: 14px 0; }

/* --- Page: Suppliers --- */
.tab-row { display: flex; gap: 18px; margin-bottom: 0px; border-bottom: 1px solid var(--border); }
.tab-btn-sup { font-size: 1.08rem; font-weight: 600; padding: 12px 33px 12px 33px; background: none; border: none; color: var(--gray-txt); cursor: pointer; border-bottom: 3px solid transparent; }
.tab-btn-sup.active { color: var(--primary); border-bottom-color: var(--primary); }
.headerline { font-size: 1.21rem; font-weight: 600; margin: 12px 0 29px 4px; }
.sup-name { font-weight: 700; }
.sup-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; max-width: 250px; }
.sup-badge { background: #ededed; color: #515355; font-size: .95rem; padding: 5px 11px; border-radius: 10px; }
.empty-row { color: var(--gray-txt); text-align: center; padding: 13px 0; font-size: 1.07rem; }

/* --- Media Queries --- */
@media(max-width: 900px) {
  .dashboard-row { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
  .stock-layout { flex-direction: column; }
  .col-left { flex: 0 0 auto; }
}

@media(max-width: 700px) {
  .sidebar { display: none; /* Add mobile nav logic later */ }
  .main { padding: 15px; }
  .main-header { font-size: 1.5rem; }
  .top-controls { flex-direction: column; align-items: stretch; }
  .search-input { width: auto; }
  .filter-row { flex-direction: column; align-items: stretch; }
  .add-sale-row { flex-direction: column; align-items: stretch; }
}