/* === Global Base Styles === */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #f8f9fa;
  color: #333;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

/* === Typography === */
h1, h2, h3, h4, h5 {
  font-weight: 600;
  color: #212529;
}

p {
  color: #555;
  line-height: 1.6;
}

/* === Professional Navbar === */
.navbar {
  background: linear-gradient(135deg, #0c1d4d 0%, #2c49a9 100%);
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 32px;
  height: 64px;
  gap: 24px;
}

.brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff;
  text-decoration: none;
  letter-spacing: -0.02em;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand:hover {
  opacity: 0.9;
}

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.nav-links a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  transition: all 0.2s ease;
  padding: 8px 16px;
  border-radius: 6px;
  position: relative;
}

.nav-links a:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.nav-links a:active {
  background: rgba(255, 255, 255, 0.1);
}

.nav-toggle {
  display: none;
}

/* === Cards === */
.card {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background-color: #fff;
  margin-bottom: 1rem;
}

.card:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.card-body {
  padding: 20px;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
}

/* === Buttons === */
.btn {
  border-radius: 6px;
  font-weight: 500;
  transition: transform 0.1s ease, background-color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background-color: #007bff;
  border-color: #007bff;
}

.btn-primary:hover {
  background-color: #0056b3;
}

.btn-danger {
  background-color: #dc3545;
  border: none;
}

.btn-danger:hover {
  background-color: #b02a37;
}

/* === Forms === */
input, select, textarea {
  border-radius: 5px;
  border: 1px solid #ccc;
  padding: 6px 8px;
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13,110,253,0.25);
}

/* Remove number input arrows globally for a cleaner look */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* === Footer === */
footer {
  text-align: center;
  color: #777;
  font-size: 14px;
  margin-top: 50px;
  padding-bottom: 20px;
}

/* === Utility Classes === */
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mb-3 { margin-bottom: 16px; }
.shadow-sm { box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* === Excel-style Table (Minimal & Consistent) === */
.line-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: white;
}

.line-items-table th,
.line-items-table td {
  border: 1px solid #d0d0d0;
  padding: 0 3px;
  height: 18px;
  vertical-align: middle;
}

.line-items-table th {
  background: #f3f3f3;
  font-weight: bold;
  text-align: center;
}

.line-items-table tr:nth-child(even) {
  background-color: #fafafa;
}

.line-items-table tr:hover {
  background-color: #e9f3ff;
}

.line-items-table input {
  width: 100%;
  height: 18px;
  border: none;
  padding: 0 3px;
  background: transparent;
  font-size: 12px;
  font-family: inherit;
}

.line-item-cell:focus {
  outline: 2px solid #0078d4;   /* thinner than default */
  outline-offset: -1px;         /* move it inside the cell */
  background-color: #fffceb;    /* subtle highlight like Excel */
}

/* === Compact Delete Button (for spreadsheet tables) === */
.delete-btn-small {
  all: unset;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0 2px;
  text-align: center;
}

.delete-btn-small:hover {
  color: red;
  background-color: #ffeaea;
}

/* === Messages Icon Button === */
.nav-icon-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: #ffffff;
  padding: 6px 10px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
  min-width: 40px;
  height: 40px;
}

.nav-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.nav-icon-btn:active {
  transform: translateY(0);
  background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
  .nav-container {
    padding: 0 16px;
  }
  
  .nav-links {
    gap: 4px;
  }
  
  .nav-links a {
    padding: 6px 12px;
    font-size: 0.875rem;
  }
  
  .brand {
    font-size: 1.25rem;
  }
}


/* === Slide-Out Chat Panel (Global) === */
.chat-panel { position: fixed; top: 0; right: -420px; width: 420px; height: 100%; background: #fff; border-left: 1px solid #dce3eb; box-shadow: -2px 0 10px rgba(0,0,0,0.08); transition: right 0.3s ease; display: flex; flex-direction: column; z-index: 1050; }
.chat-panel.open { right: 0; }
.chat-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid #e5e7eb; background: #f8f9fa; }
.chat-body { display: grid; grid-template-columns: auto 1fr; gap: 0; height: calc(100% - 52px); }
.chat-sidebar {
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  width: 56px;                   
  transition: width 0.3s ease;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chat-sidebar:hover { width: 220px; }

.chat-sidebar * {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* Message */
.chat-sidebar-header { padding: 8px; border-bottom: 1px solid #e5e7eb; }
.chat-sidebar-header input { width: 100%; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 0.9rem; }
.chat-section-title { margin: 8px 8px 4px; font-size: 0.8rem; color: #64748b; text-transform: uppercase; letter-spacing: .03em; }
.chat-list { list-style: none; padding: 0; margin: 0; overflow-y: auto; }
.chat-list-item { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; cursor: pointer; }
.chat-list-item:hover { background: #f8fafc; }
.chat-list-name { font-size: 0.95rem; color: #0f172a; font-weight: 600; }
.chat-list-sub { font-size: 0.8rem; color: #64748b; }

.chat-main { display: flex; flex-direction: column; height: 100%; }
.chat-thread-header { padding: 10px 12px; border-bottom: 1px solid #e5e7eb; background: #fafafa; font-weight: 600; color: #0f172a; }
.chat-messages { flex: 1; overflow-y: auto; padding: 10px 12px; background: #fff; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e5e7eb; background: #fafafa; }
.chat-input input { flex: 1; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.95rem; }
.chat-input .btn { padding: 6px 12px; }

.message { max-width: 78%; padding: 8px 12px; border-radius: 10px; word-break: break-word; margin-bottom: 8px; }
.message.sent { align-self: flex-end; background: #d1e7dd; }
.message.received { align-self: flex-start; background: #e2e8f0; }
.message-meta { font-size: 0.75rem; color: #64748b; text-align: right; margin-top: 2px; }

/* === Chat Sidebar Collapse/Expand Details === */
.chat-all-heading { font-size: 1rem; font-weight: 600; margin: 6px 0; text-align: center; color: #0f172a; }

.chat-sidebar:not(:hover) .chat-section-title,
.chat-sidebar:not(:hover) .chat-list-sub,
.chat-sidebar:not(:hover) #chat-search,
.chat-sidebar:not(:hover) .chat-all-heading,
.chat-sidebar:not(:hover) .chat-list-name,
.chat-sidebar:not(:hover) .chat-list-item { display: none !important; }

#new-chat-header::after { content: '+'; display: block; text-align: center; font-size: 1.2rem; font-weight: 700; }
.chat-sidebar:hover #new-chat-header::after { content: '+ New Chat'; font-size: 1rem; font-weight: 600; }

/* === Chat Home (All Chats list) === */
.chat-home { padding: 10px 14px; overflow-y: auto; }
.chat-home.hidden { display: none; }
.chat-home h4 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
#chat-home-list { list-style: none; padding: 0; margin: 0; }
.chat-home-item {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
}
.chat-home-item:hover { background: #f8fafc; }
.chat-home-name {
  font-weight: 500;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
.chat-home-preview {
  font-size: 0.85rem;
  color: #9ca3af;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
.chat-home-meta {
  font-size: 0.75rem;
  color: #94a3b8;
  align-self: flex-end;
}

/* Back button in thread header */
.chat-back-btn { background: none; border: none; font-size: 0.9rem; cursor: pointer; color: #0d6efd; margin-right: 8px; }
.chat-back-btn:hover { text-decoration: underline; }

/* Generic hidden utility */
.hidden { display: none !important; }