:root {
  --primary-color: #4CAF50;
  --primary-color-dark: #45a049;
  --secondary-color: #2196F3;
  --text-color: #333333;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #f5f5f5;
  color: var(--text-color);
}

header {
  background-color: var(--primary-color);
  color: white;
  padding: 1rem;
  text-align: center;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  flex-grow: 1;
  text-align: center;
  margin: 0;
}

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

.dashboard {
  margin-bottom: 2rem;
}

.quick-stats {
  display: flex;
  justify-content: space-around;
  gap: 1rem;
}

.stat-box {
  background-color: white;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  text-align: center;
  flex: 1;
}

.stat-box i {
  font-size: 2rem;
  color: var(--primary-color);
}

.stat-number {
  display: block;
  font-size: 1.5rem;
  font-weight: bold;
  margin: 0.5rem 0;
}

.stat-label {
  font-size: 0.9rem;
  color: #666;
}

.contact-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.contact-header h2 {
  margin: 0 0 0.5rem 0;
}

.search-bar {
  display: flex;
  margin-bottom: 1rem;
}

.search-bar input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px 0 0 4px;
}

.search-bar button {
  padding: 0.5rem 1rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
}

.primary-btn {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.3s ease;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  margin-bottom: 0.5rem;
}

.primary-btn:hover {
  background-color: var(--primary-color-dark);
}

.primary-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.5);
}

#contactList {
  list-style-type: none;
  padding: 0;
}

.contact-item {
  background-color: white;
  margin-bottom: 0.5rem;
  padding: 1rem;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.contact-item .name {
  font-weight: bold;
  flex: 1;
}

.contact-item button {
  background: none;
  border: none;
  cursor: pointer;
  margin-left: 0.5rem;
  font-size: 1rem;
}

.expand-btn {
  color: var(--primary-color);
}

.edit-btn {
  color: var(--secondary-color);
}

.delete-btn {
  color: #f44336;
}

.contact-details {
  display: none;
  margin-top: 0.5rem;
}

.contact-details.show {
  display: block;
}

.floating-action-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.floating-action-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--primary-color);
  color: white;
  font-size: 24px;
  border: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  cursor: pointer;
  margin-bottom: 1rem;
}

.import-export-btn {
  position: fixed;
  bottom: 7rem;
  right: 2rem;
  background-color: var(--secondary-color);
}

.ai-assistant-btn {
  position: fixed;
  bottom: 12rem;
  right: 2rem;
  background-color: #9C27B0;
}

.no-contacts-message {
  background-color: rgba(255, 255, 255, 0.9);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  color: var(--text-color);
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.modal {
  display: none;
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.4);
}

.modal-content {
  background-color: white;
  margin: 15% auto;
  padding: 2rem;
  border-radius: 8px;
  max-width: 500px;
}

#infoModal .modal-content {
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  margin: 10% auto;
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover,
.close:focus {
  color: #000;
  text-decoration: none;
  cursor: pointer;
}

form input,
form textarea,
form select {
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
}

form button {
  background-color: var(--primary-color);
  color: white;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.alert-settings {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}

.alert-settings label {
  margin-right: 1rem;
}

#alertDays,
#editAlertDays {
  width: 100px;
}

.alert-progress-bar {
  width: 100%;
  height: 10px;
  background-color: #ddd;
  border-radius: 5px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.alert-progress-bar .progress {
  height: 100%;
  background-color: var(--primary-color);
}

.header-icons {
  display: flex;
  gap: 1rem;
}

.header-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 0.2s ease-in-out;
}

.header-btn:hover {
  transform: scale(1.1);
}

#settingsBtn, #infoBtn {
  color: #FFD700;
}

#profileList {
  list-style-type: none;
  padding: 0;
}

#profileList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  border-bottom: 1px solid #ddd;
}

#profileList li:last-child {
  border-bottom: none;
}

#profileList button {
  background: none;
  border: none;
  color: var(--primary-color);
  cursor: pointer;
}

#settingsForm label {
  display: block;
  margin-top: 1rem;
}

#settingsForm input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 4px;
}

#importExportModal button {
  display: block;
  width: 100%;
  margin-bottom: 1rem;
}

#importFile {
  display: block;
  margin-bottom: 1rem;
}

#aiAssistantModal .modal-content {
  max-width: 800px;
}

#aiChat {
  display: flex;
  flex-direction: column;
  height: 400px;
  margin-bottom: 1rem;
}

#aiMessages {
  flex-grow: 1;
  overflow-y: auto;
  border: 1px solid #ddd;
  padding: 10px;
  margin-bottom: 10px;
  background-color: #f9f9f9;
}

#aiMessages p {
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  border-radius: 4px;
  white-space: pre-wrap;
}

#aiMessages p.user {
  background-color: #e3f2fd;
  text-align: right;
}

#aiMessages p.ai {
  background-color: #f1f8e9;
}

#aiForm {
  display: flex;
}

#aiInput {
  flex-grow: 1;
  margin-right: 10px;
}

#aiSendBtn {
  width: 60px;
}

#aiWaitingMessage {
  text-align: center;
  font-style: italic;
  margin-top: 10px;
}

.hidden {
  display: none;
}

#profileList .current-profile {
  font-weight: bold;
  background-color: #e6f7ff;
}

.ai-controls {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
}

.ai-controls button {
  padding: 0.5rem 1rem;
  background-color: var(--secondary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#aiHelpBtn, #aiSettingsBtn {
  background: none;
  border: none;
  color: var(--secondary-color);
  font-size: 1.5rem;
  cursor: pointer;
  margin-left: 0.5rem;
}

#aiSaveBtn, #aiLoadBtn {
  background-color: var(--primary-color);
  color: white;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 1rem;
}

#aiSettingsModal .modal-content {
  max-width: 400px;
}

#aiSettingsModal label {
  display: block;
  margin-bottom: 0.5rem;
}

#aiSettingsModal input[type="range"],
#aiSettingsModal input[type="number"],
#aiSettingsModal select {
  width: 100%;
  margin-bottom: 1rem;
}

/* Accessibility improvements */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

*:focus {
  outline: 2px solid var(--secondary-color);
  outline-offset: 2px;
}

/* AI typing indicator */
@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 1; }
}

.ai-typing::after {
    content: '|';
    animation: blink 1s infinite;
}

/* Responsive design */
@media (max-width: 600px) {
  .quick-stats {
    flex-direction: column;
  }
  
  .floating-action-btn {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
  
  .modal-content {
    width: 90%;
    margin: 5% auto;
  }

  #aiAssistantModal .modal-content {
    width: 95%;
  }

  #aiChat {
    height: 300px;
  }

  #aiMessages {
    height: 200px;
  }

  .ai-controls {
    flex-wrap: wrap;
  }

  .ai-controls button {
    margin-bottom: 0.5rem;
  }

  .contact-header {
    flex-direction: column;
    align-items: stretch;
  }

  .contact-header h2 {
    text-align: center;
  }

  .primary-btn {
    width: 100%;
  }

  .floating-action-container {
    display: none;  /* Hide the floating action button on mobile */
  }
}
