/* 
 * Modern Main CSS with Morandi Color Palette
 * Complementary to style.css
 */

:root {
  /* Extended Morandi Color Palette */
  --morandi-beige-light: #f2f0e6;
  --morandi-pink-light: #f0e2df;
  --morandi-blue-light: #d9e1ea;
  --morandi-green-light: #e1ede6;
  --morandi-brown-light: #e6ded5;
  
  --morandi-beige-dark: #c5c2b3;
  --morandi-pink-dark: #c5a9a6;
  --morandi-blue-dark: #96a5b8;
  --morandi-green-dark: #a4b8ac;
  --morandi-brown-dark: #b0a195;
  
  /* Additional modern UI variables */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.05), 0 4px 6px rgba(0, 0, 0, 0.05);
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
  
  /* Dashboard grid settings */
  --panel-width: 350px;
  --panel-height: 350px;
  --panel-gap: 20px;
}

/* Modern Typography Enhancements */
body {
  font-weight: 400;
  letter-spacing: 0.01em;
  color: #3c3c3c;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  color: #333;
}

h1 {
  font-size: 2.5rem;
  line-height: 1.2;
}

h2 {
  font-size: 2rem;
  line-height: 1.3;
}

h3 {
  font-size: 1.5rem;
  line-height: 1.4;
}

p {
  margin-bottom: 1rem;
  line-height: 1.7;
}

a {
  color: var(--morandi-blue-dark);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--morandi-blue);
}

/* Modern Card Refinements */
.card {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  overflow: hidden;
  background: white;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

/* Modified hover behavior to not lift the card when in dashboard mode */
.dashboard-panel.card:hover {
  transform: none;
  box-shadow: var(--shadow-lg);
}

/* Only apply hover lift effect when not in the dashboard */
.card:not(.dashboard-panel):hover {
  transform: translateY(-4px);
}

.card-header {
  background: linear-gradient(to right, var(--morandi-blue), var(--morandi-blue-light));
  padding: 1.25rem;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

/* Modern Button Styles */
.btn {
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: var(--radius-sm);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  padding: 0.75rem 1.5rem;
}

.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.2);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--transition-normal);
}

.btn:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

.btn:active {
  transform: scale(0.98);
}

.btn-outline {
  background-color: transparent;
  border: 2px solid var(--morandi-blue);
  color: var(--morandi-blue);
}

.btn-outline:hover {
  background-color: var(--morandi-blue-light);
}

/* Modern Form Elements */
.form-control {
  border-radius: var(--radius-sm);
  border: 1px solid var(--morandi-gray);
  padding: 0.75rem 1rem;
  transition: all var(--transition-fast);
}

.form-control:focus {
  border-color: var(--morandi-blue);
  box-shadow: 0 0 0 3px var(--morandi-blue-light);
}

.form-label {
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: #555;
}

/* Skeleton Loading Animation */
.skeleton {
  background: linear-gradient(90deg, 
    var(--morandi-beige-light) 0%, 
    var(--morandi-beige) 50%, 
    var(--morandi-beige-light) 100%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-sm);
  height: 1rem;
  margin-bottom: 0.5rem;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Badge Component */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-blue {
  background-color: var(--morandi-blue-light);
  color: var(--morandi-blue-dark);
}

.badge-green {
  background-color: var(--morandi-green-light);
  color: var(--morandi-green-dark);
}

.badge-pink {
  background-color: var(--morandi-pink-light);
  color: var(--morandi-pink-dark);
}

/* Modern Dashboard Panel Enhancements */
.dashboard-panel {
  transition: all var(--transition-normal);
  border-radius: var(--radius-md);
  position: relative;
  /* Remove the absolute positioning to allow grid-based layout */
  margin-bottom: 20px;  /* Add spacing between panels when in vertical layout */
}

/* Modified panel dragging appearance */
.dashboard-panel.is-dragging {
  opacity: 0.9;
  z-index: 10;
  box-shadow: var(--shadow-lg);
}

.dashboard-panel:hover .panel-handle {
  opacity: 1;
}

/* ===== Grid Alignment System ===== */
/* Alignment guides that appear when dragging */
.alignment-guides {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none; /* Don't interfere with interactions */
  z-index: 1000;
}

.alignment-guide {
  position: absolute;
  background-color: rgba(45, 145, 255, 0.7);
  z-index: 1000;
}

.horizontal-guide {
  height: 1px;
  left: 0;
  right: 0;
  animation: guide-pulse 1s infinite;
}

.vertical-guide {
  width: 1px;
  top: 0;
  bottom: 0;
  animation: guide-pulse 1s infinite;
}

@keyframes guide-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0.3; }
}

/* Show grid helper (optional, for development) */
.show-grid {
  background-image: 
    linear-gradient(to right, rgba(0,0,0,0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0,0,0,0.05) 1px, transparent 1px);
  background-size: 
    calc(350px + 20px) calc(350px + 20px); /* cellWidth + gutterSize */
}

/* Loading indicator for panels */
.morandi-loader {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 10px;
}

.morandi-loader-circle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--morandi-blue);
  animation: loader-pulse 1.4s infinite ease-in-out both;
  animation-delay: var(--delay, 0s);
}

@keyframes loader-pulse {
  0%, 80%, 100% { 
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% { 
    transform: scale(1);
    opacity: 1;
  }
}

/* Tooltip Component */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltip-text {
  visibility: hidden;
  width: 120px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: var(--radius-sm);
  padding: 5px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -60px;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Modern Alerts */
.alert {
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  border-left: 4px solid;
}

.alert-success {
  background-color: var(--morandi-green-light);
  border-color: var(--morandi-green);
  color: var(--morandi-green-dark);
}

.alert-warning {
  background-color: var(--warning-color);
  border-color: #d4bc80;
  color: #8a7b4b;
}

.alert-error {
  background-color: var(--error-color);
  border-color: #d48080;
  color: #8a4b4b;
}

/* Modern Table Styles */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 1rem;
}

.table th,
.table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  background-color: var(--morandi-beige-light);
  font-weight: 600;
}

.table tr:last-child td {
  border-bottom: none;
}

.table-hover tr:hover {
  background-color: var(--morandi-beige-light);
}

/* Layout utilities */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.items-center {
  align-items: center;
}

.gap-1 {
  gap: 0.25rem;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-4 {
  gap: 1rem;
}

/* Password toggle button */
.password-wrapper {
  position: relative;
  display: block;
  width: 100%;
}

.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--morandi-gray);
  cursor: pointer;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.password-toggle:hover {
  opacity: 1;
}

.password-toggle.active {
  color: var(--morandi-blue);
}

/* Notification component */
.notifications-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 300px;
}

.notification {
  background-color: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 15px;
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.notification.show {
  transform: translateX(0);
  opacity: 1;
}

.notification-info {
  border-left: 4px solid var(--morandi-blue);
}

.notification-success {
  border-left: 4px solid var(--morandi-green);
}

.notification-warning {
  border-left: 4px solid var(--warning-color);
}

.notification-error {
  border-left: 4px solid var(--error-color);
}

/* Modern grid for smaller screens */
@media (max-width: 768px) {
  .dashboard-grid {
    justify-content: center;
  }
  
  .dashboard-panel {
    flex: 0 0 100%;
    margin-bottom: var(--panel-gap);
  }
  
  .dashboard-panel.medium,
  .dashboard-panel.large,
  .dashboard-panel.wide {
    flex: 0 0 100%;
    height: auto;
    min-height: var(--panel-height);
  }
  
  .navbar-content {
    flex-direction: column;
    gap: 1rem;
  }
  
  .navbar-menu {
    width: 100%;
    justify-content: space-around;
  }
}

/* Focus styles for accessibility */
.has-focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--morandi-blue-light);
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #292929;
    --card-bg: #333333;
    --text-color: #e0e0e0;
    --border-color: #444444;
  }
  
  .card {
    background-color: var(--card-bg);
  }
  
  h1, h2, h3, h4, h5, h6 {
    color: #f0f0f0;
  }
  
  .navbar {
    background-color: #333333;
  }
}

/* ==== Dashboard Grid Layout ==== */
.dashboard-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--panel-gap);
  padding: var(--panel-gap);
  align-items: flex-start;
  justify-content: flex-start;
}

.dashboard-panel {
  flex: 0 0 var(--panel-width);
  height: var(--panel-height);
  margin: 0; /* Remove previous margins */
  transition: all 0.3s ease;
  position: relative;
}

.dashboard-panel.is-dragging {
  z-index: 100;
  opacity: 0.9;
  box-shadow: var(--shadow-lg);
}

/* Panel size variations */
.dashboard-panel.small {
  flex: 0 0 var(--panel-width);
  height: var(--panel-height);
}

.dashboard-panel.medium {
  flex: 0 0 calc(var(--panel-width) * 2 + var(--panel-gap));
  height: var(--panel-height);
}

.dashboard-panel.large {
  flex: 0 0 calc(var(--panel-width) * 2 + var(--panel-gap));
  height: calc(var(--panel-height) * 2 + var(--panel-gap));
}

.dashboard-panel.wide {
  flex: 0 0 calc(var(--panel-width) * 3 + var(--panel-gap) * 2);
  height: var(--panel-height);
}

.dashboard-panel.tall {
  flex: 0 0 var(--panel-width);
  height: calc(var(--panel-height) * 2 + var(--panel-gap));
}

/* Card style for panels */
.dashboard-panel.card {
  display: flex;
  flex-direction: column;
}

.dashboard-panel .card-content {
  flex: 1;
  overflow: auto;
}

/* Drag handle styling */
.panel-handle {
  cursor: grab;
  transition: opacity 0.2s ease;
  opacity: 0.5;
}

.panel-handle:hover {
  opacity: 1;
}

.panel-handle:active {
  cursor: grabbing;
}

/* Placeholder for drag target */
.panel-placeholder {
  flex: 0 0 var(--panel-width);
  height: var(--panel-height);
  background-color: var(--morandi-beige-light);
  border: 2px dashed var(--morandi-beige-dark);
  border-radius: var(--radius-md);
  opacity: 0.6;
}

/* Panel size controls */
.panel-size-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 5px;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.dashboard-panel:hover .panel-size-controls {
  opacity: 1;
}

.size-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--morandi-gray);
  transition: all 0.2s ease;
}

.size-btn:hover {
  background: var(--morandi-blue-light);
  color: var(--morandi-blue-dark);
}

.size-btn.active {
  background: var(--morandi-blue);
  color: white;
}

/* Alert animations */
@keyframes slideInDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.alert {
  animation: slideInDown 0.3s ease forwards;
}

/* Tooltip Component */
.tooltip {
  position: relative;
  display: inline-block;
}
/* Add to your CSS file */
.latest-photo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
}

.latest-photo {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 4px;
    margin-bottom: 8px;
}

.photo-timestamp {
    font-size: 0.9rem;
    color: #6c757d;
    font-style: italic;
    margin-top: 5px;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.03);
    padding: 4px 8px;
    border-radius: 4px;
    width: 100%;
}

/* Photo upload form styling */
.photo-upload-form {
    margin-top: 15px;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.photo-upload-form .form-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.photo-upload-form input[type="file"] {
    flex: 1;
}

/* Chart container optimizations for proper sizing */
.panel-content {
  position: relative;
  width: 100%;
  height: calc(100% - 50px); /* Account for panel header and controls */
  display: flex;
  flex-direction: column;
  padding: 10px;
  box-sizing: border-box;
  overflow: hidden;
}

.chart-container {
  position: relative;
  height: 100%;
  min-height: 200px;
  width: 100%;
  overflow: hidden;
  flex: 1;
}

.chart-container canvas {
  position: absolute !important;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
}

/* Panel header considerations */
.dashboard-panel .panel-header {
  height: 40px;
  min-height: 40px;
  flex-shrink: 0;
  padding: 8px 12px;
}

.dashboard-panel .panel-header h3 {
  font-size: 14px;
  margin: 0;
  line-height: 24px;
}

/* Responsive chart sizing for different panel sizes */
.dashboard-panel.small .panel-content {
  height: calc(var(--panel-height) - 50px);
}

.dashboard-panel.medium .panel-content {
  height: calc(var(--panel-height) - 50px);
}

.dashboard-panel.large .panel-content {
  height: calc(var(--panel-height) * 2 + var(--panel-gap) - 50px);
}

.dashboard-panel.wide .panel-content {
  height: calc(var(--panel-height) - 50px);
}

.dashboard-panel.tall .panel-content {
  height: calc(var(--panel-height) * 2 + var(--panel-gap) - 50px);
}

/* Refresh indicator styling */
.refresh-indicator {
  position: absolute;
  bottom: 5px;
  right: 5px;
  font-size: 10px;
  color: #999;
  background: rgba(255, 255, 255, 0.8);
  padding: 2px 6px;
  border-radius: 3px;
  z-index: 10;
}