﻿/* ============================================
   CUSTOM COLOR SYSTEM
   Main Color: #4bb9ec
   ============================================ */

:root {
  /* Primary Brand Color */
  --primary: #4bb9ec;
  --primary-dark: #3a9fd4;
  --primary-light: #6bc8f5;
  --primary-hover: #3a9fd4;
  --primary-rgb: 75, 185, 236;
  
  /* Primary with opacity (for backgrounds) */
  --primary-50: rgba(75, 185, 236, 0.05);
  --primary-100: rgba(75, 185, 236, 0.1);
  --primary-200: rgba(75, 185, 236, 0.2);
  --primary-300: rgba(75, 185, 236, 0.3);
  --primary-500: rgba(75, 185, 236, 0.5);
  --primary-700: rgba(75, 185, 236, 0.7);
  --primary-800: rgba(75, 185, 236, 0.8);
  --primary-900: rgba(75, 185, 236, 0.9);
  
  /* Text Colors */
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --text-light: #d1d5db;
  --text-muted: #9ca3af;
  
  /* Background Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --bg-dark: #1f2937;
  
  /* Border Colors */
  --border-light: #e5e7eb;
  --border-default: #d1d5db;
  --border-dark: #9ca3af;
  
  /* Hover States */
  --hover-bg: #f3f4f6;
  --hover-text: #374151;
  
  /* Additional Colors for Chart/Data Visualization */
  --chart-primary: #4bb9ec;
  --chart-accent: #8b5cf6;
  --chart-success: #10b981;
  --chart-warning: #f59e0b;
  --chart-danger: #ef4444;
  
  /* Shadow */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* ============================================
   BASE STYLES
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

input.date-input {
  font-size: 14px;
}

.sidebar {
  transition: transform 0.3s ease;
}

.sidebar-closed {
  transform: translateX(-100%);
}

.sidebar-open {
  transform: translateX(0);
}

@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.sidebar-open {
    transform: translateX(0);
  }
}

/* ============================================
   MOVED FROM INDEX.PHP EMBEDDED STYLES
   ============================================ */

:root {
  --background: 60 9% 98%;
  --foreground: 24 10% 10%;
  --card: 0 0% 100%;
  --card-foreground: 24 10% 10%;
  --primary-hsl: 142 76% 36%;
  --primary-foreground: 0 0% 100%;
  --secondary: 60 5% 96%;
  --muted-foreground: 24 5% 64%;
  --border: 20 6% 90%;
  --ring: 142 76% 36%;
}

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

body.db-picker-open::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 9998;
}

.litepicker {
  z-index: 9999 !important;
}

body.db-picker-open .litepicker {
  position: fixed !important;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
}

body.db-picker-open .litepicker .container__main {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.18);
  padding: 10px;
}

body.db-picker-open .litepicker .month-item-header div,
body.db-picker-open .litepicker .month-item-weekdays-row > div {
  color: #374151;
  font-weight: 600;
}

body.db-picker-open .litepicker .month-item-weekdays-row > div {
  font-size: 12px;
  letter-spacing: 0.02em;
}

body.db-picker-open .litepicker .day-item {
  border-radius: 8px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

body.db-picker-open .litepicker .day-item:hover {
  background-color: #f3f4f6;
}

body.db-picker-open .litepicker .day-item.is-today {
  color: #dc2626;
  font-weight: 700;
}

body.db-picker-open .litepicker .day-item.is-start-date,
body.db-picker-open .litepicker .day-item.is-end-date {
  background-color: #111827;
  color: #ffffff !important;
}

body.db-picker-open .litepicker .month-item-header .button-previous-month,
body.db-picker-open .litepicker .month-item-header .button-next-month {
  border-radius: 8px;
}

@media (max-width: 640px) {
  body.db-picker-open .litepicker .container__main {
    max-width: calc(100vw - 24px);
    padding: 8px;
  }
}

/* ============================================
   CHECKLIST HEADER (AJAX-SAFE)
   Ensures consistent layout even when Tailwind CDN
   hasn't generated responsive utility rules yet.
   ============================================ */

#checklistHeader {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  #checklistHeader {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  #checklistHeader .checklist-date-controls {
    margin-left: auto;
    justify-content: flex-end;
    width: auto;
    flex: 0 0 auto;
  }

  #checklistHeader .checklist-date-wrap {
    width: auto;
  }

  #checklistDate {
    width: 11rem;
  }
}

#checklistHeader .checklist-date-wrap {
  position: relative;
  width: 100%;
}

#checklistHeader .checklist-date-input {
  width: 100%;
  padding-left: 1rem;
  padding-right: 2.5rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: #ffffff;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: #374151;
  text-align: left;
}

#checklistHeader .checklist-date-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.45);
  border-color: rgba(59, 130, 246, 0.75);
}

#checklistHeader .checklist-date-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
}

p {
  color: var(--text-secondary);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-dark);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
}

.btn-primary:active {
  opacity: 0.9;
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--hover-bg);
}

.btn-outline {
  background-color: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover {
  background-color: var(--primary-50);
}

/* ============================================
   CARDS & CONTAINERS
   ============================================ */

.card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 0.5rem;
  padding: 1.5rem;
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1rem;
  padding-bottom: 1rem;
}

/* ============================================
   INPUTS & FORM ELEMENTS
   ============================================ */

input, select, textarea {
  border: 1px solid var(--border-light);
  border-radius: 0.375rem;
  padding: 0.5rem 1rem;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}

input::placeholder {
  color: var(--text-tertiary);
}

/* Remove number-input spinners (financial amount fields) */
#surplusAmount,
#payments_received,
#rolling_12m_turnover {
  -moz-appearance: textfield;
  appearance: textfield;
}

#surplusAmount::-webkit-outer-spin-button,
#surplusAmount::-webkit-inner-spin-button,
#payments_received::-webkit-outer-spin-button,
#payments_received::-webkit-inner-spin-button,
#rolling_12m_turnover::-webkit-outer-spin-button,
#rolling_12m_turnover::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ============================================
   PRIMARY COLOR UTILITIES
   ============================================ */

/* Text colors */
.text-primary {
  color: var(--primary);
}

.text-primary-hover:hover {
  color: var(--primary-dark);
}

/* Background colors */
.bg-primary {
  background-color: var(--primary);
}

.bg-primary-light {
  background-color: var(--primary-100);
}

.bg-primary-lighter {
  background-color: var(--primary-50);
}

/* Border colors */
.border-primary {
  border-color: var(--primary);
}

/* ============================================
   STATUS BADGES
   ============================================ */

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-primary {
  background-color: var(--primary-100);
  color: var(--primary-dark);
}

.badge-success {
  background-color: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.1);
  color: #d97706;
}

.badge-danger {
  background-color: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

/* ===== Toast Alert Container ===== */
.toast-alert {
  position: fixed;
  top: 24px;
  right: 24px;
  padding: 10px 14px;
  border-radius: 18px;
  color: #fff;
  font-weight: 600;
  z-index: 9999;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(6px);
  opacity: 0;
}

/* ===== Color Variants ===== */
.toast-success {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.toast-error {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.toast-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.toast-info {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

/* ===== Animations ===== */
@keyframes toastSlideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastSlideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(120%); opacity: 0; }
}

@keyframes toastPulse {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
  70% { box-shadow: 0 0 0 14px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.toast-show {
  animation: toastSlideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275),
             toastPulse 1.2s ease-out;
  opacity: 1;
}

.toast-hide {
  animation: toastSlideOut 0.35s ease-in forwards;
}

/* ============================================
   PROGRESS BARS
   ============================================ */

.progress {
  width: 100%;
  height: 0.5rem;
  background-color: var(--border-light);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  background-color: var(--primary);
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease;
}

/* ============================================
   NAVIGATION
   ============================================ */

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.nav-link:hover {
  background-color: var(--hover-bg);
  color: var(--text-primary);
}

.nav-link.active,
.nav-item-link.active {
  background-color: var(--primary);
  color: #ffffff;
}

.sidebar-group {
  border-radius: 0.75rem;
}

.nav-parent-toggle {
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-parent-toggle:hover,
.sidebar-group.open > .nav-parent-toggle {
  background-color: var(--hover-bg);
  color: var(--text-primary);
}

.nav-parent-toggle:focus-visible,
.nav-item-link:focus-visible {
  outline: 2px solid rgba(var(--primary-rgb), 0.35);
  outline-offset: 2px;
}

.submenu-arrow {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.sidebar-group.open > .nav-parent-toggle .submenu-arrow {
  transform: rotate(90deg);
}

.submenu-list {
  list-style: none;
  margin-top: 0.125rem;
  margin-left: 0.25rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border-light);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}

.sidebar-group.open > .submenu-list {
  max-height: 24rem;
  opacity: 1;
}

.nav-sub-link {
  padding-left: 1.25rem;
  margin-top: 0.125rem;
}

.sidebar-group.has-active-child > .nav-parent-toggle {
  background-color: var(--primary-50);
  color: var(--primary-dark);
  font-weight: 600;
}

/* ============================================
   LISTS & ACTIVITY INDICATORS
   ============================================ */

.activity-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: var(--primary);
  display: inline-block;
  margin-top: 0.25rem;
}

.activity-dot-accent {
  background-color: var(--chart-accent);
}

/* ============================================
   TABLES
   ============================================ */

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background-color: var(--bg-tertiary);
}

th {
  padding: 0.75rem 1.5rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-light);
}

td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

tbody tr:hover {
  background-color: var(--bg-secondary);
}

/* ============================================
   DROPDOWN & POPOVER
   ============================================ */

.dropdown {
  position: absolute;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-lg);
  z-index: 50;
}

.dropdown a, .dropdown button {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  text-align: left;
  color: var(--text-primary);
  transition: all 0.2s ease;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
}

.dropdown a:hover, .dropdown button:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ============================================
   ANIMATIONS
   ============================================ */

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 0.75rem;
}

.gap-4 {
  gap: 1rem;
}

.gap-6 {
  gap: 1.5rem;
}

.transition-colors {
  transition: color, background-color, border-color 0.2s ease;
}

.transition-shadow {
  transition: box-shadow 0.2s ease;
}

.rounded-lg {
  border-radius: 0.5rem;
}

.rounded-full {
  border-radius: 9999px;
}

.space-y-3 > * + * {
  margin-top: 0.75rem;
}

.space-y-4 > * + * {
  margin-top: 1rem;
}

.space-y-6 > * + * {
  margin-top: 1.5rem;
}

.w-full {
  width: 100%;
}

.h-2 {
  height: 0.5rem;
}

.h-8 {
  height: 2rem;
}

.h-12 {
  height: 3rem;
}

.w-2 {
  width: 0.5rem;
}

.w-8 {
  width: 2rem;
}

.w-12 {
  width: 3rem;
}

.mt-1 {
  margin-top: 0.25rem;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mt-4 {
  margin-top: 1rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mb-6 {
  margin-bottom: 1.5rem;
}

.pb-2 {
  padding-bottom: 0.5rem;
}

.pb-3 {
  padding-bottom: 0.75rem;
}

.pt-4 {
  padding-top: 1rem;
}

.px-3 {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.py-1 {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.py-2 {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.text-xs {
  font-size: 0.75rem;
}

.text-sm {
  font-size: 0.875rem;
}

.text-lg {
  font-size: 1.125rem;
}

.text-2xl {
  font-size: 1.5rem;
}

.text-3xl {
  font-size: 1.875rem;
}

.text-gray-500 {
  color: var(--text-tertiary);
}

.text-gray-600 {
  color: var(--text-secondary);
}

.text-gray-900 {
  color: var(--text-primary);
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

.tracking-tight {
  letter-spacing: -0.02em;
}

.opacity-75 {
  opacity: 0.75;
}

.line-through {
  text-decoration: line-through;
}

.min-w-0 {
  min-width: 0;
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */

@media (max-width: 768px) {
  .hidden-mobile {
    display: none;
  }
}

@media (min-width: 768px) {
  .hidden-desktop {
    display: none;
  }
}

/* ============================================
   CUSTOM COLOR CLASSES (co- prefix)
   ============================================ */

/* Primary Color Classes */
.co-bg-primary {
  background-color: var(--primary);
}

.co-bg-primary-dark {
  background-color: var(--primary-dark);
}

.co-bg-primary-light {
  background-color: var(--primary-100);
}

.co-bg-primary-50 {
  background-color: var(--primary-50);
}

.co-text-primary {
  color: var(--primary);
}

.co-text-primary-dark {
  color: var(--primary-dark);
}

.co-text-white {
  color: #ffffff;
}

.co-text-danger {
  color: #ef4444;
}

.co-border-primary-light {
  border-color: var(--primary-100);
}

.co-border-primary {
  border-color: var(--primary);
}

/* Accent/Secondary Colors */
.co-bg-accent {
  background-color: var(--chart-accent);
}

.co-bg-accent-light {
  background-color: rgba(139, 92, 246, 0.1);
}

.co-text-accent {
  color: var(--chart-accent);
}

/* Warning/Status Colors */
.co-bg-warning-light {
  background-color: rgba(245, 158, 11, 0.1);
}

.co-border-warning-light {
  border-color: rgba(245, 158, 11, 0.2);
}

.co-text-warning {
  color: #f59e0b;
}

/* Hover States with Color */
.co-hover-bg-primary-dark:hover {
  background-color: var(--primary-dark);
}

.co-hover-bg-primary-light:hover {
  background-color: var(--primary-100);
}

.co-hover-text-primary-dark:hover {
  color: var(--primary-dark);
}

.co-hover-text-primary:hover {
  color: var(--primary);
}

/* Focus States with Color */
.co-focus-ring-primary:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-100);
  border-color: var(--primary);
}

/* Combined Classes for Common Patterns */
.co-button-primary {
  background-color: var(--primary);
  color: #ffffff;
  transition: all 0.2s ease;
}

.co-button-primary:hover {
  background-color: var(--primary-dark);
}

.co-badge-primary {
  background-color: var(--primary-100);
  color: var(--primary-dark);
}

/* ============================================
   MODERN UI ENHANCEMENTS
   ============================================ */

/* Larger modern radius */
.rounded-xl {
  border-radius: 0.75rem;
}

.rounded-2xl {
  border-radius: 1rem;
}

/* Premium card feel */
.card-modern {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.04);
  transition: all 0.25s ease;
}

.card-modern:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 40px rgba(var(--primary-rgb), 0.08);
}

/* Elevated primary button */
.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  box-shadow: 0 6px 18px rgba(var(--primary-rgb), 0.4);
  transform: translateY(-1px);
}

/* Smooth transitions globally */
button,
.card,
input,
select,
textarea {
  transition: all 0.2s ease;
}
