/* ==========================================================================
   FV DIESEL - PREMIUM HIGH-CONTRAST SAAS DESIGN SYSTEM
   ========================================================================== */

:root {
  --primary-dark: #090d16;   /* Deep charcoal dark */
  --primary-mid:  #0f172a;   /* Sidebar dark */
  --primary-light: #1e293b;  /* Sidebar hover item */
  --accent: #2563eb;         /* Bright premium blue */
  --accent-hover: #1d4ed8;   /* Darker premium blue */
  --bg: #e2e8f0;             /* Darker slate background for high card contrast */
  --card: #ffffff;           /* Clear white cards */
  --text-main: #0f172a;      /* Dark text */
  --text-muted: #475569;     /* Slate text */
  --border-color: #cbd5e1;   /* Stronger gray borders for separation */
  --success: #059669;        /* Deep green */
  --danger: #dc2626;         /* Deep red */
  --warning: #d97706;        /* Deep gold */
}

* {
  box-sizing: border-box;
}

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

/* ==========================================================================
   LAYOUT GRID (RESPONSIVE SIDEBAR / OFF-CANVAS)
   ========================================================================== */

.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Desktop Sidebar */
.app-sidebar {
  width: 280px;
  background: var(--primary-mid);
  color: #fff;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Navigation Links */
.nav-link-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: #cbd5e1; /* Much brighter slate/white for high visibility */
  text-decoration: none;
  border-radius: 10px;
  font-size: 0.925rem;
  font-weight: 600; /* Slightly bolder for better legibility */
  margin-bottom: 4px;
  transition: all 0.2s ease;
}

.menu-category-title {
  color: #94a3b8 !important; /* Brighter gray for visible section headers */
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.nav-link-item i {
  font-size: 1.1rem;
}

.nav-link-item:hover {
  background: var(--primary-light);
  color: #fff;
}

.nav-link-item.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

/* Content Area */
.app-content {
  flex: 1 1 auto;
  min-width: 0;
  max-width: calc(100vw - 280px);
  width: calc(100% - 280px);
  margin-left: 280px;
  background: var(--bg);
  min-height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

/* Top Navigation Bar on Mobile */
.mobile-navbar {
  display: none;
  background: var(--primary-mid);
  padding: 16px 24px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  z-index: 1050;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Mobile styles */
@media (max-width: 991.98px) {
  .app-sidebar {
    display: none;
  }
  .app-content {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
    padding: 16px;
    padding-top: 80px;
  }
  .mobile-navbar {
    display: flex;
  }
}

/* ==========================================================================
   UI COMPONENTS
   ========================================================================== */

/* Page Headers */
.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 4px;
}

/* Cards (Higher contrast borders and deeper shadows) */
.card {
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
  margin-bottom: 24px;
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.card-header {
  background: #f8fafc;
  border-bottom: 1.5px solid var(--border-color);
  padding: 16px 20px;
  border-top-left-radius: 15px;
  border-top-right-radius: 15px;
}

.card-body {
  padding: 20px;
}

/* Tables (Highly visible headers, clear row borders) */
.table {
  width: 100%;
  margin-bottom: 0;
  vertical-align: middle;
}

.table th {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.8px;
  color: #334155;
  background: #e2e8f0; /* Darker header background */
  padding: 14px 18px;
  border-bottom: 2.5px solid var(--border-color);
}

.table td {
  padding: 14px 18px;
  border-bottom: 1.5px solid var(--border-color);
  color: var(--text-main);
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: #f8fafc;
}

.table-hover tbody tr:hover {
  background-color: #e2e8f0;
}

/* Responsive Table Wrapper Borders */
.table-responsive {
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

/* Custom Scrollbar para as Tabelas no Mobile */
.table-responsive::-webkit-scrollbar {
  height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 0 0 12px 12px;
}
.table-responsive::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 12px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Badges */
.badge-soft {
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent);
  border: 1px solid rgba(37, 99, 235, 0.25);
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
}

.badge-success-soft {
  background: rgba(5, 150, 105, 0.1);
  color: var(--success);
  border: 1px solid rgba(5, 150, 105, 0.25);
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
}

.badge-danger-soft {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.25);
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
}

.badge-warning-soft {
  background: rgba(217, 119, 6, 0.1);
  color: var(--warning);
  border: 1px solid rgba(217, 119, 6, 0.25);
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
}

/* ==========================================================================
   ULTRA-PREMIUM GLOBAL BUTTON STANDARDIZATION SYSTEM
   ========================================================================== */

.btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  min-height: 38px !important;
  height: 38px !important;
  padding: 0 16px !important;
  font-size: 0.875rem !important; /* 14px */
  font-weight: 600 !important;
  line-height: 1 !important;
  white-space: nowrap !important;
  border-radius: 8px !important;
  border: 1.5px solid transparent !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
  cursor: pointer !important;
  text-decoration: none !important;
  vertical-align: middle !important;
  box-sizing: border-box !important;
}

.btn:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12) !important;
}

.btn:active {
  transform: translateY(0) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

.btn i, .btn svg {
  font-size: 1em !important;
  line-height: 1 !important;
  flex-shrink: 0 !important;
}

/* Small Buttons (.btn-sm) - Used for Table Actions & Compact UI */
.btn-sm {
  min-height: 32px !important;
  height: 32px !important;
  max-height: 32px !important;
  padding: 0 12px !important;
  font-size: 0.8rem !important; /* 12.8px */
  font-weight: 600 !important;
  border-radius: 6px !important;
}

/* Large Buttons (.btn-lg) - Used for Form Submits & Page CTAs */
.btn-lg {
  min-height: 46px !important;
  height: 46px !important;
  padding: 0 24px !important;
  font-size: 0.95rem !important;
  font-weight: 700 !important;
  border-radius: 10px !important;
}

/* Variant Color Palette Standardization */
.btn-primary {
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #ffffff !important;
}
.btn-primary:hover {
  background-color: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
  color: #ffffff !important;
}

.btn-dark {
  background-color: var(--primary-mid) !important;
  border-color: var(--primary-mid) !important;
  color: #ffffff !important;
}
.btn-dark:hover {
  background-color: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
  color: #ffffff !important;
}

.btn-secondary {
  background-color: #475569 !important;
  border-color: #475569 !important;
  color: #ffffff !important;
}
.btn-secondary:hover {
  background-color: #334155 !important;
  border-color: #334155 !important;
  color: #ffffff !important;
}

.btn-success {
  background-color: #059669 !important;
  border-color: #059669 !important;
  color: #ffffff !important;
}
.btn-success:hover {
  background-color: #047857 !important;
  border-color: #047857 !important;
  color: #ffffff !important;
}

.btn-danger {
  background-color: #dc2626 !important;
  border-color: #dc2626 !important;
  color: #ffffff !important;
}
.btn-danger:hover {
  background-color: #b91c1c !important;
  border-color: #b91c1c !important;
  color: #ffffff !important;
}

.btn-warning {
  background-color: #d97706 !important;
  border-color: #d97706 !important;
  color: #ffffff !important;
}
.btn-warning:hover {
  background-color: #b45309 !important;
  border-color: #b45309 !important;
  color: #ffffff !important;
}

.btn-outline-primary {
  background-color: transparent !important;
  border: 1.5px solid var(--accent) !important;
  color: var(--accent) !important;
}
.btn-outline-primary:hover {
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #ffffff !important;
}

.btn-outline-secondary {
  background-color: transparent !important;
  border: 1.5px solid #94a3b8 !important;
  color: #475569 !important;
}
.btn-outline-secondary:hover {
  background-color: #94a3b8 !important;
  border-color: #94a3b8 !important;
  color: #ffffff !important;
}

.btn-outline-danger {
  background-color: transparent !important;
  border: 1.5px solid #dc2626 !important;
  color: #dc2626 !important;
}
.btn-outline-danger:hover {
  background-color: #dc2626 !important;
  border-color: #dc2626 !important;
  color: #ffffff !important;
}

.btn-outline-dark {
  background-color: transparent !important;
  border: 1.5px solid var(--primary-mid) !important;
  color: var(--primary-mid) !important;
}
.btn-outline-dark:hover {
  background-color: var(--primary-mid) !important;
  border-color: var(--primary-mid) !important;
  color: #ffffff !important;
}

/* ==========================================================================
   TABLE ACTION BUTTONS STANDARDIZATION (DESKTOP, TABLET & MOBILE)
   ========================================================================== */

/* Align buttons cleanly side-by-side in table cells */
.table td.text-end,
.table td.text-center,
.btn-action-group {
  white-space: nowrap;
}

.table td form,
.btn-action-group form {
  display: inline-block !important;
  margin: 0 !important;
  padding: 0 !important;
}

.table td .btn,
.table td form .btn,
.btn-action-group .btn,
.btn-action-group form .btn {
  margin: 2px 2px !important;
}

/* Tablet & Mobile Responsiveness (< 768px) */
@media (max-width: 767.98px) {
  /* Cells with action buttons stack buttons at 100% width with identical heights & radiuses */
  .table td:has(.btn),
  .table td.text-end:has(.btn),
  .btn-action-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 5px !important;
    align-items: stretch !important;
    justify-content: center !important;
    min-width: 100px;
  }
  
  .table td:has(.btn) > .btn,
  .table td:has(.btn) > a.btn,
  .table td:has(.btn) > button.btn,
  .table td:has(.btn) > form,
  .table td:has(.btn) > form > button.btn,
  .btn-action-group > .btn,
  .btn-action-group > form,
  .btn-action-group > form > .btn {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
  }
}

/* Forms */
.form-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-control, .form-select {
  border-radius: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-main);
  background-color: #fff;
  transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  outline: none;
}

/* KPI Widgets */
.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi .value {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text-main);
}

.kpi .value.accent {
  color: var(--accent);
}

.kpi .hint {
  color: var(--text-muted);
  font-size: 0.825rem;
  font-weight: 600;
}

/* ==========================================================================
   LOGIN PAGE BEAUTIFICATION
   ========================================================================== */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top right, #1e293b, #090d16);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 460px;
  border-radius: 20px;
  background: #ffffff;
  border: none;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.login-header {
  padding: 40px 40px 20px 40px;
  text-align: center;
}

.login-header .brand {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--primary-mid);
}

.login-header .mini {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 6px;
}

.login-form {
  padding: 0 40px 40px 40px;
}

/* ==========================================================================
   TABLET & MOBILE RESPONSIVE OPTIMIZATION SYSTEM
   ========================================================================== */

/* Glassmorphism & Elevation System */
.shadow-sm { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04) !important; }
.shadow-md { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08) !important; }
.shadow-lg { box-shadow: 0 16px 36px rgba(0, 0, 0, 0.12) !important; }

/* Select2 Touch & Tablet Optimization */
.select2-container--default .select2-selection--single {
  height: 44px !important;
  border-radius: 10px !important;
  border: 1.5px solid var(--border-color) !important;
  display: flex !important;
  align-items: center !important;
  padding-left: 6px !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 44px !important;
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  color: var(--text-main) !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 42px !important;
}
.select2-dropdown {
  border-radius: 12px !important;
  border: 1.5px solid var(--border-color) !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15) !important;
  overflow: hidden !important;
  z-index: 1075 !important;
}
.select2-results__option {
  padding: 10px 14px !important;
  font-size: 0.9rem !important;
}

/* Touch Targets for Buttons and Inputs */
.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  font-weight: 600;
}
.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.825rem;
}
.form-control, .form-select {
  min-height: 44px;
  border-radius: 10px;
}

/* Mobile Navbar Glass Effect */
.mobile-navbar {
  background: rgba(15, 23, 42, 0.95) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Responsive Table Touch Scroll & Wrap */
.table-responsive {
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1.5px solid var(--border-color);
  background: #ffffff;
  width: 100%;
}
.table {
  width: 100%;
  max-width: 100%;
}

/* 5th Column Grid for Tablet / Mobile */
@media (min-width: 992px) {
  .col-lg-5th {
    width: 20%;
    flex: 0 0 20%;
  }
}
@media (min-width: 768px) and (max-width: 991.98px) {
  .col-lg-5th {
    width: 33.333%;
    flex: 0 0 33.333%;
  }
}
@media (max-width: 767.98px) {
  .col-lg-5th {
    width: 50%;
    flex: 0 0 50%;
  }
}
@media (max-width: 480px) {
  .col-lg-5th {
    width: 100%;
    flex: 0 0 100%;
  }
}

/* Tablet & iPad Specific Optimization (768px to 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  body {
    font-size: 13.5px !important;
  }
  .app-content {
    padding: 16px !important;
  }
  .card-body {
    padding: 16px !important;
  }
  .page-title {
    font-size: 1.4rem !important;
  }
  .table th {
    padding: 10px 10px !important;
    font-size: 0.72rem !important;
    letter-spacing: 0.5px !important;
  }
  .table td {
    padding: 10px 10px !important;
    font-size: 0.825rem !important;
  }
  .btn-group {
    flex-wrap: wrap;
  }
}

/* Smartphone & Mobile Optimization (< 768px) */
@media (max-width: 767.98px) {
  body {
    font-size: 12px !important;
  }
  .app-content {
    margin-left: 0 !important;
    padding: 8px !important;
    padding-top: 72px !important;
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  .page-title {
    font-size: 1.25rem !important;
  }
  .card-body {
    padding: 10px !important;
  }
  .table th {
    padding: 6px 6px !important;
    font-size: 0.65rem !important;
    letter-spacing: 0px !important;
  }
  .table td {
    padding: 6px 6px !important;
    font-size: 0.75rem !important;
  }
  .modal-dialog {
    margin: 8px !important;
  }
  .btn-mobile-block {
    width: 100% !important;
    margin-bottom: 6px;
  }
}

/* Ensure smooth touch table scrolling across all screens */
.table-responsive {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
}
.table-responsive table {
  min-width: 100%;
}

/* ==========================================================================
   FORM TABLES & EDITABLE OS TABLES RESPONSIVENESS SYSTEM (#tblItens)
   ========================================================================== */

#tblItens {
  min-width: 800px !important;
  width: 100% !important;
}

#tblItens th,
#tblItens td {
  vertical-align: middle !important;
  padding: 8px 6px !important;
}

#tblItens th:nth-child(1), #tblItens td:nth-child(1) { min-width: 240px !important; }
#tblItens th:nth-child(2), #tblItens td:nth-child(2) { min-width: 75px !important; }
#tblItens th:nth-child(3), #tblItens td:nth-child(3) { min-width: 110px !important; }
#tblItens th:nth-child(4), #tblItens td:nth-child(4) { min-width: 95px !important; }
#tblItens th:nth-child(5), #tblItens td:nth-child(5) { min-width: 100px !important; }
#tblItens th:nth-child(6), #tblItens td:nth-child(6) { min-width: 110px !important; }
#tblItens th:nth-child(7), #tblItens td:nth-child(7) { min-width: 45px !important; }

#tblItens .form-control,
#tblItens .form-select {
  min-height: 38px !important;
  height: 38px !important;
  padding: 4px 8px !important;
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  width: 100% !important;
}

#tblItens .select2-container {
  width: 100% !important;
  min-width: 230px !important;
}

/* Modal Max Heights for Mobile & Tablets */
@media (max-height: 700px) {
  .modal-body {
    max-height: 75vh;
    overflow-y: auto;
  }
}