/* =============================================
   TASK 1: UI & STRUCTURE
   Done by: Samuel Olaniran (Lead), Kafayah Olaniyan,
            Sulaimon Akintunde, Oladejo Aisha

   This file has all the styles for MyLinkSpace.
   ============================================= */


/* ---------- Basics ---------- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  color: #19313a;
  background: #f6fbfb;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

/* sidebar on the left */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 228px;
  padding: 22px 15px;
  background: white;
  border-right: 1px solid #dce8e7;
  overflow-y: auto;
  z-index: 20;
}

/* logo and app name */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 24px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 9px;
  object-fit: cover;
}

.brand-name {
  font-size: 18px;
  font-weight: bold;
}

.brand-my { color: #00163d; }
.brand-link { color: #005ceb; }
.brand-space { color: #009e8f; }

/* close button for the phone menu */
.close-menu {
  display: none; /* only shows on phones */
  margin-left: auto;
  border: none;
  background: #f2f7f7;
  border-radius: 7px;
  font-size: 22px;
  width: 34px;
  height: 34px;
}

/* sidebar buttons (Home, Archived, tags) */
.nav-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: #627278;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 14px;
  text-align: left;
  overflow-wrap: anywhere; /* long tag names wrap */
}

.nav-link:hover,
.nav-link.active {
  background: #e8f7f5;
  color: #087f73;
  font-weight: bold;
}

/* Home and Archived icons in the sidebar */
.nav-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

/* the small numbers on the right of sidebar buttons */
.count {
  margin-left: auto;
  color: #879599;
  font-size: 12px;
}

/* main area on the right */
.main {
  margin-left: 228px;
}

/* top bar */
.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 28px;
  background: white;
  border-bottom: 1px solid #dce8e7;
  z-index: 10;
}

/* ☰ button for the phone menu */
.open-menu {
  display: none; /* only shows on phones */
  width: 38px;
  height: 38px;
  border: 1px solid #dce7e6;
  border-radius: 8px;
  background: white;
  font-size: 20px;
}

/* normal buttons */
.btn {
  border: 1px solid #d5e1e0;
  background: white;
  border-radius: 7px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: bold;
  color: #516167;
  white-space: nowrap; /* keep button words on one line */
}

/* icon inside a button (Add Bookmark) */
.btn-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.btn:has(.btn-icon) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* the word "Bookmark" after "Add" */
.long-word {
  margin-left: -2px;
}

/* green buttons */
.btn.primary {
  background: #087f73;
  border-color: #087f73;
  color: white;
}

.btn.primary:hover {
  background: #076e64;
}

/* page content */
.content {
  padding: 22px 27px 35px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.eyebrow {
  font-size: 12px;
  color: #087f73;
  font-weight: bold;
  margin: 0 0 3px;
}

h1 {
  font-size: 26px;
  margin: 0;
  overflow-wrap: anywhere; /* long search words don't break the page */
}

h1 small {
  font-size: 14px;
  color: #879598;
}

.sub {
  font-size: 14px;
  color: #77868a;
  margin: 5px 0 18px;
}

/* empty page message */
.empty {
  background: white;
  border: 1px dashed #cbdad8;
  border-radius: 10px;
  text-align: center;
  padding: 70px 20px;
  color: #708084;
}

/* picture on the empty pages */
.empty-icon {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin: 0 auto 12px;
}

.empty h3 {
  margin: 0;
  font-size: 18px;
}

.empty p {
  font-size: 14px;
}

/* pop-up message in the corner */
#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #18373d;
  color: white;
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 14px;
  display: none;
  z-index: 2000;
}

#toast.show {
  display: block;
}

/* phones: sidebar slides in from the left */
@media (max-width: 760px) {
  .sidebar {
    width: 260px;
    left: -280px;
    transition: left 0.2s;
    z-index: 1000;
  }

  .sidebar.open {
    left: 0;
  }

  /* dark background behind the open menu */
  .overlay.open {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(14, 31, 35, 0.42);
    z-index: 999;
  }

  .close-menu,
  .open-menu {
    display: block;
  }

  .main {
    margin-left: 0;
  }

  .topbar {
    padding: 10px 12px;
    gap: 8px;
  }

  .content {
    padding: 18px 14px 30px;
  }

  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}


/* ---------- Bookmark cards, archived rows and the form ---------- */

/* Add Bookmark button sits on the right of the top bar */
#addBtn {
  margin-left: auto;
}

/* grid of cards: 3 in a row */
.bookmark-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

/* one bookmark card */
.card {
  min-width: 0;
  overflow-wrap: anywhere; /* long links and words go to the next line */
  background: white;
  border: 1px solid #dce8e7;
  border-radius: 10px;
  padding: 15px;
}

.category {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 8px;
  background: #e8f7f5;
  color: #087f73;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
}

.card h3 {
  font-size: 16px;
  margin: 7px 0 2px;
}

.url {
  font-size: 13px;
  color: #8a989b;
}

.description {
  font-size: 14px;
  color: #718085;
  line-height: 1.5;
  margin: 9px 0 11px;
}

/* tags on a card */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.tag {
  background: #f0f6f5;
  color: #587177;
  border-radius: 4px;
  padding: 4px 9px;
  font-size: 12px;
}

/* Edit, Archive, Delete buttons */
.card-actions {
  display: flex;
  gap: 6px;
}

.small-btn {
  border: 1px solid #d5e1e0;
  background: white;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 13px;
  color: #42565b;
}

.small-btn:hover {
  background: #eef8f7;
  color: #087f73;
}

.small-btn.danger {
  color: #b83a43;
}

/* bottom of the card: open link and date */
.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 9px;
  border-top: 1px solid #edf1f1;
}

/* "Open link" button on each card.
   (It used to be called .open, but the phone menu also uses
   the class "open", so the sidebar became see-through.) */
.open-link {
  border: none;
  background: none;
  padding: 0;
  color: #087f73;
  font-size: 13px;
  font-weight: bold;
}

.date {
  font-size: 12px;
  color: #9aa5a8;
}

/* one row on the archived page */
.archive-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: white;
  border: 1px solid #dce8e7;
  border-radius: 9px;
  padding: 13px;
  margin-bottom: 9px;
}

.archive-row .grow {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.archive-row h3 {
  margin: 0;
  font-size: 15px;
}

.archive-row p {
  margin: 3px 0 0;
  color: #8a989b;
  font-size: 13px;
}

.archive-row .tags {
  margin-bottom: 0;
}

/* the add/edit form pop-up */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

/* used to hide the form (must come after .modal) */
.hidden {
  display: none;
}

/* dark background behind the form */
.modal-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(18, 38, 42, 0.34);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 490px;
  max-height: 90vh;
  overflow: auto;
  background: white;
  border-radius: 10px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  padding: 18px 19px;
  border-bottom: 1px solid #e4eceb;
}

.modal-head h2 {
  margin: 0;
  font-size: 19px;
}

.modal-head p {
  margin: 4px 0 0;
  color: #89979a;
  font-size: 13px;
}

.close-btn {
  border: none;
  background: none;
  color: #89979a;
  font-size: 24px;
}

form {
  padding: 18px 19px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: bold;
  color: #4c6065;
  margin-bottom: 13px;
}

/* the red star on required fields */
label span {
  color: #db6b6b;
}

label input,
label textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 10px;
  border: 1px solid #d7e2e1;
  border-radius: 7px;
  font-size: 15px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid #edf1f1;
  padding-top: 14px;
}

/* tablets: 2 cards in a row */
@media (max-width: 1000px) {
  .bookmark-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* phones: 1 card in a row */
@media (max-width: 760px) {
  .bookmark-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .archive-row {
    flex-wrap: wrap;
  }
}


/* ---------- Search, tags and sorting ---------- */

/* search box (the box and its icon sit inside .search-wrap) */
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 0; /* lets the box get smaller on small screens */
  max-width: 410px;
}

/* magnifying glass inside the search box */
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  pointer-events: none; /* clicks go through to the box */
}

.search {
  width: 100%;
  height: 40px;
  padding: 0 13px 0 40px; /* room on the left for the icon */
  border: 1px solid #dbe6e5;
  border-radius: 7px;
  font-size: 14px;
}

/* the word "Tags" above the tag list */
.nav-title {
  font-size: 11px;
  font-weight: bold;
  color: #94a2a5;
  text-transform: uppercase;
  margin: 16px 10px 7px;
}

/* picture next to each tag */
.tag-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

/* row with "Filtered by..." and the sort menu */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 13px;
}

.result-count {
  font-size: 13px;
  color: #7b898d;
}

.sort {
  border: 1px solid #dce7e6;
  background: white;
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 13px;
}


/* ---------- Website icon ---------- */

.site-icon {
  width: 35px;
  height: 35px;
  border-radius: 8px;
  background: #f2f7f7;
  border: 1px solid #e1eaea;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #087f73;
}

.site-icon img {
  width: 22px;
  height: 22px;
}


/* ---------- Extra fixes for phones ---------- */

@media (max-width: 760px) {
  /* sidebar: solid white with a shadow when open */
  .sidebar {
    max-width: 85vw;
    visibility: hidden; /* closed menu can't be reached with the Tab key */
    transition: left 0.2s, visibility 0.2s;
  }

  .sidebar.open {
    visibility: visible;
    box-shadow: 12px 0 34px rgba(20, 47, 52, 0.16);
  }

  /* stop the page behind the open menu from scrolling */
  body.menu-open {
    overflow: hidden;
  }

  /* top bar: buttons on the first line, search box on its own line */
  .topbar {
    flex-wrap: wrap;
  }

  .search-wrap {
    order: 2;
    flex: 1 1 100%;
    max-width: none;
  }

  .search {
    height: 44px;
  }

  .topbar .btn {
    padding: 9px 10px;
    font-size: 13px;
  }

  /* text boxes use 16px, so phones don't zoom in when you tap them */
  .search,
  .sort,
  label input,
  label textarea {
    font-size: 16px;
  }

  /* bigger buttons that are easier to tap with a finger */
  .nav-link {
    padding: 11px 10px;
    font-size: 16px;
  }

  .small-btn {
    padding: 8px 12px;
    font-size: 14px;
  }

  .open-link {
    padding: 6px 0;
    font-size: 14px;
  }

  /* bigger text on phones so it's easier to read */
  .btn {
    font-size: 14px;
  }

  .sub,
  .result-count {
    font-size: 15px;
  }

  .card h3 {
    font-size: 18px;
  }

  .description {
    font-size: 15px;
    line-height: 1.55;
  }

  .url,
  .archive-row p {
    font-size: 14px;
  }

  .category {
    font-size: 12px;
  }

  .tag,
  .date {
    font-size: 13px;
  }

  .archive-row h3 {
    font-size: 16px;
  }

  label {
    font-size: 14px;
  }

  #toast {
    font-size: 15px;
  }

  /* "Filtered by..." and the sort menu can go on two lines */
  .toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* archived rows: title takes the whole line, tags go underneath */
  .archive-row .grow {
    flex: 1 1 200px;
  }

  /* archived rows: Restore button goes full width under the title */
  .archive-row .btn {
    width: 100%;
  }

  /* pop-up form uses more of the screen */
  .modal {
    padding: 10px;
  }

  .modal-card {
    max-height: 95vh;
  }

  /* message stretches across the bottom of the screen */
  #toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    text-align: center;
  }
}


/* ---------- Very small phones ---------- */

@media (max-width: 400px) {
  /* "Add Bookmark" becomes "Add" so all buttons fit on one line */
  .long-word {
    display: none;
  }
}


/* ---------- Keyboard outline ---------- */

/* show a clear outline when using the keyboard (Tab key) */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #087f73;
  outline-offset: 2px;
}

/* END OF TASK 1 */
