/* Reset and box sizing */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Body and base styles */
body {
  margin: 0;
  padding-top: 56px;    /* Height of fixed header */
  padding-left: 220px;  /* Width of fixed sidebar */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  background-color: #f9fbfd;
  color: #172b4d;
  height: 100vh;
  overflow-y: auto;     /* Enable vertical scroll */
  overflow-x: hidden;   /* Prevent horizontal scroll */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Login container */
.login-container {
  max-width: 360px;
  margin: 12vh auto;
  padding: 32px 24px;
  background: white;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.login-container h2 {
  margin-bottom: 1.5rem;
  font-weight: 600;
  font-size: 1.8rem;
  color: #0052cc;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.login-form input[type="email"],
.login-form input[type="password"] {
  width: 100%;
  padding: 12px 8px;
  margin-bottom: 1.25rem;
  font-size: 1rem;
  border: none;
  border-bottom: 2px solid #dfe3e8;
  background: transparent;
  color: #172b4d;
  transition: border-color 0.3s ease;
}

.login-form input[type="email"]:focus,
.login-form input[type="password"]:focus {
  outline: none;
  border-color: #0052cc;
}

.btn-primary {
  width: 100%;
  padding: 14px 0;
  background-color: #0052cc;
  color: white;
  font-weight: 700;
  font-size: 1rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-primary:hover {
  background-color: #2684ff;
}

.error-message {
  margin-bottom: 1rem;
  padding: 12px 15px;
  background-color: #fdecea;
  color: #de350b;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
  box-shadow: 0 0 5px rgba(222, 53, 11, 0.3);
}

/* Header / Topbar */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: linear-gradient(90deg, #0052cc 0%, #2684ff 100%);
  box-shadow: 0 4px 10px rgba(38, 132, 255, 0.4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28px;
  color: white;
  font-weight: 600;
  user-select: none;
  z-index: 1000;
  transition: background 0.3s ease;
}

.topbar:hover {
  background: linear-gradient(90deg, #0041b3 0%, #1e69e2 100%);
  box-shadow: 0 6px 16px rgba(30, 105, 226, 0.6);
}

/* Brand text */
.brand {
  font-size: 1.3rem;
  letter-spacing: 0.05em;
}

/* Right side in header */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 0.95rem;
}

/* Logout button */
.logout-btn {
  color: white;
  border: 1.5px solid white;
  padding: 6px 18px;
  border-radius: 3px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.3s ease, color 0.3s ease;
  user-select: none;
}

.logout-btn:hover {
  background-color: white;
  color: #0052cc;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 56px;
  left: 0;
  width: 220px;
  height: calc(100vh - 56px);
  background-color: white;
  border-right: 1px solid #e3e6ea;
  display: flex;
  flex-direction: column;
  padding-top: 28px;
  user-select: none;
  z-index: 1000;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 16px;
}

.sidebar nav a {
  font-weight: 600;
  font-size: 1rem;
  color: #172b4d;
  padding: 12px 16px;
  /* border-left: 4px solid transparent; */ /* removed */
  text-decoration: none;
  transition: background-color 0.25s ease;
  border-radius: 0 6px 6px 0;
  white-space: nowrap;
}

.sidebar nav a:hover {
  background-color: #e7f0ff;
  color: #0052cc;
}

.sidebar nav a.active {
  background-color: #d0e4ff;
  color: #0052cc;
}

/* Main content area */
.main-content {
  position: relative;
  width: calc(100% - 220px);
  height: calc(100vh - 56px);
  background-color: #f9fbfd;
  overflow-y: auto;
  border-radius: 0 0 0 6px;
  box-shadow: inset 0 0 8px #cbd9f8;
  padding: 20px 24px;
}

/* Iframe (if used) */
.main-content iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0 0 0 6px;
  background-color: white;
}

/* Table styles */
table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  word-wrap: break-word;
}

table th,
table td {
  padding: 8px 12px;
  border: 1px solid #ccc;
  vertical-align: top;
  text-align: left;
}

table th {
  background-color: #e7f0ff;
  color: #0052cc;
  font-weight: 600;
  white-space: nowrap;
}

/* Links and buttons inside table */
table a,
table button {
  position: relative;
  z-index: 1;
  display: inline-block;
  white-space: nowrap;
  text-decoration: none;
  color: #0052cc;
  padding: 4px 8px;
  border: 1px solid #0052cc;
  border-radius: 4px;
  background: #d0e4ff;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
  user-select: none;
}

table a:hover,
table button:hover {
  background-color: #0052cc;
  color: white;
}

/* Notes blocks */
.note-block {
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 6px 10px;
  margin: 6px 0;
  background: #f9f9f9;
  word-break: break-word;
}

.note-meta {
  font-size: 12px;
  color: #666;
  margin-bottom: 3px;
}

.note-text {
  white-space: pre-wrap;
}

/* Tabs */
.tabs {
  margin-bottom: 16px;
}

.tabs a {
  padding: 8px 12px;
  text-decoration: none;
  background: #eee;
  margin-right: 5px;
  border-radius: 5px;
  color: #000;
  font-weight: 600;
  user-select: none;
}

.tabs a.active {
  background: #007bff;
  color: white;
}

/* Add note link */
.add-note-link {
  font-size: 13px;
  display: inline-block;
  margin-bottom: 6px;
  cursor: pointer;
}

/* Scrollbar styling for main-content */
.main-content::-webkit-scrollbar {
  width: 8px;
}

.main-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.main-content::-webkit-scrollbar-thumb {
  background-color: #0052cc;
  border-radius: 4px;
}

/* Responsive considerations */
@media (max-width: 768px) {
  body {
    padding-left: 0;
    padding-top: 112px; /* header + sidebar height stacked */
  }
  .sidebar {
    position: fixed;
    width: 100%;
    height: 56px;
    top: 56px;
    left: 0;
    flex-direction: row;
    padding-top: 0;
    border-right: none;
    border-bottom: 1px solid #e3e6ea;
    overflow-x: auto;
  }
  .sidebar nav {
    flex-direction: row;
    gap: 0;
    padding-left: 8px;
  }
  .sidebar nav a {
    border-left: none;
    border-bottom: 4px solid transparent;
    padding: 12px 16px;
    border-radius: 0;
    white-space: nowrap;
  }
  .sidebar nav a.active {
    border-left: none;
    border-bottom-color: #0052cc;
  }
  .main-content {
    width: 100%;
    height: calc(100vh - 112px);
    margin-left: 0;
  }
}

/* === Table layout fix: allow columns to size based on content === */
table {
  table-layout: auto !important;
}

/* Set min widths on table headers for better column distribution */
table th:nth-child(1) { min-width: 40px; }   /* ID */
table th:nth-child(2),
table th:nth-child(3) { min-width: 120px; } /* First and Last Name */
table th:nth-child(4) { min-width: 140px; }  /* Phone */
table th:nth-child(5) { min-width: 180px; }  /* Email */
table th:nth-child(6) { min-width: 130px; }  /* Company */
table th:nth-child(7) { min-width: 220px; }  /* Notes */
table th:nth-child(8) { min-width: 70px; }   /* Actions */
