﻿/* Font Import */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Industry-grade dark theme palette for sidebar */
  --primary: #3b82f6;
  /* More vibrant blue */
  --primary-dark: #2563eb;

  --bg-body: #f1f5f9;
  /* Slate 100 */
  --bg-sidebar: #0f172a;
  /* Slate 900 (Dark) */
  --bg-sidebar-hover: #1e293b;
  /* Slate 800 */

  --text-main: #334155;
  /* Slate 700 */
  --text-muted: #64748b;
  /* Slate 500 */

  --sidebar-text: #94a3b8;
  /* Slate 400 */
  --sidebar-text-hover: #ffffff;

  --border: #e2e8f0;
  --border-dark: #1e293b;

  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* Sidebar (Dark Theme) */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-dark);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  z-index: 50;
  color: var(--sidebar-text);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-x: hidden;
  /* Hide overflow during transition */
}

.sidebar.collapsed {
  width: 70px;
}

.sidebar.collapsed .brand-logo span,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .user-profile>div:nth-child(2),
.sidebar.collapsed .nav-sub {
  display: none !important;
}

.sidebar.collapsed .brand {
  padding: 24px 0;
  justify-content: center;
}

.sidebar.collapsed .brand-logo {
  margin: 0;
}

.sidebar.collapsed .nav-link-main {
  justify-content: center;
  padding: 10px 0;
}

.sidebar.collapsed .nav-link-main i {
  margin: 0;
  font-size: 1.3rem;
}

.sidebar.collapsed .user-profile {
  padding: 16px 0;
  justify-content: center;
}

.sidebar.collapsed .user-profile>div:first-child {
  margin: 0;
}

.sidebar.collapsed .user-profile button {
  display: none;
}

.brand {
  padding: 24px;
  /* border-bottom: 1px solid var(--border-dark); */
  display: flex;
  align-items: center;
  justify-content: center;
  /* Center Logo */
  margin-bottom: 10px;
}

.brand-logo {
  height: 40px;
  width: auto;
  /* In case image fails */
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
  letter-spacing: -0.5px;
}

.nav-links {
  list-style: none;
  padding: 0 12px;
  margin: 0;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  margin-bottom: 4px;
}

.nav-link-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.nav-link-main i {
  font-size: 1.1rem;
  color: var(--sidebar-text);
  opacity: 0.7;
  transition: color 0.2s;
}

.nav-link-main:hover {
  background-color: var(--bg-sidebar-hover);
  color: var(--sidebar-text-hover);
}

.nav-link-main:hover i {
  color: var(--sidebar-text-hover);
  opacity: 1;
}

.nav-item.active .nav-link-main {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  /* Glow effect */
}

.nav-item.active .nav-link-main i {
  color: white;
  opacity: 1;
}

/* Sub-Menu */
.nav-sub {
  list-style: none;
  padding: 4px 0 4px 10px;
  margin: 0 0 0 20px;
  display: none;
  border-left: 1px solid var(--border-dark);
}

.nav-item.active .nav-sub {
  display: block;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sub-link {
  display: block;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: color 0.15s;
  border-radius: 4px;
}

.sub-link:hover {
  color: white;
  background: rgba(255, 255, 255, 0.05);
}

.user-profile {
  padding: 16px 24px;
  border-top: 1px solid var(--border-dark);
  background: var(--bg-sidebar-hover);
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
}

/* Main Content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: var(--text-main);
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  background-color: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: #f8fafc;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-outline {
  background-color: white;
  border-color: var(--border);
  color: var(--text-main);
}

.btn-outline:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: white;
  padding: 32px;
  border-radius: 16px;
  width: 500px;
  max-width: 90%;
  max-height: 90vh;
  /* Prevent overflow on small screens */
  overflow-y: auto;
  /* Enable scroll if content is too long */
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Cute Global Loader (Progress Bar Modern) */
#global-loader {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

#global-loader.visible {
  opacity: 1;
  pointer-events: all;
}

/* No Card - Floating Layout */
.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: floatUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.loader-icon-container {
  position: relative;
  margin-bottom: 24px;
}

.loader-icon {
  font-size: 3.5rem;
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: pulseGradient 3s ease infinite;
  filter: drop-shadow(0 8px 16px rgba(168, 85, 247, 0.25));
  z-index: 2;
  position: relative;
}

.loader-glow {
  position: absolute;
  inset: -10px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.5) 0%, transparent 70%);
  filter: blur(12px);
  z-index: 1;
  animation: breathe 3s ease-in-out infinite;
}

.loader-text {
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: -0.5px;
  color: #1e293b;
  margin-bottom: 4px;
  background: linear-gradient(90deg, #1e293b, #475569);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.loader-sub {
  font-size: 1rem;
  color: #64748b;
  font-weight: 500;
  margin-bottom: 24px;
  opacity: 0.9;
}

/* Progress Bar */
.loader-progress-container {
  width: 240px;
  height: 6px;
  background: rgba(203, 213, 225, 0.4);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.loader-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, #6366f1, #ec4899);
  border-radius: 99px;
  animation: progressIndeterminate 1.5s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

@keyframes progressIndeterminate {
  0% {
    left: -40%;
    width: 40%;
  }

  50% {
    left: 30%;
    width: 60%;
  }

  100% {
    left: 100%;
    width: 10%;
  }
}

@keyframes floatUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pulseGradient {
  0% {
    transform: scale(1);
    filter: brightness(100%);
  }

  50% {
    transform: scale(1.05);
    filter: brightness(120%);
  }

  100% {
    transform: scale(1);
    filter: brightness(100%);
  }
}

@keyframes breathe {
  0% {
    opacity: 0.5;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1.2);
  }

  100% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

/* =========================================
   MOBILE APP EXPERIENCE V2 (PREMIUM OVERRIDES)
   ========================================= */

@media (max-width: 768px) {

  /* 1. Global Reset & Premium Feel (LIGHT MODE) */
  body {
    padding-bottom: 90px !important;
    /* Space for Nav + Safe Area */
    padding-left: 0 !important;
    background: #f8fafc !important;
    /* Light Premium BG */
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar,
  .top-nav,
  .desktop-only,
  #sidebarToggle {
    display: none !important;
  }

  #contentArea,
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 16px !important;
  }

  /* 2. Glassmorphism Bottom Nav (Light) */
  .mobile-nav {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    border-top: 1px solid #e2e8f0 !important;
    height: 75px !important;
    bottom: 0 !important;
    position: fixed !important;
    width: 100% !important;
    left: 0 !important;
    z-index: 99999 !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1) !important;
  }

  .nav-item {
    color: #64748b !important;
    font-size: 10px !important;
    font-weight: 500 !important;
    gap: 6px !important;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-decoration: none !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  .nav-item i {
    font-size: 1.4rem !important;
    margin-bottom: 0 !important;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  }

  /* Active State */
  .nav-item.active {
    color: #2563eb !important;
    /* Premium Blue */
  }

  .nav-item.active i {
    transform: translateY(-4px) scale(1.1);
    color: #2563eb !important;
    filter: drop-shadow(0 0 8px rgba(37, 99, 235, 0.3));
  }

  .nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 8px;
    width: 4px;
    height: 4px;
    background: #2563eb;
    border-radius: 50%;
    box-shadow: 0 0 8px #2563eb;
  }

  /* 3. Planning Cards (Premium Light) */
  .card-mobile {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 16px !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
    margin-bottom: 20px !important;
    overflow: hidden;
  }

  .card-mobile-header {
    background: #f8fafc;
    padding: 15px !important;
    border-bottom: 1px solid #e2e8f0;
    color: #1e293b !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .job-card {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    margin-top: 10px;
    margin-bottom: 10px;
    padding: 16px !important;
    position: relative;
  }

  .job-card.running::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #10b981;
    /* Emerald */
    box-shadow: 2px 0 12px rgba(16, 185, 129, 0.3);
  }

  .job-title {
    color: #0f172a !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    margin-bottom: 8px !important;
    padding-left: 10px !important;
    line-height: 1.3;
  }

  .job-meta {
    padding-left: 10px !important;
    color: #64748b !important;
    font-size: 0.85rem !important;
    display: flex;
    justify-content: space-between;
  }

  /* 4. Inputs */
  input,
  select {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
    border-radius: 12px !important;
    padding: 14px !important;
    font-size: 16px !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  }

  /* 5. Modals */
  .modal-content {
    background: #ffffff !important;
    border: none !important;
  }
}

/* =========================================
   MOBILE APP EXPERIENCE V4 (FINAL CONSOLIDATED)
   ========================================= */

@media (max-width: 768px) {

  /* 1. APP SHELL LAYOUT (Native Feel - Light) */
  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    /* Lock body scroll */
    background-color: #f8fafc !important;
    -webkit-tap-highlight-color: transparent;
  }

  /* Scrollable Content Area */
  .main-content,
  #contentArea,
  #pageContent {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 70px !important;
    /* Space for Bottom Nav */
    overflow-y: auto !important;
    /* Internal Scroll */
    -webkit-overflow-scrolling: touch !important;
    padding: 16px !important;
    width: 100% !important;
    margin: 0 !important;
    z-index: 10 !important;
  }

  /* 2. NUCLEAR SIDEBAR REMOVAL */
  .sidebar,
  .top-nav,
  #sidebarToggle,
  .desktop-only,
  .header button {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
  }

  /* 3. BOTTOM NAVIGATION (Fixed & Solid & Light) */
  .mobile-nav {
    display: flex !important;
    justify-content: space-around !important;
    align-items: center !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 70px !important;
    background-color: #ffffff !important;
    border-top: 1px solid #e2e8f0 !important;
    z-index: 999999 !important;
    padding-bottom: env(safe-area-inset-bottom) !important;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05) !important;
  }

  .nav-item {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    color: #64748b !important;
    text-decoration: none !important;
    font-size: 11px !important;
    height: 100% !important;
    background: transparent !important;
  }

  .nav-item i {
    font-size: 1.5rem !important;
    margin-bottom: 2px !important;
    color: #64748b !important;
  }

  .nav-item.active i,
  .nav-item.active {
    color: #2563eb !important;
  }

  /* 4. CARDS & VISUALS */
  .card,
  .card-mobile {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 16px !important;
    margin-bottom: 16px !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
    max-width: 100% !important;
  }

  h1,
  h2,
  h3,
  h4,
  .page-title {
    color: #1e293b !important;
    font-size: 1.5rem !important;
  }

  .text-muted {
    color: #64748b !important;
  }

  /* 5. FORMS */
  input,
  select {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
    height: 45px !important;
    border-radius: 8px !important;
    font-size: 16px !important;
    /* No Zoom */
  }

  /* 6. MODALS (Full Screen) */
  .modal-content {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
    background: #f8fafc !important;
    z-index: 9999999 !important;
  }
}