/* IronOrderTally — app.css
   CRM-style theme on Bootstrap 5
   Navy accent: #3f51b5  (indigo-ish)
   Header bar:  #3f51b5
*/

:root {
  --iot-primary: #3f51b5;
  --iot-primary-dark: #303f9f;
  --iot-primary-light: #c5cae9;
  --iot-sidebar-width: 240px;
  --iot-topbar-height: 48px;
}

/* ========================================
   SIDEBAR — overlay style
   ======================================== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--iot-sidebar-width);
  background: #fff;
  border-right: 1px solid #e0e0e0;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .25s ease;
  overflow-y: auto;
}
.sidebar.open {
  transform: translateX(0);
}

/* Backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 1040;
}
.sidebar-backdrop.show {
  display: block;
}

/* Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid #e0e0e0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  text-decoration: none;
  color: var(--iot-primary);
  font-weight: 700;
  font-size: .95rem;
}
.sidebar-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--iot-primary);
  color: #fff;
  font-weight: 700;
  font-size: .75rem;
}
.sidebar-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #666;
  cursor: pointer;
  padding: .25rem;
}
.sidebar-close:hover { color: #000; }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: .5rem 0;
  overflow-y: auto;
}
.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar-section-label {
  padding: .75rem 1rem .25rem;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--iot-primary);
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem 1rem;
  color: #444;
  text-decoration: none;
  font-size: .85rem;
  border-left: 3px solid transparent;
  transition: background .15s, border-color .15s;
}
.sidebar-link:hover {
  background: #f5f5f5;
  color: var(--iot-primary);
}
.sidebar-link.active {
  background: var(--iot-primary-light);
  color: var(--iot-primary-dark);
  border-left-color: var(--iot-primary);
  font-weight: 600;
}
.sidebar-link i {
  font-size: 1rem;
  width: 1.2rem;
  text-align: center;
  flex-shrink: 0;
}

/* User footer */
.sidebar-footer {
  display: flex;
  align-items: center;
  padding: .75rem 1rem;
  border-top: 1px solid #e0e0e0;
  gap: .5rem;
}
.sidebar-user {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}
.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--iot-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .8rem;
  flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name {
  font-size: .8rem;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: .7rem;
  color: #888;
}
.sidebar-logout {
  background: none;
  border: none;
  color: #999;
  font-size: 1rem;
  cursor: pointer;
  padding: .25rem;
}
.sidebar-logout:hover { color: #e53935; }

/* ========================================
   TOPBAR
   ======================================== */
.topbar {
  display: flex;
  align-items: center;
  height: var(--iot-topbar-height);
  padding: 0 1rem;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}
.topbar-toggle {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: #555;
  cursor: pointer;
  padding: .25rem .5rem;
  margin-right: .75rem;
  border-radius: 4px;
}
.topbar-toggle:hover {
  background: #f0f0f0;
  color: var(--iot-primary);
}
.topbar-title {
  font-size: .95rem;
  font-weight: 600;
  color: #333;
}
.topbar-right {
  margin-left: auto;
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.main-content {
  min-height: 100vh;
  background: #f7f7fa;
}
.page-content {
  padding: 1rem 1rem 2rem;
}
@media (min-width: 768px) {
  .page-content {
    padding: 1.25rem 1.5rem 2rem;
  }
}

/* ========================================
   SECTION HEADER BAR (purple/navy)
   Like "Quotation List" / "Update Quotation"
   ======================================== */
.section-header {
  background: var(--iot-primary);
  color: #fff;
  padding: .5rem 1rem;
  font-size: .85rem;
  font-weight: 600;
  border-radius: 4px 4px 0 0;
  margin-bottom: 0;
}

/* ========================================
   TABLE STYLING
   ======================================== */
.table-iot thead th {
  background: #f5f5f5;
  color: #555;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  padding: .5rem .75rem;
  border-bottom: 2px solid #ddd;
}
.table-iot tbody td {
  font-size: .85rem;
  padding: .5rem .75rem;
  vertical-align: middle;
  border-bottom: 1px solid #eee;
}
.table-iot tbody tr:hover {
  background: #f9f9ff;
}

/* ========================================
   FORM STYLING
   Content-first, label-above
   ======================================== */
.form-control:focus,
.form-select:focus {
  border-color: var(--iot-primary) !important;
  box-shadow: 0 0 0 2px rgba(63, 81, 181, .15) !important;
  outline: none;
}

/* Label styling */
.form-label {
  font-size: .75rem;
  font-weight: 600;
  color: #666;
  margin-bottom: .2rem;
}

/* Required asterisk */
.requiredField::after {
  content: "*";
  color: #e53935;
  margin-left: 2px;
}

/* ========================================
   BADGES — pill style
   ======================================== */
.badge-broker {
  background: #e8eaf6;
  color: var(--iot-primary);
  font-weight: 600;
  font-size: .72rem;
  padding: .3em .6em;
  border-radius: 50rem;
}
.badge-party {
  background: #ede7f6;
  color: #6a1b9a;
  font-weight: 600;
  font-size: .72rem;
  padding: .3em .6em;
  border-radius: 50rem;
}
.badge-synced {
  background: #e8f5e9;
  color: #2e7d32;
  font-size: .72rem;
  padding: .3em .6em;
  border-radius: 50rem;
}
.badge-pending {
  background: #fff3e0;
  color: #e65100;
  font-size: .72rem;
  padding: .3em .6em;
  border-radius: 50rem;
}
.badge-order-pending {
  background: #fff3e0;
  color: #e65100;
}
.badge-order-closed {
  background: #e8f5e9;
  color: #2e7d32;
}
.badge-order-cancelled {
  background: #f5f5f5;
  color: #757575;
}

/* ========================================
   DETAIL PAGE — label/value pairs
   ======================================== */
.detail-label {
  font-size: .7rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .15rem;
}
.detail-value {
  font-size: .9rem;
  color: #333;
  font-weight: 500;
  min-height: 1.4em;
}
.detail-value.text-empty {
  color: #ccc;
}

/* ========================================
   LOCK BANNER
   ======================================== */
.alert-tally-lock {
  background: #fff8e1;
  border-left: 4px solid #ffc107;
  border-radius: .25rem;
  padding: .6rem 1rem;
  font-size: .85rem;
}

/* ========================================
   SELECT2
   ======================================== */
.select2-container { width: 100% !important; }
.select2-container--default .select2-selection--single {
  height: calc(1.5em + .75rem + 2px);
  padding: .375rem .75rem;
  border: 1px solid #ced4da;
  border-radius: .375rem;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 1.5;
  padding: 0;
  color: inherit;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 100%;
  top: 0;
  right: .5rem;
}
.select2-container--default.select2-container--focus .select2-selection--single {
  border-color: var(--iot-primary);
  box-shadow: 0 0 0 2px rgba(63, 81, 181, .15);
}

/* ========================================
   UTILITY
   ======================================== */
.text-primary-iot { color: var(--iot-primary) !important; }
.bg-primary-iot   { background: var(--iot-primary) !important; }
.btn-primary-iot  { background: var(--iot-primary); border-color: var(--iot-primary); color: #fff; }
.btn-primary-iot:hover { background: var(--iot-primary-dark); border-color: var(--iot-primary-dark); color: #fff; }
