
/* Apple-Inspired Theme - Refined Light Grey, Black, White */

:root {
  /* Base Colors */
  --background-color: #fafafa;
  --primary-background: #ffffff;
  --secondary-background: #f5f5f7;
  --tertiary-background: #e8e8ed;

  /* Text Colors */
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --text-tertiary: #a1a1a6;

  /* Border Colors */
  --border-primary: #d2d2d7;
  --border-secondary: #e5e5ea;
  --border-light: #f0f0f5;

  /* Accent Colors - Minimal, Apple-style */
  --accent-black: #000000;
  --accent-grey: #515154;
  --accent-light-grey: #98989d;

  /* Interactive States */
  --hover-bg: #f5f5f7;
  --active-bg: #e8e8ed;
  --focus-ring: rgba(0, 0, 0, 0.1);

  /* Shadows - Subtle and Elegant */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.12);

  /* Status Colors - Muted for elegance */
  --status-success: #34c759;
  --status-warning: #ff9500;
  --status-error: #ff3b30;
  --status-info: #007aff;
}

* {
    box-sizing: border-box;
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cccccc;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #b3b3b3;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    margin: 0;
    font-size: 15px;
    line-height: 1.47059;
    letter-spacing: -0.022em;
}

aside {
    background-color: var(--secondary-background);
    border-right: 1px solid var(--border-secondary);
}

header {
    background-color: var(--primary-background);
    border-bottom: 1px solid var(--border-secondary);
    backdrop-filter: saturate(180%) blur(20px);
    background-color: rgba(255, 255, 255, 0.72);
}

main {
    padding: 2rem;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.022em;
}

h1 {
    font-size: 2.5rem;
    line-height: 1.1;
    font-weight: 700;
}

h2 {
    font-size: 1.75rem;
    line-height: 1.2;
    font-weight: 600;
}

h3 {
    font-size: 1.25rem;
    line-height: 1.3;
    font-weight: 600;
}

.bg-white {
    background-color: var(--primary-background) !important;
}

.bg-gray-50 {
    background-color: var(--secondary-background) !important;
}

.bg-gray-100 {
    background-color: var(--tertiary-background) !important;
}

.text-gray-900 {
  color: var(--text-primary) !important;
}

.text-gray-800 {
  color: var(--accent-grey) !important;
}

.text-gray-600 {
  color: var(--text-secondary) !important;
}

.text-gray-500 {
    color: var(--text-tertiary) !important;
}

.border-gray-200 {
  border-color: var(--border-secondary) !important;
}

.border-gray-300 {
  border-color: var(--border-primary) !important;
}

.border-gray-400 {
  border-color: var(--accent-light-grey) !important;
}

a {
    color: var(--accent-black);
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

a:hover {
    color: var(--accent-grey);
    opacity: 0.8;
}

button {
    background-color: var(--accent-black);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 11px 22px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.022em;
    box-shadow: var(--shadow-sm);
}

button:hover {
    background-color: var(--accent-grey);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.button-secondary {
    background-color: var(--secondary-background);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.button-secondary:hover {
    background-color: var(--tertiary-background);
    border-color: var(--accent-light-grey);
}


input,
select,
textarea {
  background-color: var(--primary-background);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 15px;
  font-family: inherit;
  letter-spacing: -0.022em;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-black);
  box-shadow: 0 0 0 4px var(--focus-ring);
  outline: none;
  background-color: #ffffff;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

.card {
    background-color: var(--primary-background);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-light);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.modal {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal > div {
    background-color: var(--primary-background);
    border-radius: 18px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-light);
}


/* Sidebar - Apple minimalist style */
aside a {
    color: var(--text-secondary);
    border-radius: 10px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

aside a:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

aside a.bg-gradient-to-r { /* Active link - Black accent */
    background: var(--accent-black);
    color: #ffffff;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

aside a.bg-gradient-to-r:hover {
    background: var(--accent-grey);
}


/* Mobile sidebar styles */
@media (max-width: 1024px) {

  /* Sidebar styling when visible */
  .sidebar {
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
    left: 0;
    top: 0;
  }

  /* Ensure sidebar is hidden by default on mobile */
  .sidebar.-translate-x-full {
    transform: translateX(-100%);
  }

  /* Ensure sidebar shows when toggled */
  .sidebar.translate-x-0 {
    transform: translateX(0);
  }

  /* Sidebar overlay styling */
  .sidebar-overlay {
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
  }

  /* Main content takes full width when sidebar is hidden */
  main {
    width: 100% !important;
    max-width: 100vw !important;
    flex: 1;
  }
}

/* Mobile responsive adjustments */
@media (max-width: 640px) {

  /* Fix main container for mobile - ensure proper height */
  main {
    height: calc(100vh - 64px) !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0.5rem !important;
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  #content-area {
    padding: 0.75rem !important;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  html,
  body {
    height: 100% !important;
    overflow: hidden !important;
  }

  body {
    min-height: 100vh !important;
    min-height: -webkit-fill-available !important;
    font-size: 14px;
  }

  .p-6 {
    padding: 1rem !important;
  }

  .p-5 {
    padding: 1rem !important;
  }

  .p-4 {
    padding: 0.75rem !important;
  }

  .text-3xl {
    font-size: 1.5rem !important;
  }

  .text-2xl {
    font-size: 1.25rem !important;
  }

  .text-xl {
    font-size: 1.125rem !important;
  }

  .text-lg {
    font-size: 1rem !important;
  }

  /* Mobile modal improvements */
  .modal>div {
    margin: 0.5rem;
    max-height: 95vh;
    max-width: calc(100vw - 1rem);
    overflow-y: auto;
  }

  /* Account modal specific fixes */
  #account-settings-modal .sticky {
    position: relative !important;
  }

  /* Make grid single column on mobile */
  .grid-cols-2 {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }

  .md\\:grid-cols-3,
  .lg\\:grid-cols-4 {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
  }

  /* Improve button sizing for mobile */
  button {
    min-height: 44px;
    font-size: 14px !important;
  }

  /* Header mobile fixes */
  header {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    height: 64px;
  }

  /* Hide long text on mobile */
  .hidden\\.sm\\:inline {
    display: none !important;
  }

  /* Hide notification bell on mobile */
  #notification-wrapper {
    display: none !important;
  }

  /* Improve spacing */
  .space-x-4 > * + * {
    margin-left: 0.75rem !important;
  }

  .space-y-4 > * + * {
    margin-top: 0.75rem !important;
  }

  /* Make cards full width on mobile */
  .rounded-2xl,
  .rounded-xl {
    border-radius: 12px !important;
  }

  /* Improve form inputs on mobile */
  input,
  select,
  textarea {
    font-size: 16px !important; /* Prevents zoom on iOS */
  }

  /* Fix text overflow and wrapping */
  .task-card {
    max-width: calc(100vw - 1.5rem) !important;
    overflow: hidden !important;
    padding: 0.75rem !important;
  }

  .task-card h4.truncate {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    max-width: 100% !important;
  }

  .task-card p,
  .task-card span,
  .task-card div {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
  }

  /* Fix task card badges and buttons overflow */
  .task-card .space-x-2,
  .task-card .space-x-3 {
    gap: 0.25rem !important;
    flex-wrap: wrap !important;
  }

  .task-card .space-x-2 > *,
  .task-card .space-x-3 > * {
    margin-left: 0 !important;
  }

  /* Hide elements that cause overflow in task cards */
  .task-card .hidden.sm\\:inline,
  .task-card .hidden.sm\\:block {
    display: none !important;
  }

  /* Ensure status badges fit */
  .task-card .flex.items-center.justify-between {
    gap: 0.5rem !important;
  }

  .task-card .flex-shrink-0 {
    flex-shrink: 1 !important;
  }

  .task-card {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }

  .task-card-main,
  .task-card-actions {
    width: 100% !important;
  }

  .task-card-actions {
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    gap: 0.5rem !important;
  }

  .task-card-meta {
    flex-wrap: wrap !important;
  }

  .task-card-status {
    width: auto !important;
    text-align: left !important;
  }

  .task-card-spacer {
    display: none !important;
  }

  /* Fix navbar position */
  header {
    position: sticky !important;
    top: 0 !important;
    width: 100vw !important;
    left: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Ensure proper text wrapping in all cards */
  .card,
  .bg-white,
  .bg-gray-50,
  .rounded-xl {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    box-sizing: border-box !important;
  }

  /* Fix grid layouts to prevent overflow */
  .grid {
    width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  /* Fix space-x utilities that can cause overflow */
  .space-x-3 > * + *,
  .space-x-4 > * + * {
    margin-left: 0.5rem !important;
  }

  /* Remove min-w-0 that can cause issues */
  .min-w-0 {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Fix Live Operations header section */
  .mb-6.flex.justify-between {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }

  .mb-6.flex.justify-between .flex {
    width: 100% !important;
    justify-content: flex-start !important;
  }

  /* Reduce heading sizes on mobile */
  #content-area h2 {
    font-size: 1.125rem !important;
  }

  /* Make space-x-3 groups wrap properly */
  .space-x-3 {
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }

  .space-x-3 > * {
    margin-left: 0 !important;
  }

  /* Fix task drawer on mobile */
  #task-drawer {
    max-width: 100vw !important;
    width: 100vw !important;
  }

  #task-drawer button {
    pointer-events: auto !important;
    z-index: 10 !important;
  }

  /* Ensure drawer action buttons are visible and clickable */
  #drawer-view-full-btn,
  button[onclick*="deleteTaskFromDrawer"],
  button[onclick*="viewFullResult"] {
    display: flex !important;
    min-height: 48px !important;
    touch-action: manipulation !important;
  }

  #drawer-view-full-btn.hidden {
    display: none !important;
  }

  /* Dashboard - Today's Summary Banner Mobile Optimization */
  .bg-gradient-to-r.from-gray-900 {
    padding: 1rem !important;
  }

  .bg-gradient-to-r.from-gray-900 .flex.flex-wrap {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 1rem !important;
  }

  .bg-gradient-to-r.from-gray-900 .flex.items-center.space-x-6 {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
    margin: 0 !important;
  }

  .bg-gradient-to-r.from-gray-900 .flex.items-center.space-x-6 > * {
    margin: 0 !important;
  }

  .bg-gradient-to-r.from-gray-900 .text-center {
    text-align: left !important;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.75rem !important;
    border-radius: 8px !important;
  }

  /* Dashboard - Working on Today Section Mobile */
  .bg-white.p-6.rounded-2xl {
    padding: 1rem !important;
  }

  .bg-white.p-6.rounded-2xl .flex.items-center.justify-between {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }

  .bg-white.p-6.rounded-2xl .flex.items-center.justify-between button {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Dashboard Widget Cards - Better mobile spacing */
  .bg-gray-50.p-5 {
    padding: 0.875rem !important;
  }

  .bg-gray-50.p-5 .text-3xl {
    font-size: 1.75rem !important;
  }

  /* Live Operations Header - Mobile Optimization */
  .mb-6.flex.justify-between.items-center {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
    margin-bottom: 1rem !important;
  }

  .mb-6.flex.justify-between.items-center > * {
    width: 100% !important;
  }

  .mb-6.flex.justify-between.items-center .flex.items-center.space-x-3 {
    flex-wrap: wrap !important;
    width: 100% !important;
  }

  .mb-6.flex.justify-between.items-center .flex.items-center.space-x-3 button {
    flex: 1 1 auto !important;
    min-width: 120px !important;
  }

  /* Make Deploy Task button full width on very small screens */
  @media (max-width: 380px) {
    .mb-6.flex.justify-between.items-center .flex.items-center.space-x-3 button {
      width: 100% !important;
    }
  }

  /* Reduce padding on stat cards */
  .text-center > .text-2xl {
    font-size: 1.5rem !important;
  }

  .text-center > .text-xs {
    font-size: 0.65rem !important;
  }

  /* Fix large stat cards with SVG backgrounds on mobile */
  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }

  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 > div {
    padding: 0.75rem !important;
  }

  /* Hide large decorative SVG icons on mobile */
  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 .absolute {
    display: none !important;
  }

  /* Make stat card text smaller on mobile */
  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 h3 {
    font-size: 0.65rem !important;
    margin-bottom: 0.25rem !important;
  }

  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 .text-3xl {
    font-size: 1.5rem !important;
  }

  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 .text-lg {
    font-size: 0.875rem !important;
  }

  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 .text-sm {
    font-size: 0.75rem !important;
  }

  /* Grid for model usage cards */
  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-3 {
    grid-template-columns: repeat(1, 1fr) !important;
    gap: 0.5rem !important;
  }

  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-3 > div {
    padding: 0.75rem !important;
  }

  /* Compact "Working on Today" cards */
  .grid.grid-cols-1.md\\:grid-cols-3 {
    gap: 0.5rem !important;
  }

  .grid.grid-cols-1.md\\:grid-cols-3 > div {
    padding: 0.75rem !important;
  }

  .grid.grid-cols-1.md\\:grid-cols-3 .h-10 {
    height: 2rem !important;
    width: 2rem !important;
  }

  .grid.grid-cols-1.md\\:grid-cols-3 .w-5 {
    width: 1rem !important;
    height: 1rem !important;
  }

  .grid.grid-cols-1.md\\:grid-cols-3 .text-3xl {
    font-size: 1.5rem !important;
  }

  /* Fix login/signup pages on mobile */
  body.min-h-screen {
    min-height: 100vh !important;
    min-height: -webkit-fill-available !important;
    align-items: flex-start !important;
    padding: 1.5rem 1rem !important;
    overflow-y: auto !important;
  }

  body.min-h-screen > div {
    margin-top: 2rem !important;
    margin-bottom: 2rem !important;
  }

  /* Make login form more compact on mobile */
  body.min-h-screen .text-3xl {
    font-size: 1.75rem !important;
  }

  body.min-h-screen .mb-10 {
    margin-bottom: 1.5rem !important;
  }

  body.min-h-screen .mb-5 {
    margin-bottom: 1rem !important;
  }

  body.min-h-screen .w-14 {
    width: 3rem !important;
    height: 3rem !important;
  }

  body.min-h-screen .w-7 {
    width: 1.5rem !important;
    height: 1.5rem !important;
  }

  body.min-h-screen .p-8 {
    padding: 1.25rem !important;
  }

  body.min-h-screen .space-y-6 > * + * {
    margin-top: 1rem !important;
  }

  body.min-h-screen .mt-8 {
    margin-top: 1.5rem !important;
  }
}
