/* ============================================
   MS Building - Native App Hybrid UI
   End-to-End Mobile Primary Design
   ============================================ */

:root {
  /* Premium Native Theme */
  --primary: #1e3a8a; /* Deep Indigo */
  --primary-light: #3b82f6;
  --secondary: #64748b;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #0ea5e9;

  /* Native Surfaces */
  --bg-body: #f1f5f9;
  --bg-sidebar: #0f172a;
  --bg-card: #ffffff;
  --bg-topbar: #ffffff;
  --bg-nav: #ffffff;
  
  /* Typography */
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #ffffff;
  
  /* Precision Borders & Shadows */
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-app: 0 -2px 10px rgba(0, 0, 0, 0.05);
  
  /* Sizing */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --sidebar-width: 280px;
  --topbar-height: 60px;
  --bottomnav-height: 65px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Scrollbar Handling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.1);
  border-radius: 10px;
}

/* ============================================
   Native App Header
   ============================================ */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.page-title {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-main);
}

/* ============================================
   Sidebar (Classic App)
   ============================================ */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-light);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
  padding: 24px;
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo i {
  font-size: 1.8rem;
  color: #3b82f6;
}

.sidebar-logo h5 {
  margin: 0;
  font-weight: 700;
  font-size: 1.1rem;
}

.sidebar-nav {
  flex: 1;
  padding: 15px 10px;
  overflow-y: auto;
}

/* ============================================
   Section Headers (Native App Look)
   ============================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 8px 0;
  gap: 16px;
  flex-wrap: wrap; /* Prevent overlap */
}

.section-header h5 {
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  letter-spacing: -0.02em;
}

.section-header h5 i {
  color: var(--primary-light);
  line-height: 1;
  font-size: 1.8rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: #94a3b8;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
  margin-bottom: 2px;
  text-decoration: none;
}

.sidebar-nav .nav-link:hover, .sidebar-nav .nav-link.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  border-left: 4px solid var(--primary-light);
  padding-left: 12px;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 1040;
}

/* ============================================
   Grid & Layout
   ============================================ */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 0;
  min-height: 100vh;
  transition: margin 0.3s;
}

.content-wrapper {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
  padding-bottom: 100px; /* Space for bottom nav */
}

/* ============================================
   Metric Cards (Mobile Fixed for Overflow)
   ============================================ */
.metric-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  height: 100%;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.metric-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.metric-value {
  font-size: 1.2rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
  line-height: 1.2;
}

.metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.metric-icon.primary { background: #eff6ff; color: #1e40af; }
.metric-icon.info { background: #f0f9ff; color: #0369a1; }
.metric-icon.success { background: #f0fdf4; color: #15803d; }
.metric-icon.warning { background: #fffbeb; color: #b45309; }
.metric-icon.danger { background: #fef2f2; color: #b91c1c; }
.metric-icon.accent { background: #fdf4ff; color: #a21caf; }

/* ============================================
   Cards & Content
   ============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
}

.card-header i {
  font-size: 1.25rem;
  color: var(--primary-light);
  opacity: 0.9;
}

/* Tables (Mobile Aware) */
.table-responsive {
  border: 0;
  padding: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  margin-bottom: 0;
  vertical-align: middle;
  border-collapse: separate;
  border-spacing: 0;
}

.table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table td {
  padding: 14px 16px;
  font-size: 0.9rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.table tr:last-child td {
  border-bottom: 0;
}

.table-hover tbody tr:hover {
  background-color: rgba(30, 58, 138, 0.02);
}

/* Specific Column Sizing */
.table th:first-child, .table td:first-child {
  width: 50px;
  padding-left: 20px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.table th:last-child, .table td:last-child {
  padding-right: 20px;
  text-align: right;
  white-space: nowrap;
  width: 1%;
}

.btn-action + .btn-action {
  margin-left: 6px;
}

/* ============================================
   Bottom Navigation (Native Native Style)
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottomnav-height);
  background: var(--bg-nav);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 1030;
  box-shadow: var(--shadow-app);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 600;
  flex: 1;
  gap: 4px;
  transition: color 0.2s;
}

.bottom-nav-item i {
  font-size: 1.4rem;
}

.bottom-nav-item.active {
  color: var(--primary-light);
}

/* FAB - App Style */
.fab-btn {
  position: fixed;
  bottom: calc(var(--bottomnav-height) + 20px);
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--primary-light);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  z-index: 1025;
  border: none;
}

/* ============================================
   Forms & Buttons (Native Touch)
   ============================================ */
.form-control, .form-select {
  height: 48px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 16px;
  font-size: 1rem;
  background-color: #f8fafc;
}

.form-control:focus {
  background-color: #fff;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.btn {
  padding: 10px 20px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-sm {
  height: 32px;
  padding: 0 10px;
  font-size: 0.85rem;
  gap: 4px;
}

.btn-action {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.btn-primary { background: var(--primary-light); border: none; color: #fff; }
.btn-primary:hover { background: var(--primary); color: #fff; }

/* ============================================
   Responsive Tweaks
   ============================================ */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; }
  
  .top-bar {
    height: 70px;
    padding: 0 16px;
    position: sticky;
    top: 0;
  }
  
  .page-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.05rem;
  }
  
  .content-wrapper {
    padding: 16px;
    padding-bottom: 120px;
  }
  
  /* Table Button Fixes */
  .btn-action {
    margin-bottom: 0;
  }
  
  .table td {
    padding: 12px 10px;
  }
  
  /* Stack metrics better on mobile */
  .col-6 { padding: 4px; }
  .metric-card { padding: 12px; }
  .metric-icon { width: 36px; height: 36px; min-width: 36px; font-size: 1.1rem; }
  .metric-value { font-size: 1rem; }
  .metric-label { font-size: 0.6rem; }
}

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeInUp 0.4s ease-out forwards;
}

/* Badges */
.badge {
  padding: 6px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 6px;
  text-transform: uppercase;
}

/* Offcanvas Native Look */
#detailsOffcanvas {
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
}

.detail-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}
.detail-label { color: var(--text-muted); font-size: 0.65rem; font-weight: 700; text-transform: uppercase; margin-bottom: 2px;}
.detail-value { color: var(--text-main); font-weight: 600; font-size: 1rem; }

/* Filter Bar App Style */
.filter-bar {
  display: flex !important;
  align-items: center;
  overflow-x: auto;
  gap: 12px;
  padding: 16px;
  margin-bottom: 24px;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  scrollbar-width: none;
  width: 100%;
}
.filter-bar::-webkit-scrollbar { display: none; }

.filter-bar .form-select, 
.filter-bar .form-control,
.filter-bar .btn {
  min-width: 150px;
  height: 48px !important;
  flex: 1 1 auto;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0 16px;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  color: var(--text-main);
  transition: all 0.2s ease;
  box-shadow: none;
}

.filter-bar .form-select:focus, 
.filter-bar .form-control:focus {
  background-color: #fff;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
  outline: none;
}

.filter-bar input[type="month"] {
  cursor: pointer;
  position: relative;
}

/* Print Handling */
@media print {
  .no-print { display: none !important; }
}

/* ============================================
   Status Tabs UI
   ============================================ */
.status-tabs-container {
    padding: 4px;
    background: #e2e8f0;
    border-radius: 14px;
    display: inline-flex;
    width: 100%;
    max-width: 600px;
}

.status-tabs {
    display: flex;
    width: 100%;
    gap: 4px;
}

.status-tab {
    flex: 1;
    text-align: center;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.status-tab:hover {
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-main);
}

.status-tab.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.status-tab .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.success { background-color: var(--success); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); }
.status-dot.warning { background-color: var(--warning); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2); }
.status-dot.danger { background-color: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2); }

@media (max-width: 576px) {
    .status-tab {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  .filter-bar {
    padding: 12px;
    gap: 8px;
    border-radius: 12px;
  }
  .filter-bar .form-select, 
  .filter-bar .form-control {
    min-width: 130px;
    height: 44px !important;
    font-size: 0.85rem;
  }
}

/* ============================================
   Luxury Login Page
   ============================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  position: relative;
  overflow: hidden;
}

/* Decorative Background Elements */
.login-page::before, .login-page::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  filter: blur(80px);
  z-index: 0;
}
.login-page::before {
  width: 400px;
  height: 400px;
  top: -100px;
  right: -100px;
}
.login-page::after {
  width: 300px;
  height: 300px;
  bottom: -50px;
  left: -50px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  padding: 40px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  position: relative;
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header .icon {
  width: 72px;
  height: 72px;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin: 0 auto 16px;
  box-shadow: 0 10px 20px rgba(30, 58, 138, 0.3);
}

.login-header h3 {
  font-weight: 800;
  font-size: 1.75rem;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.login-body .form-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.login-body .input-group-text {
  background: #f8fafc;
  border-right: none;
  color: var(--primary-light);
  border-radius: 12px 0 0 12px;
  border: 1px solid #e2e8f0;
}

.login-body .form-control {
  height: 52px;
  border-left: none;
  border-radius: 0 12px 12px 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-weight: 500;
}

.login-body .form-control:focus {
  background: #fff;
  box-shadow: none;
  border-color: #e2e8f0;
}

.login-body .input-group:focus-within .input-group-text,
.login-body .input-group:focus-within .form-control {
  border-color: var(--primary-light);
}

.login-body .input-group:focus-within .input-group-text {
  background: #fff;
}

/* Password Toggle Specific */
.login-body #passwordToggleBtn {
  border-left: none;
  border-radius: 0 12px 12px 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 0 16px;
}
.login-body #password {
  border-radius: 0;
}

.login-btn {
  height: 54px;
  border-radius: 14px;
  font-size: 1.1rem;
  background: var(--primary);
  border: none;
  box-shadow: 0 8px 16px rgba(30, 58, 138, 0.25);
  transition: all 0.3s ease;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 20px rgba(30, 58, 138, 0.35);
  background: var(--primary-light);
}

@media (max-width: 480px) {
  .login-card {
    padding: 30px 20px;
    border-radius: 20px;
  }
}
