/* note-controls.css - Controls for notes editing features */

/* Header toggle buttons in main view */
/* Header toggle buttons in main view */
.header-control-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  font-size: 16px;
  color: var(--text-color);
  transition:
    background-color 0.2s,
    color 0.2s;
}

.header-control-btn:hover {
  background-color: rgba(98, 0, 238, 0.1);
  color: var(--primary-color);
}

.header-control-btn.active {
  background-color: var(--primary-color);
  color: white;
}

/* Group container for header controls */
.header-controls-group {
  display: flex;
  align-items: center;
  margin-right: 16px; /* Space between controls and add button */
  background-color: rgba(0, 0, 0, 0.03);
  padding: 4px 8px;
  border-radius: 10px;
}

/* Container for expanded note controls */
.expanded-note-controls {
  position: fixed;
  top: 15px;
  right: 60px; /* Position to the left of the delete button */
  z-index: 9002; /* Same level as other expanded note controls */
  display: none;
  gap: 10px;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 6px 10px;
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.expanded-note-controls.active {
  display: flex; /* Show when active */
  /* opacity: 1; */
  /* visibility: visible; */
}

/* Individual control buttons */
.expanded-control-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-color);
  border-radius: 50%;
  transition:
    background-color 0.2s,
    color 0.2s;
}

.expanded-control-btn:hover {
  background-color: rgba(98, 0, 238, 0.1);
  color: var(--primary-color);
}

/* Active state for toggle buttons */
.expanded-control-btn.active {
  background-color: var(--primary-color);
  color: white;
}

/* Tooltip for buttons */
.expanded-control-btn .tooltip {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s,
    visibility 0.2s;
}

.expanded-control-btn:hover .tooltip {
  opacity: 1;
  visibility: visible;
}

.nav-toggle {
  margin-bottom: 30px;
}

/* Global spell check toggle in sidebar */
.spell-check-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-top: 1px solid var(--border-color);
  margin-top: auto; /* Push to the bottom of flex container */
}

.spell-check-toggle .toggle-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.spell-check-toggle .toggle-label {
  font-size: 14px;
  color: var(--text-color);
}

/* Reusing switch styles from dark-mode.css */
.spell-check-toggle .switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.spell-check-toggle .switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.spell-check-toggle .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 24px;
}

.spell-check-toggle .slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

.spell-check-toggle input:checked + .slider {
  background-color: var(--primary-color);
}

.spell-check-toggle input:focus + .slider {
  box-shadow: 0 0 1px var(--primary-color);
}

.spell-check-toggle input:checked + .slider:before {
  transform: translateX(26px);
}

/* Dark mode support */
body.dark-mode .expanded-note-controls {
  background-color: rgba(30, 30, 30, 0.9);
}

body.dark-mode .expanded-control-btn {
  color: #e0e0e0;
}

body.dark-mode .expanded-control-btn:hover {
  background-color: rgba(187, 134, 252, 0.1);
  color: var(--primary-color);
}

body.dark-mode .expanded-control-btn.active {
  background-color: var(--primary-color);
  color: white;
}

body.dark-mode .spell-check-toggle {
  border-color: var(--border-color);
}

body.dark-mode .spell-check-toggle .toggle-label {
  color: var(--text-color);
}

body.dark-mode .header-controls-group {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Mobile layout adjustments */
@media (max-width: 768px) {
  .expanded-note-controls {
    top: 15px;
    right: 55px;
    padding: 4px 8px;
  }

  .expanded-control-btn {
    width: 26px;
    height: 26px;
    font-size: 14px;
  }

  .spell-check-toggle {
    padding: 8px 15px;
  }

  .spell-check-toggle .toggle-label {
    font-size: 13px;
  }

  .header-control-btn {
    width: 28px;
    height: 28px;
    margin-right: 3px;
    margin-left: 3px;
    font-size: 14px;
  }

  .header-controls-group {
    padding: 4px 6px;
    margin-left: 0; /* Remove the large left margin */
    margin-right: 10px;
    position: relative; /* Ensure proper positioning */
    z-index: 10; /* Make sure it doesn't interfere with other elements */
  }

  .notes-header .user-info {
    margin-right: 30px;
  }
}

/* Very small screen adjustments */
@media (max-width: 480px) {
  .expanded-note-controls {
    top: auto;
    /*
       The note-expand button is height: 28px, bottom: 10px.
       So its top edge is at bottom: 10px + 28px = 38px from the note's bottom.
       Let's place the controls above this.
       Give a bit of margin, say 10px.
       So, bottom: 38px + 10px = 48px.
    */
    bottom: 50px; /* Adjust this value based on visual testing */
    right: 15px;
    left: auto;
    padding: 4px 8px; /* */
  }

  .header-control-btn {
    width: 24px;
    height: 24px;
    margin-right: 2px;
    margin-left: 2px;
    font-size: 12px;
  }

  `` /* On very small screens, hide the optional buttons to save space */
  #searchButton,
  #sortButton {
    display: none;
  }

  .header-controls-group {
    margin-right: 5px;
    padding: 2px 4px;
    position: static; /* Reset position to avoid overlapping issues */
    margin-bottom: 5px;
    margin-left: 180px;
  }

  /* Ensure the notes header has proper layout */
  .notes-header {
    flex-wrap: wrap; /* Prevent wrapping that could cause overlap */
    justify-content: flex-end; /* Push elements to the right */
    padding: 10px 10px;
    margin-bottom: 30px;
  }

  /* Ensure user-info doesn't take up all space if it wraps */
  .notes-header .user-info {
    /* Apply to the .user-info container or .username-display */
    /* To prevent it from taking full width if it wraps to its own line */
    /* flex-basis: auto; /* Allow it to shrink */
    /* max-width: 100%; /* Or a more constrained max-width if needed next to other items */
    margin-bottom: 5px;
    /* Add specific text overflow handling for the username itself if not already done */
  }
  .notes-header .username-display {
    display: inline-block; /* Or block if it needs to be on its own line when long */
    max-width: 150px; /* Example: Adjust as needed */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle; /* Align with buttons if on the same line */
  }

  /* Make sure the current category indicator doesn't overlap */
  .current-category {
    max-width: 40%; /* Limit width to prevent overlap */
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (min-width: 370px) {
  .username-display {
    margin-left: 40px;
  }
}
