:root {
  --bg-main: #050814;
  --bg-sidebar: #07111F;
  --bg-topbar: #060B18;
  --bg-card: #0B2136;
  --gold-primary: #D6A72D;
  --gold-highlight: #F5D36B;
  --text-primary: #F8F5EA;
  --text-secondary: #9AA7B4;
  --border-gold: rgba(214, 167, 45, 0.25);
  --gold-soft-bg: rgba(214, 167, 45, 0.1);
  --border-radius: 12px;
  --transition: all 0.3s ease;
}

/* Scoped Dashboard Wrapper */
.shenaco-theme {
  display: flex;
  height: 100vh;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  background-color: var(--bg-main);
  z-index: 1000;
}
.shenaco-theme * {
  box-sizing: border-box;
}

/* Sidebar */
.sidebar-v2 {
  font-family: 'Inter', 'Poppins', sans-serif;
  width: 280px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-gold);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 10;
  box-sizing: border-box;
}

.logo-container {
  height: 80px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-gold);
}

.logo-container h2 {
  color: var(--gold-primary);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
  margin: 0;
}

.logo-container span {
  color: var(--text-primary);
}

.menu-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
}

.menu-container::-webkit-scrollbar {
  width: 6px;
}

.menu-container::-webkit-scrollbar-thumb {
  background-color: var(--border-gold);
  border-radius: 4px;
}

.menu-item-v2 {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
  border-left: 3px solid transparent;
  gap: 12px;
  font-size: 14px;
}

.menu-item-v2 i {
  font-size: 20px;
}

.menu-item-v2:hover, .menu-item-v2.active {
  color: var(--gold-highlight);
  background-color: var(--gold-soft-bg);
  border-left-color: var(--gold-primary);
}

.menu-item-v2.active {
  font-weight: 600;
}

/* Main Content Wrapper */
.main-content-v2 {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-main);
}

/* Topbar */
.topbar-v2 {
  font-family: 'Inter', 'Poppins', sans-serif;
  height: 80px;
  background-color: var(--bg-topbar);
  border-bottom: 1px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  box-sizing: border-box;
}

.topbar-left .page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-left .page-title small {
  font-size: 14px;
  font-weight: 400;
  color: var(--gold-primary);
}

.breadcrumb-v2 {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.breadcrumb-v2 span {
  color: var(--gold-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.year-indicator {
  background-color: var(--bg-card);
  border: 1px solid var(--border-gold);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--gold-highlight);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding-left: 24px;
  border-left: 1px solid var(--border-gold);
  text-decoration: none;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--gold-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-main);
  font-weight: 700;
  font-size: 16px;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-role {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Dashboard Scrollable Area */
.dashboard-area {
  font-family: 'Inter', 'Poppins', sans-serif;
  color: var(--text-primary);
  flex: 1;
  padding: 32px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dashboard-area * {
  box-sizing: border-box;
}

/* Summary Cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.card-v2 {
  background-color: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--border-radius);
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  transition: var(--transition);
}

/* Dropdown Menu Styles */
.dropdown-menu {
    border-radius: 8px !important;
    overflow: hidden;
}

.dropdown-menu > li > a {
    transition: all 0.2s ease;
}

.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus {
    background-color: rgba(214, 167, 45, 0.1) !important;
    color: var(--gold-highlight) !important;
}

.card-v2:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(214, 167, 45, 0.1);
}

.card-info h3 {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 8px;
  margin-top: 0;
}

.card-info p {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background-color: var(--gold-soft-bg);
  color: var(--gold-highlight);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

/* Middle Layout */
.middle-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  flex: 1;
}

.section-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--border-radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.section-header {
  font-size: 18px;
  font-weight: 600;
  color: var(--gold-primary);
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Chart Area */
.chart-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  min-height: 300px;
}

/* Right Panel - Log Book */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
}

.log-item {
  display: flex;
  gap: 16px;
}

.log-time {
  min-width: 50px;
  font-size: 12px;
  color: var(--text-secondary);
  padding-top: 2px;
}

.log-line {
  position: relative;
  width: 2px;
  background-color: var(--border-gold);
}

.log-dot {
  position: absolute;
  top: 4px;
  left: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--gold-primary);
  box-shadow: 0 0 8px var(--gold-highlight);
}

.log-content {
  flex: 1;
  background-color: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.05);
  padding: 12px;
  border-radius: 8px;
}

.log-content h4 {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 4px;
  margin-top: 0;
}

.log-content p {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

/* Server Status */
.server-status {
  margin-top: 24px;
  padding: 16px;
  background-color: rgba(0,0,0,0.2);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.server-info h4 {
  font-size: 13px;
  color: var(--text-primary);
  margin: 0;
}

.server-info p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  margin-bottom: 0;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #4CAF50;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #4CAF50;
  box-shadow: 0 0 8px #4CAF50;
}

/* Footer */
footer.v2-footer {
  text-align: center;
  padding: 24px 0;
  font-size: 12px;
  color: var(--text-secondary);
  border-top: 1px solid rgba(255,255,255,0.05);
  font-family: 'Inter', sans-serif;
}

/* ==========================================================================
   GLOBAL LEGACY LAYOUT OVERRIDES
   These rules force the old AdminLTE wrappers across 40+ views to 
   position themselves exactly like the new V2 Flexbox layout.
   ========================================================================== */

body, body.skin-blue {
    background-color: var(--bg-main) !important;
}

/* Legacy typography and layout fixes */
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--text-primary) !important;
}
.box-title, label, .control-label, p {
    color: var(--text-primary);
}

/* Force header to stick to the right of the sidebar ONLY in legacy pages */
body > header.topbar-v2 {
    position: fixed !important;
    top: 0;
    right: 0;
    left: 280px !important;
    width: calc(100% - 280px) !important;
    z-index: 1030;
}

/* Force the legacy wrapper to just hold things without shifting */
.wrapper.row-offcanvas {
    padding-top: 0 !important;
    margin-top: 0 !important;
    display: block !important;
    background: transparent !important;
}

/* Sidebar positioned absolute left full height ONLY in legacy pages */
.wrapper > aside.sidebar-v2 {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh !important;
    z-index: 1040 !important;
}

/* Legacy Toolbar placed above tables */
.legacy-toolbar {
    position: fixed;
    top: 125px; /* Give breathing room below the two-tier topbar */
    left: 280px; /* Right of sidebar */
    width: calc(100% - 280px);
    background-color: var(--bg-main);
    padding: 12px 24px;
    z-index: 1020;
    border-bottom: 1px solid var(--border-gold);
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end; /* Move buttons to the right */
    flex-wrap: wrap; /* Allow wrapping if there are many buttons */
}

/* Adjust right-side to make room for the new toolbar */
.wrapper > aside.right-side {
    position: absolute !important;
    top: 125px !important; /* Default without legacy-toolbar */
    left: 280px !important; /* Right of sidebar */
    width: calc(100% - 280px) !important;
    height: calc(100vh - 125px) !important;
    margin-left: 0 !important;
    background-color: var(--bg-main) !important;
    overflow-y: auto !important;
    padding: 10px 24px 24px 24px; /* Give legacy content breathing room but reduce top gap */
}

/* Modifier when legacy-toolbar is present */
body.has-legacy-toolbar .wrapper > aside.right-side {
    top: 185px !important; /* 125px toolbar pos + 60px toolbar height */
    height: calc(100vh - 185px) !important;
}

/* Override old title elements inside legacy content to prevent duplication */
.right-side .content-header > h1, 
.right-side .judul > h1 {
    display: none !important; /* Title is now strictly in the topbar */
}

/* Modals Fixes for Dark Theme */
.modal-content, .modal-body, .modal-header, .modal-footer {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-gold) !important;
}

.modal-header .close {
    color: var(--text-primary) !important;
    opacity: 0.8;
    text-shadow: none;
}

.modal-title {
    color: var(--gold-primary) !important;
    font-weight: 600;
}

/* Ensure inputs inside modals have correct colors */
.modal-content input, 
.modal-content select, 
.modal-content textarea,
.modal-content .form-control {
    background-color: #111111 !important; /* Pure dark background */
    border: 1px solid var(--border-gold) !important;
    color: var(--gold-primary) !important; /* Gold text to make it stand out from white */
    font-weight: 500 !important;
}

.modal-content input:focus, 
.modal-content select:focus, 
.modal-content textarea:focus {
    border-color: var(--gold-highlight) !important;
    box-shadow: 0 0 5px rgba(214, 167, 45, 0.5) !important;
}

.modal-content input[readonly],
.modal-content input[disabled] {
    background-color: #222222 !important;
    color: var(--text-secondary) !important;
}

/* Fix dropdown options visibility */
.modal-content select option {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

/* Modal Buttons Fix */
.modal-footer .btn-secondary, 
.modal-footer .btn-default,
.modal-content .btn-secondary,
.modal-content .btn-default {
    background-color: #2C3E50 !important;
    color: var(--text-primary) !important;
    border: 1px solid #34495E !important;
}

.modal-footer .btn-secondary:hover, 
.modal-footer .btn-default:hover,
.modal-content .btn-secondary:hover,
.modal-content .btn-default:hover {
    background-color: #34495E !important;
}

button.close, .modal-header .close {
    color: var(--text-primary) !important;
    opacity: 0.8 !important;
    text-shadow: none !important;
    background: transparent !important;
}
button.close:hover, .modal-header .close:hover {
    color: var(--gold-highlight) !important;
    opacity: 1 !important;
}

/* ==========================================================================
   RESPONSIVE DESIGN FOR ANDROID / MOBILE DEVICES
   ========================================================================== */
@media screen and (max-width: 768px) {
  /* Sidebar adjustments */
  .sidebar-v2, .wrapper > aside.sidebar-v2 {
    left: -280px !important;
    transition: left 0.3s ease;
  }
  
  /* Class to toggle sidebar on mobile if needed */
  .sidebar-open .sidebar-v2, .sidebar-open .wrapper > aside.sidebar-v2 {
    left: 0 !important;
    z-index: 9999 !important;
  }

  /* Header and Toolbar full width */
  body > header.topbar-v2 {
    left: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 80px;
    flex-wrap: wrap;
    padding: 10px 16px;
    position: relative !important; /* Change from fixed to relative to avoid overlapping content */
    z-index: 1000 !important;
  }

  .legacy-toolbar {
    left: 0 !important;
    width: 100% !important;
    top: 0 !important; /* Reset top offset */
    margin-bottom: 15px; /* Add space below it instead */
    justify-content: flex-start;
    flex-wrap: wrap;
    position: relative !important;
    z-index: 900 !important;
  }

  /* Main content full width */
  .wrapper > aside.right-side,
  body.has-legacy-toolbar .wrapper > aside.right-side {
    left: 0 !important;
    width: 100% !important;
    top: 0 !important;
    position: relative !important;
    height: auto !important;
    overflow-y: visible !important;
    z-index: 1 !important; /* Ensure it's below modals but clickable */
  }

  .wrapper {
    padding-top: 0 !important; /* Remove padding since header is relative */
  }

  /* Dashboard grids */
  .summary-cards {
    grid-template-columns: 1fr;
  }
  
  .middle-layout {
    grid-template-columns: 1fr;
  }

  /* Topbar content wrapping */
  .topbar-right {
    width: 100%;
    margin-top: 10px;
    justify-content: space-between;
  }
  
  .user-profile {
    padding-left: 10px;
  }

  .logo-container {
    justify-content: center;
  }

  .dashboard-area {
    padding: 16px;
  }
  
  .card-v2 {
    padding: 16px;
  }
  
  /* Tables and overflows */
  .box-body, .table-responsive, .card-v2 {
    overflow-x: auto !important;
  }
  }
}

/* ==========================================================================
   DATATABLES DARK THEME OVERRIDES
   ========================================================================== */
.dataTables_wrapper .dataTables_filter label,
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_info {
    color: var(--text-primary) !important;
}

.dataTables_wrapper .dataTables_paginate .pagination > li > a,
.dataTables_wrapper .dataTables_paginate .pagination > li > span {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-gold) !important;
}

.dataTables_wrapper .dataTables_paginate .pagination > li.active > a,
.dataTables_wrapper .dataTables_paginate .pagination > li.active > span,
.dataTables_wrapper .dataTables_paginate .pagination > li > a:hover,
.dataTables_wrapper .dataTables_paginate .pagination > li > span:hover {
    background-color: var(--gold-primary) !important;
    color: var(--bg-main) !important;
    border-color: var(--gold-primary) !important;
}

.dataTables_wrapper .dataTables_paginate .pagination > li.disabled > a,
.dataTables_wrapper .dataTables_paginate .pagination > li.disabled > span {
    color: var(--text-secondary) !important;
    background-color: rgba(255,255,255,0.05) !important;
    border-color: var(--border-gold) !important;
}

.dataTables_wrapper input[type="search"],
.dataTables_wrapper select {
    background-color: #111111 !important;
    color: var(--gold-primary) !important;
    border: 1px solid var(--border-gold) !important;
    border-radius: 4px;
    padding: 4px 8px;
}
.dataTables_wrapper input[type="search"]:focus,
.dataTables_wrapper select:focus {
    border-color: var(--gold-highlight) !important;
    box-shadow: 0 0 5px rgba(214, 167, 45, 0.5) !important;
    outline: none;
}

/* ==========================================================================
   GLOBAL FORM & TABLE OVERRIDES
   ========================================================================== */
.box, .nav-tabs-custom, .tab-content {
    background-color: var(--bg-card) !important;
    border-top-color: var(--gold-primary) !important;
    color: var(--text-primary) !important;
}
.nav-tabs-custom > .nav-tabs > li > a {
    color: var(--text-secondary) !important;
}
.nav-tabs-custom > .nav-tabs > li.active > a {
    background-color: var(--bg-main) !important;
    color: var(--gold-primary) !important;
}

.table, .table td, .table th {
    color: var(--text-primary) !important;
    background-color: transparent !important;
}

.table-striped > tbody > tr:nth-of-type(odd) {
    background-color: rgba(255,255,255,0.05) !important;
}

.table-hover > tbody > tr:hover {
    background-color: rgba(214, 167, 45, 0.15) !important;
}

.input-group-addon {
    background-color: #111111 !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-gold) !important;
}
.input-group-addon b, .input-group-addon label {
    color: var(--text-primary) !important;
}
