/* =======================================================
   CONTACTS.CSS â€“ FINAL & TRULY 100% FIXED â€“ NOVEMBER 2025
   â€¢ No mobile overlap EVER
   â€¢ Chart.js always renders full bars
   â€¢ Desktop: perfect side-by-side + full scrollable contacts
   â€¢ Mobile: contacts on top â†’ chart safely below
   â€¢ All modals, buttons, forms = pixel-perfect
   ======================================================= */

   * { box-sizing: border-box; margin: 0; padding: 0; }

   html, body {
     height: 100%;
     width: 100%;
     font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
     background: #f4f6f9;
     color: #333;
     overflow-x: hidden;
   }
   
   /* ==================== NAVBAR ==================== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;

  /* Use gradient per theme for nicer visual effect */
  background: var(--navbar-gradient, var(--navbar-bg));
  color: var(--navbar-text);

  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 1000;

  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);

  transition: 
    background 0.3s ease,
    color 0.3s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}
   #hamburgerButton { 
     display: none; 
     font-size: 1.8rem; 
     background: none; 
     border: none; 
     color: white; 
     cursor: pointer; 
   }
   
   
   @media (max-width: 768px) { 
     #hamburgerButton { display: block; } 
   }
   
   /* ==================== APP CONTAINER ==================== */
   #app {
     margin-top: 60px;
   }
   
   /* ==================== DESKTOP LAYOUT (â‰¥769px) ==================== */
   @media (min-width: 769px) {
     #app {
       display: grid;
       grid-template-columns: 380px 1fr;
       height: calc(100vh - 60px);
     }
   
     .sidebar {
       background: #f8f9fa;
       border-right: 1px solid #dee2e6;
       overflow-y: auto;
       height: 100%;
     }
   
     .main-content {
       display: flex;
       flex-direction: column;
       height: 100%;
       overflow: hidden;
     }
   
     .chart-container {
      flex: 1;
      margin: 2rem;
      padding: 2rem;
      background: white;
      border-radius: 20px;
      box-shadow: 0 15px 50px rgba(0,0,0,0.12);
      
      /* REQUIRED TO STOP OVERLAP */
      height: 320px;         /* <-- add this */
      position: relative;    /* <-- required for Chart.js */
      
      min-height: 0;
      display: flex;
      flex-direction: column;
    }
    
    #myChart {
      flex: 1;
      width: 100% !important;
      height: 100% !important;
      display: block !important;  /* ensures no canvas shrink bug */
    }
  }
   
   /* ==================== MOBILE LAYOUT (â‰¤768px) â€” NO OVERLAP ==================== */
   @media (max-width: 768px) {
    #app { display: block !important; }
  
    .sidebar {
      height: auto !important;        /* â† THIS IS THE MISSING LINE */
      min-height: auto !important;
      position: static !important;
      border-bottom: 1px solid #dee2e6;
      background: #f8f9fa;
    }
  
    .main-content {
      height: auto !important;
      overflow: visible !important;
      padding-bottom: 3rem;
    }
  
    /* your chart-container 480px rule etc. */
  }
  
  
    #myChart {
      width: 100% !important;
      height: 100% !important;
      display: block !important;
    }
  
   /* ==================== SEARCH BAR â€” Theme Aware ==================== */
.search-container {
  position: sticky;
  top: 0;
  background: var(--card-bg);           /* adapts: white â†’ slate â†’ warm paper */
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
  transition: background 0.5s ease, border-color 0.5s ease;
}

.search-container input {
  width: 100%;
  padding: 1rem 1rem 1rem 3.2rem;
  border: 2px solid var(--border-color);
  border-radius: 14px;
  background: var(--card-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") no-repeat 1rem center;
  background-size: 20px 20px;
  font-size: 1.05rem;
  color: var(--text-color);
  transition: all 0.3s ease;
}

/* Dynamic magnifying glass icon color per theme */
.search-container input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
}

/* Light theme: medium gray icon */
:root .search-container input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
}

/* Dark theme: lighter gray icon for visibility */
[data-theme="dark"] .search-container input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23a0aec0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
}

/* Sepia theme: warm brown icon */
[data-theme="sepia"] .search-container input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23705040' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
}

.search-container input:focus {
  outline: none;
  border-color: var(--accent-color);
  background-color: var(--card-bg);     /* stays consistent on focus */
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent-color) 18%, transparent);
}

/* Placeholder text color */
.search-container input::placeholder {
  color: color-mix(in srgb, var(--text-color) 60%, transparent);
  opacity: 1;
}
   /* ==================== MOBILE COLLAPSE BUTTON & LIST ==================== */
   .collapse-btn { display: none; }
   
   @media (max-width: 768px) {
     .collapse-btn {
       display: flex;
       justify-content: center;
       align-items: center;
       width: 100%;
       padding: 1.4rem;
       background: linear-gradient(135deg, #007bff, #0056b3);
       color: white;
       border: none;
       border-radius: 16px;
       font-size: 1.35rem;
       font-weight: 700;
       cursor: pointer;
       box-shadow: 0 10px 30px rgba(0,123,255,0.4);
       margin: 1rem 0;
     }
    }
   
     /* ==================== MOBILE â€” FINAL NO-OVERLAP EVER ==================== */
     @media (max-width: 768px) {
      .contact-list-wrapper {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.7s ease;
      }
    
      .contact-list-container:not(.collapsed) .contact-list-wrapper {
        max-height: 3000px !important;
        padding: 1.5rem 1rem;
      }
    
      /* ðŸ”¥ instant collapse fix */
      .contact-list-container.collapsed .contact-list-wrapper {
        transition: none !important;
        max-height: 0 !important;
        padding: 0 !important;
      }
    }
    

   /* ==================== EDIT & ADD NOTE BUTTONS (RESTORED) ==================== */
.edit-btn,
.add-log-btn {
  padding: 0.9rem 2rem;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  margin: 0.5rem;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.edit-btn {
  background: #007bff;
  color: white;
}

.edit-btn:hover {
  background: #0056b3;
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,123,255,0.3);
}

.add-log-btn {
  background: #28a745;
  color: white;
}

.add-log-btn:hover {
  background: #218838;
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(40,167,69,0.3);
}
   
   /* ==================== CONTACT CARDS ==================== */
   .contact-list {
     padding: 0 1rem;
     display: flex;
     flex-direction: column;
     gap: 14px;
   }
   .contact-list-wrapper {
    max-height: 3000px;
    overflow: hidden;
    transition: max-height 0s ease; /* immediate */
  }
  
  .contact-list-container.collapsed .contact-list-wrapper {
    max-height: 0 !important;
    padding: 0 !important;
  }
   
   .contact-card {
     background: white;
     border: 1px solid #e0e0e0;
     border-radius: 16px;
     padding: 1.4rem;
     box-shadow: 0 4px 15px rgba(0,0,0,0.08);
     transition: all 0.3s ease;
     cursor: pointer;
     position: relative;
   }
   
   .contact-card:hover {
     transform: translateY(-6px);
     box-shadow: 0 20px 40px rgba(0,123,255,0.2);
     border-color: #007bff;
     background: #f8fbff;
   }
   
   .delete-btn {
     position: absolute;
     top: 12px;
     right: 12px;
     background: #e74c3c;
     color: white;
     border: none;
     border-radius: 10px;
     padding: 6px 12px;
     font-size: 11px;
     font-weight: 600;
     cursor: pointer;
     opacity: 0;
     transition: all 0.2s;
   }
   
   .contact-card:hover .delete-btn { opacity: 1; }

   /* ==================== RESTORE CONTACT CARDS & HIDDEN VIEWS ==================== */
.contact-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 16px;
  padding: 1.4rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
}

.contact-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 40px rgba(0,123,255,0.2);
  border-color: #007bff;
  background: #f8fbff;
}


/* FLOATING ADD BUTTON */
.add-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #007bff;                     /* original blue */
  color: white;
  font-size: 2.8rem;                        /* your larger size */
  font-weight: 300;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;

  /* merged shadow + transitions */
  box-shadow: 0 12px 35px rgba(0, 123, 255, 0.5);
  transition: all 0.2s ease;

  /* keeps it above content but not too high */
  z-index: 1500;
}

/* Hover */
.add-btn:hover {
  transform: scale(1.15);
  box-shadow: 0 15px 40px rgba(0, 123, 255, 0.5);
  background: #0056b3;                     /* darker blue on hover */
}

/* Active (press) */
.add-btn:active {
  transform: scale(0.95);
}

   
   /* ==================== EDIT CONTACT FORM ==================== */
   #backFromEdit {
     position: absolute;
     top: 1rem;
     left: 1rem;
     background: #dc3545;
     color: white;
     border: none;
     width: 48px;
     height: 48px;
     border-radius: 50%;
     font-size: 1.6rem;
     font-weight: bold;
     cursor: pointer;
     display: flex;
     align-items: center;
     justify-content: center;
     box-shadow: 0 6px 20px rgba(220,53,69,0.4);
     z-index: 10;
     transition: all 0.25s ease;
   }
   
   #backFromEdit:hover {
     background: #c82333;
     transform: scale(1.1);
   }
   
   #editContactView {
     display: none !important;
     position: fixed;
     top: 60px;
     left: 0;
     right: 0;
     bottom: 0;
     background: white;
     z-index: 950;
     overflow-y: auto;
   }
   
   #editContactView.active {
     display: block !important;
     opacity: 1;
   }
   
  
   /* ==================== FORMS & BUTTONS ==================== */
   .form-group {
     margin-bottom: 1.6rem;
   }
   
   .form-group label {
     display: block;
     margin-bottom: 0.7rem;
     font-weight: 600;
     color: #222;
   }
   
   .form-group input,
   .form-group textarea {
     width: 100%;
     padding: 1rem;
     border: 2px solid #e0e0e0;
     border-radius: 14px;
     font-size: 1.05rem;
     background: white;
     transition: all 0.3s;
   }
   
   .form-group input:focus,
   .form-group textarea:focus {
     outline: none;
     border-color: #007bff;
     box-shadow: 0 0 0 5px rgba(0,123,255,0.18);
   }
   
   #addContactSubmit,
   #saveEditBtn,
   .btn-primary {
     width: 100%;
     padding: 1.2rem;
     background: linear-gradient(135deg, #007bff, #0056b3);
     color: white;
     border: none;
     border-radius: 16px;
     font-size: 1.2rem;
     font-weight: 700;
     cursor: pointer;
     margin-top: 1.5rem;
     box-shadow: 0 10px 30px rgba(0,123,255,0.4);
     transition: all 0.3s;
   }
   
   #addContactSubmit:hover,
   #saveEditBtn:hover {
     transform: translateY(-4px);
     box-shadow: 0 16px 40px rgba(0,123,255,0.5);
   }
   
   /* ==================== CONTACT DETAIL PANEL & ADD BUTTON ==================== */
   #contactDetail {
     position: fixed;
     top: 60px;
     right: 0;
     width: 420px;
     max-width: 100%;
     height: calc(100vh - 60px);
     background: white;
     border-left: 1px solid #dee2e6;
     box-shadow: -10px 0 40px rgba(0,0,0,0.15);
     z-index: 900;
     transform: translateX(100%);
     transition: transform 0.4s ease;
     padding: 2rem;
     overflow-y: auto;
   }
   
   #contactDetail.active { transform: translateX(0); }
   
  
   .navbar-user-dropdown {
    position: relative;
  }
  
  .user-menu-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
  }
  
  .user-menu-btn:hover {
    background: rgba(255, 255, 255, 0.2);
  }
  
  .user-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
    backdrop-filter: blur(8px);
    border: 2px solid rgba(255, 255, 255, 0.4);
    overflow: hidden;
  }
  
  #userInitials {
    font-size: 1.3rem;
    font-weight: 700;
  }
  
  /* Dropdown styling */
 .dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card-bg);   /* uses theme card background */
    color: var(--text-color);     /* uses theme text color */
    min-width: 220px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    padding: 0.8rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.3s ease;
    z-index: 9999;
}

.dropdown-menu a {
    color: var(--text-color);     /* theme-aware links */
}

.dropdown-menu a:hover {
    background: var(--accent-color);
    color: #fff;
}
  
  .dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  
  .dropdown-user-info strong {
  color: var(--text-color);
}

.dropdown-user-info small {
  color: var(--text-color);
  opacity: 0.6;
  font-size: 0.85rem;
}
  
  .dropdown-item {
    width: 100%;
    padding: 0.8rem 1.2rem;
    text-align: left;
    background: none;
    border: none;
    color: #333;
    font-size: 0.95rem;
    cursor: pointer;
  }
  
  .dropdown-item:hover {
  background: var(--border-color);
  color: var(--text-color);
}
  
  .signout-item {
    color: #e74c3c !important;
    font-weight: 600;
  }
  
  .signout-item:hover {
    background: #ffe6e6 !important;
  }

  .navbar-user-dropdown { position: relative; }
.user-menu-btn {
  background: none; border: none; cursor: pointer; padding: 8px; border-radius: 50%;
}
.user-menu-btn:hover { background: rgba(255,255,255,0.2); }
.user-avatar {
  width: 44px; height: 44px; background: rgba(255,255,255,0.3);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: white; font-weight: bold; font-size: 1.2rem;
}

.dropdown-menu.show { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-user-info { padding: 0 16px 8px; border-bottom: 1px solid #eee; margin-bottom: 8px; }
.dropdown-item { width: 100%; padding: 10px 16px; background: none; border: none;
  text-align: left; cursor: pointer; color: #333; }
.dropdown-item:hover { background: #f0f4ff; }
#signOutBtn { color: #e74c3c; font-weight: 600; }
#signOutBtn:hover { background: #ffe6e6; }

/* === FIX USER AVATAR INSIDE BUTTON â€” CRITICAL === */
#userMenuBtn.user-menu-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;           /* removes unwanted padding */
  background: none !important;
  border: none !important;
}

.user-avatar {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 44px !important;
  height: 44px !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.3) !important;
  color: white !important;
  font-weight: 700 !important;
  font-size: 1.3rem !important;
  backdrop-filter: blur(8px) !important;
  border: 2px solid rgba(255, 255, 255, 0.4) !important;
  text-align: center !important;
}




/* ------------------ MODAL CONTAINER ------------------ */
#contactModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(12px);
  z-index: 2000;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

#contactModal.active {
  display: flex;
}

/* ------------------ MODAL CONTENT ------------------ */
.modal-content {
  width: 95%;
  max-width: 560px;
  max-height: 95vh;            /* never taller than screen */
  background: white;
  border-radius: 20px;
  flex-direction: column;
  position: relative;
  overflow: hidden;            /* hide overflow; scroll handled in form */
}

/* ------------------ MODAL HEADER ------------------ */
.modal-header {
  position: relative;
  padding: 1.2rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #eee;
  font-weight: 700;
  z-index: 10;
}

/* ------------------ CLOSE BUTTON ------------------ */
.close-modal-btn {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.close-modal-btn:hover {
  background: #f0f0f0;
  color: #000;
}

/* === FORCE CLOSE (X) BUTTON VISIBILITY === */
.close-modal-btn {
  color: #111827; /* visible in light mode */
}

.close-modal-btn:hover {
  background: #f0f0f0;
  color: #000;
}

/* Dark mode */
[data-theme="dark"] .close-modal-btn {
  color: #e5e7eb;
}

[data-theme="dark"] .close-modal-btn:hover {
  background: #334155;
  color: #ffffff;
}


/* DESKTOP + GENERAL FIX */
#contactForm {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  overflow: visible;

  padding: 0.1rem 1rem 6.5rem 1.2rem; /* increased bottom padding */
  gap: 0.1rem;
}

#contactForm textarea {
  margin-bottom: 0.5rem;  /* small buffer so save button never overlaps */
}





/* Inputs */
.form-group label {
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: #333;
  font-size: 0.95rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1.8px solid #ddd;
  border-radius: 12px;
  font-size: 1rem;
  transition: all 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

.form-group textarea {
  min-height: 80px;
  max-height: 100px;
  resize: none;
}

/* ------------------ SAVE BUTTON ------------------ */
#addContactSubmit,
.save-contact-btn {
  position: sticky;          /* sticks at bottom */
  bottom: 1rem;
  margin: 0 auto;
  width: calc(100% - 3rem);
  max-width: 460px;
  padding: 1.2rem;
  background: linear-gradient(135deg, #007bff, #0056b3);
  color: white;
  border: none;
  border-radius: 18px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 35px rgba(0,123,255,0.45);
  z-index: 10;
  text-align: center;
}

#addContactSubmit:hover,
.save-contact-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 50px rgba(0,123,255,0.6);
}

/* ------------------ MOBILE ------------------ */
@media (max-width: 768px) {

  .modal-content {
    width: 96%;
    max-height: 100vh;
    padding: 0.5rem;
    border-radius: 14px;
    overflow: visible;
  }

  #contactForm {
    padding: 0.5rem 0.8rem 4rem 0.8rem; /* tighter + still room for sticky button */
    gap: 0.25rem; /* SUPER tight â€” fixes overlap */
    flex: 0 0 auto;
    overflow: visible;
  }

  #contactForm input,
  #contactForm textarea {
    padding: 0.45rem 0.6rem; /* smaller to save height */
    font-size: 0.85rem;
  }

  /* Save button */
  #addContactSubmit,
  .save-contact-btn {
    bottom: 0.4rem;
    padding: 0.9rem;
    width: calc(100% - 1rem);
    font-size: 1rem;
  }
}

/* DESKTOP â€” COMPACT FORM */
@media (min-width: 769px) {
  #contactForm {
    padding: 1rem 1.2rem 6.5rem 1.2rem; /* reduced padding, but still clears sticky button */
    gap: 0.4rem;                        /* tighter spacing */
  }

  .form-group label {
    margin-bottom: 0.2rem;             /* tighten label â†’ input spacing */
    font-size: 0.9rem;
  }

  .form-group input,
  .form-group textarea {
    padding: 0.55rem 0.8rem;           /* reduce input height */
    font-size: 0.95rem;
  }

  textarea#notes {
    min-height: 85px;                  /* prevent collapse but keep compact */
  }
}

/* === VIEW CONTACT PANEL CLOSE BUTTON === */
#closeContactDetail {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: #dc3545;             /* red */
  color: white;                    /* white X */
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(220,53,69,0.4);
  z-index: 2000;                   /* above card content */
  transition: all 0.25s ease;
}

#closeContactDetail:hover {
  background: #c82333;             /* darker red on hover */
  transform: scale(1.1);
}

.navbar-calendar-dropdown {
  position: relative;
  margin-right: 1rem;
}

.calendar-menu-btn {
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: 0.2s;
  color: white;
}

.calendar-menu-btn:hover {
  background: rgba(255,255,255,0.2);
}

.calendar-dropdown-menu {
  position: absolute;
  top: 130%;
  right: 0;
  background: white;
  width: 180px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  padding: 0.5rem 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.25s ease;
  z-index: 2000;
}

.calendar-dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.calendar-item {
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.calendar-item:hover {
  background: #f0f4ff;
}

/* Calendar Overlay — Hidden by default */
/* Calendar Overlay — Hidden by default */
#calendarView {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1500;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;

  /* Modern blur with fallback */
  -webkit-backdrop-filter: blur(4px);   /* For Safari / iOS */
  backdrop-filter: blur(4px);           /* Standard property */

  /* Fallback for browsers that don't support backdrop-filter */
  background: rgba(0, 0, 0, 0.7);       /* Slightly darker fallback so content is still readable */
}

/* Visible state — matches your JS: .classList.add("active") */
#calendarView.active {
  display: flex;
}

#calendarView .calendar-modal {
  width: 95%;
  max-width: 1200px;
  height: 90dvh;       /* ensures enough height for calendar */
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
}

.calendar-container {
  flex: 1;
  min-height: 0;
}

/* Modal Header */
#calendarView .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.8rem;
  background: var(--primary, #007bff);   /* Use your primary color or fallback */
  color: white;
  border-radius: 12px 12px 0 0;
  flex-shrink: 0;
  position: relative;
}

/* Close Button (inside .modal-header or .calendar-modal) */
#calendarView .close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background 0.2s;
}

#calendarView .close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Calendar Title */
#calendarView .calendar-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
  text-align: center;
  flex: 1;
}

/* Make sure FullCalendar takes up the remaining space nicely */
#calendarView #calendar {
  flex: 1;
  min-height: 0;                    /* Important for flex child */
  padding: 1rem;
  background: var(--bg-color, #ffffff);
}
/* Close Button */
#closeCalendar {
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.4rem;
  font-weight: bold;
  cursor: pointer;
  position: absolute;
  top: 15px;
  right: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#closeCalendar:hover {
  background: #c82333;
}

/* FullCalendar Container */
#calendar {
  flex: 1;
  min-height: 0; /* Essential for flex children */
}
/* === CALENDAR DROPDOWN TEXT VISIBILITY FIX === */
.calendar-dropdown-menu {
  background: #ffffff; /* force solid background */
}

.calendar-item {
  color: #111827;      /* dark, readable text */
  font-weight: 600;
}

.calendar-item:hover {
  background: #eef2ff;
  color: #1e40af;
}

/* Dark mode override */
[data-theme="dark"] .calendar-dropdown-menu {
  background: #1e293b;
}

[data-theme="dark"] .calendar-item {
  color: #e5e7eb;
}

[data-theme="dark"] .calendar-item:hover {
  background: #334155;
  color: #a78bfa;
}


/* ============================
   SWIPE DELETE â€” VISIBILITY FIX
   ============================ */

/* Hide swipe delete button on desktop */
.swipe-delete-btn {
  display: none !important;
}

@media (max-width: 768px) {
  .swipe-delete-btn {
    display: flex !important;    /* mobile only */
  }
}


@media (max-width: 768px) {

  .contact-card {
    position: relative;
    overflow: hidden;
  }

  .card-inner {
    background: white;
    z-index: 2;
    position: relative;
    transition: transform 0.2s ease-out;
    padding: 1rem;
  }

  .swipe-delete-btn {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 90px;
    background: #e63946;
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
  }
}

/* ==================== THEME VARIABLES â€” Softer & More Comfortable ==================== */
:root {
  /* Light Theme - Clean with bold indigo */
  --bg-color: #f1f5f9;
  --card-bg: #ffffff;
  --text-color: #0f172a;
  --border-color: #cbd5e1;
  --accent-color: #4f46e5;        /* deeper indigo */
  --secondary-accent: #6366f1;
  --shadow: 0 8px 20px rgba(0, 0, 0, 0.08);

  /* Navbar */
  --navbar-bg: var(--accent-color);
  --navbar-text: #ffffff;
  --navbar-gradient: linear-gradient(135deg, var(--accent-color), var(--secondary-accent));
}

[data-theme="dark"] {
  --bg-color: #121a2d;
  --card-bg: #1e293b;
  --text-color: #e2e8f0;
  --border-color: #334155;
  --accent-color: #a78bfa;
  --secondary-accent: #c4b5fd;
  --shadow: 0 8px 25px rgba(0, 0, 0, 0.3);

  /* Navbar */
  --navbar-bg: #1e293b;
  --navbar-text: #e2e8f0;
  --navbar-gradient: linear-gradient(135deg, #1e293b, #334155);
}

[data-theme="sepia"] {
  --bg-color: #faf6f0;
  --card-bg: #fffdf7;
  --text-color: #5d4037;
  --border-color: #e0d6c8;
  --accent-color: #f59e0b;
  --secondary-accent: #ffc046;
  --shadow: 0 8px 20px rgba(0, 0, 0, 0.1);

  /* Navbar */
  --navbar-bg: #f59e0b;  /* orange for sepia */
  --navbar-text: #5d4037;
  --navbar-gradient: linear-gradient(135deg, #f59e0b, #ffc046);
}

/* Webkit browsers (Chrome, Edge, Safari) */
::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
  background-color: var(--accent-color);
  border-radius: 8px;
  border: 3px solid var(--bg-color);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent-color) var(--bg-color);
}

 .user-avatar-dropdown {
  background: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
}

.user-avatar-dropdown a {
  color: var(--text-color);
}

.user-avatar-dropdown a:hover {
  background: var(--accent-color);
  color: #fff;
}
/* ==================== GLOBAL APPLICATION ==================== */
body, .sidebar, .main-content, .contact-card, #contactDetail, .modal-content, .chart-container, .navbar, .bottom-navbar {
  background-color: var(--bg-color);
  color: var(--text-color);
  border-color: var(--border-color);
  transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease;
}

h1, h2, h3, h4, p, span, label, strong {
  color: var(--text-color);
  transition: color 0.5s ease;
}

/* Cards & Containers - Elevated */
.contact-card, #contactDetail, .modal-content, .chart-container {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: all 0.3s ease;
}

/* Inputs & Search Bar - Explicitly theme-aware */
input, textarea, select, 
input[type="search"], .search-bar, .search-input /* add your search class/ID here if needed */ {
  background-color: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 12px; /* rounder for modern feel */
  padding: 0.75rem 1rem;
  transition: all 0.3s ease;
}

input:focus, textarea:focus, select:focus, input[type="search"]:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-color) 20%, transparent);
  outline: none;
}

/* Buttons */
button, .edit-btn, .add-log-btn, .save-contact-btn, #addContactSubmit {
  background: linear-gradient(135deg, var(--accent-color) 0%, var(--secondary-accent) 100%);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  cursor: pointer;
}

button:hover, .edit-btn:hover, .add-log-btn:hover, .save-contact-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* ==================== NAVBAR â€” Frosted Glass + Bold Gradient ==================== */
.navbar, .bottom-navbar {
    background: var(--navbar-bg, var(--accent-color));
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow, 0 8px 32px rgba(0, 0, 0, 0.2));
    transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.user-avatar {
  background: rgba(255, 255, 255, 0.15) !important;
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
  backdrop-filter: blur(10px);
}

.user-menu-btn:hover {
  background: rgba(255, 255, 255, 0.25) !important;
}

/* ==================== TIMELINE / CONTACT EVENTS ==================== */
.timeline-item {
  padding: 1rem 1.25rem;
  border-left: 5px solid var(--accent-color);
  margin-bottom: 1.25rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.timeline-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.12);
  border-color: var(--accent-color);
}

.event-type {
  font-weight: 800;
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
  color: var(--accent-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.event-content {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-color);
  opacity: 0.95;
}

.event-date {
  font-size: 0.85rem;
  color: var(--accent-color);
  opacity: 0.8;
  text-align: right;
  margin-top: 0.5rem;
}

/* ==================== VIEW MODE TOGGLE ==================== */
.view-mode-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  width: 100%;
  font-size: 0.95rem;
}

/* iOS-style Toggle Switch - Theme Aware */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color);
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

input:checked + .slider {
  background: linear-gradient(135deg, var(--accent-color), var(--secondary-accent));
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* ==========================
   ADD CONTACT FORM — DARK MODE INPUT FIX
   ========================== */

/* Force inputs to respect theme variables */
#contactModal input,
#contactModal textarea,
#contactForm input,
#contactForm textarea {
  background-color: var(--card-bg) !important;
  color: var(--text-color) !important;
  border-color: var(--border-color) !important;
}

/* Placeholder visibility */
#contactModal input::placeholder,
#contactModal textarea::placeholder {
  color: color-mix(in srgb, var(--text-color) 60%, transparent);
}

/* Focus state */
#contactModal input:focus,
#contactModal textarea:focus {
  border-color: var(--accent-color) !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-color) 20%, transparent);
}
/* ==========================
   CONTACT CARD HOVER — DARK MODE FIX
   ========================== */

/* Dark mode hover should stay dark */
[data-theme="dark"] .contact-card:hover {
  background: #1e293b !important;   /* matches dark card bg */
  border-color: var(--accent-color);
  box-shadow: 0 20px 40px rgba(0,0,0,0.45);
}

/* Optional: slightly lift inner content instead */
[data-theme="dark"] .contact-card:hover .card-inner {
  background: transparent;
}

/* Default hidden */
#appointmentModal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5); /* semi-transparent overlay */
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

/* Show modal when active */
#appointmentModal.active {
  display: flex; /* flex to center content */
}

/* Optional: style the form inside */
#appointmentModal form {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  max-width: 500px;
  width: 100%;
}

#appointmentModal {
  z-index: 1000; /* or higher if other modals use >1000 */
}

.appointment-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  position: relative;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.appointment-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.appointment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.appointment-header h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.appointment-header .edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: #007bff;
}

.appointment-header .edit-btn:hover {
  color: #0056b3;
}

.appointment-datetime {
  font-size: 0.875rem;
  color: #555;
  margin: 4px 0;
}

.appointment-notes {
  font-size: 0.875rem;
  color: #333;
  margin: 4px 0 0;
}

/* Delete button */
.appointment-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: #ff0000;
}



/* Overlay for calendar modal */
.modal-overlay {
  display: none;               /* hidden by default */
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);  /* slightly darker for better contrast */
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

/* Show overlay when active */
.modal-overlay.active {
  display: flex;
}

/* Inner modal content — matches BOTH classes in your HTML */
.modal-content.calendar-modal {
  width: 90%;
  max-width: 1200px;           /* prevents it from being too wide on large screens */
  height: 90vh;
  max-height: 95vh;
  background: #fff;
  overflow-y: auto;
  border: 2px solid #333;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  position: relative;
  padding: 1.5rem;
}

/* Modal header */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

/* Calendar title */
.calendar-title {
  margin: 0;
  font-size: 1.8rem;
  color: #333;
}

/* Close button */
.close-btn {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.close-btn:hover {
  background: #c0392b;
}

/* ============================================================
   GLOBAL APP SHELL – LOCK OUTER SCROLL
   ============================================================ */

/* ============================================================
   GLOBAL APP SHELL – MOBILE / DESKTOP SAFE
   ============================================================ */

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

main,
.main-content,
.userhome-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;   /* important for flex scrolling */
}

/* ============================================================
   FULL-PROFILE PAGE OVERRIDES
   ============================================================ */

body.full-profile-active,
.full-profile-view {
  height: auto;          /* let content expand */
  display: block;        /* cancel mobile flex column */
  overflow: auto;        /* allow scrolling */
}

#contactDetail.full-profile {
  position: relative;
  width: 100%;
  max-width: none;
  height: auto;
  padding: 1rem;
  overflow: visible;
}

#contactProfileContainer.full-profile-view {
  display: flex;
  flex-direction: row;      /* desktop layout */
  gap: 2rem;
  padding: 1rem;
}

/* ============================================================
   CONTACT ACTION BUTTONS – PROFILE PAGE
   ============================================================ */

#contactDetail.full-profile .contact-actions,
#contactProfileContainer .contact-actions {
  flex-direction: row;      /* horizontal buttons on profile */
  gap: 0.5rem;
}

#contactDetail.full-profile .contact-actions button,
#contactProfileContainer .contact-actions button,
#contactProfileContainer .add-appointment-btn {
  width: auto;              /* no full width */
  max-width: 200px;         /* optional, adjust as needed */
  flex: 0 0 auto;
  white-space: normal;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  margin-right: 0;          /* remove extra spacing */
}

/* ============================================================
   SIDEBAR – FIXED COLUMN (HOME PAGE ONLY)
   ============================================================ */

.sidebar {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: hidden !important;
}

/* Sidebar contact actions remain full width */
.sidebar .contact-actions button {
  width: 100%;
  max-width: 100%;
}

/* ============================================================
   SAFETY: EXPLICIT HIDES STILL WORK
   ============================================================ */

.is-hidden {
  display: none !important;
}

/* Scrollable content for sidebar contact list */
#contactListContainer,
.contact-list-container,
.contact-list-wrapper {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

#contactList,
.contact-list {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  box-sizing: border-box;
}

/* ============================================================
   FULL-PROFILE NOTES & APPOINTMENTS
   ============================================================ */

.full-profile-view .notes-content,
.full-profile-view #contactAppointments {
  display: block !important;
}

.full-profile-view .appointments-section,
.full-profile-view .notes-section {
  flex-shrink: 0;
}

.notes-content.is-hidden {
  display: none;
}

.timeline-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.delete-event-btn{
  background:none;
  border:none;
  cursor:pointer;
  opacity:0.6;
}

.delete-event-btn:hover{
  opacity:1;
}