/* ==========================================================================
   base.css — global layout and component styles for base.html
   Dynamic rules (body padding-top, .navbar top) remain inline in base.html
   ========================================================================== */

/* Sticky footer layout */
.site-body { display: flex; min-height: 100vh; flex-direction: column; }
.site-main { flex: 1 0 auto; padding-bottom: 72px; }
.site-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1020; }

/* Unauthenticated layout */
.unauthenticated-content { flex: 1 1 auto; min-height: 0; }
.unauthenticated-content > * { margin-left: auto; margin-right: auto; }

/* Mobile nav improvements */
@media (max-width: 576px) {
  .navbar-brand span { font-size: 1rem; }
  .navbar-nav .nav-link { padding: 0.75rem 0.5rem; font-size: 0.95rem; }
}

/* Enhanced Navigation Styles */
.navbar {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%) !important;
  box-shadow: 0 2px 15px rgba(0, 123, 255, 0.3);
  transition: all 0.3s ease;
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1030;
}

.navbar-brand {
  font-weight: 600;
  font-size: 1.4rem;
  transition: all 0.3s ease;
}

.navbar-brand:hover {
  transform: scale(1.05);
}

.navbar-brand i {
  background: linear-gradient(45deg, #ffd700, #ffed4e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.navbar img {
  transition: all 0.3s ease;
  border-radius: 50%;
}

.navbar img:hover {
  transform: rotate(360deg) scale(1.1);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

/* Dropdown submenu support for Bootstrap 5 */
.dropdown-submenu {
  position: relative;
}

.dropdown-submenu .dropdown-menu {
  top: 0;
  left: 100%;
  margin-top: -1px;
}

.dropdown-submenu:hover > .dropdown-menu {
  display: block;
}

.dropdown-submenu > .dropdown-toggle::after {
  transform: rotate(-90deg);
  position: absolute;
  right: 10px;
  top: 50%;
  margin-top: -3px;
}

/* Time Tracker Widget */
.timer-widget {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 0.9rem;
}
.timer-widget.timer-running {
  background: rgba(25, 135, 84, 0.2);
  border: 1px solid rgba(25, 135, 84, 0.3);
}
.timer-widget.timer-paused {
  background: rgba(255, 193, 7, 0.2);
  border: 1px solid rgba(255, 193, 7, 0.3);
}
.timer-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.timer-task {
  font-weight: 500;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.timer-duration {
  font-family: monospace;
  font-weight: bold;
  font-size: 1rem;
}
.timer-controls {
  display: flex;
  gap: 0.25rem;
}
.timer-controls .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

/* Select2 — rounded-pill in filter forms */
form .select2-container--bootstrap-5 .select2-selection--single {
  border-radius: 50rem !important;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
  height: 48px !important;
  display: flex !important;
  align-items: center !important;
}

form .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
  line-height: 1.5 !important;
  padding: 0 16px !important;
  font-size: 1.25rem !important;
  font-weight: 400 !important;
  color: #495057 !important;
  flex: 1 !important;
  display: flex !important;
  align-items: center !important;
}

form .select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
  height: 46px !important;
  top: 1px !important;
  right: 16px !important;
}

.select2-container--bootstrap-5 .select2-dropdown {
  border-radius: 0.375rem !important;
}

/* Global Spinner */
#global-spinner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.5);
  z-index: 9999;
  text-align: center;
}

#global-spinner .spinner-border {
  margin-top: 20vh;
  width: 3rem;
  height: 3rem;
}

/* Environment Banner */
.environment-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  padding: 8px 0;
  font-weight: bold;
  font-size: 1.1rem;
  line-height: 1rem;
  z-index: 1040;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.environment-banner span:first-of-type {
  font-weight: bold;
  letter-spacing: 5px;
}

.environment-banner span.ms-2 {
  font-size: 0.85rem;
  opacity: 0.9;
}

/* Notification badge */
#notificationCount {
  display: none;
}

/* Dropdown menu widths */
.dropdown-menu.dropdown-menu-end[aria-labelledby="notificationDropdown"],
.dropdown-menu.dropdown-menu-end[aria-labelledby="helpDropdown"] {
  width: 320px;
}

/* Notification list padding */
#notificationList {
  padding: 0;
}

/* Chat panel header button group */
.chat-panel-header > div[style*="display: flex"] {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Clear chat button */
#clear-chat-btn {
  padding: 4px 8px;
}

.clear-chat-trigger-btn {
  display: block;
  margin-top: 8px;
  padding: 4px 12px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

/* AI Chat Widget hidden by default */
#ai-chat-widget {
  display: none;
}

/* ==========================================================================
   Chat Side Panel
   ========================================================================== */

#chat-side-panel {
  position: fixed;
  top: 0;
  right: -450px;
  width: 450px;
  height: 100vh;
  background: white;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.15);
  z-index: 1050;
  transition: right 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
}

#chat-side-panel.open {
  right: 0;
}

#chat-toggle-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
  cursor: pointer;
  z-index: 1040;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: all 0.3s ease;
}

#chat-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 123, 255, 0.6);
}

#chat-toggle-btn.active {
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

body.chat-panel-open main,
body.chat-panel-open nav {
  margin-right: 450px;
  transition: margin-right 0.3s ease-in-out;
}

.chat-panel-header {
  padding: 20px;
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-panel-header h5 {
  margin: 0;
  font-weight: 600;
}

.chat-panel-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.chat-panel-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chat-panel-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
}

.chat-suggestions {
  padding: 10px 15px;
  background: white;
  border-top: 1px solid #e9ecef;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-suggestion-chip {
  padding: 6px 12px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.chat-suggestion-chip:hover {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.chat-input-area {
  padding: 15px;
  background: white;
  border-top: 1px solid #dee2e6;
  display: flex;
  gap: 10px;
}

.chat-input-area input {
  flex: 1;
}

.chat-input-area button {
  width: 45px;
  height: 45px;
  padding: 0;
}

.chat-message {
  margin-bottom: 15px;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-message.user    { text-align: right; }
.chat-message.assistant { text-align: left; }

.chat-bubble {
  display: inline-block;
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
}

.chat-message.user .chat-bubble {
  background: #007bff;
  color: white;
}

.chat-message.assistant .chat-bubble {
  background: white;
  color: #333;
  border: 1px solid #dee2e6;
}

.chat-timestamp {
  font-size: 0.75rem;
  color: #6c757d;
  margin-top: 4px;
}

#typing-indicator .chat-bubble {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1; }
}

/* Chat dark mode */
[data-bs-theme="dark"] #chat-side-panel {
  background: #212529;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);
}
[data-bs-theme="dark"] .chat-messages {
  background: #1a1d20;
}
[data-bs-theme="dark"] .chat-suggestions {
  background: #2b3035;
  border-top-color: #3a3f47;
}
[data-bs-theme="dark"] .chat-suggestion-chip {
  background: #3a3f47;
  border-color: #4a5058;
  color: #e9ecef;
}
[data-bs-theme="dark"] .chat-suggestion-chip:hover {
  background: #667eea;
  color: white;
  border-color: #667eea;
}
[data-bs-theme="dark"] .chat-input-area {
  background: #212529;
  border-top-color: #495057;
}
[data-bs-theme="dark"] .chat-message.assistant .chat-bubble {
  background: #2b3035;
  color: #f8f9fa;
  border-color: #495057;
}
[data-bs-theme="dark"] .chat-panel-header {
  background: linear-gradient(135deg, #0056b3 0%, #003d82 100%);
}

@media (max-width: 768px) {
  #chat-side-panel {
    width: 100%;
    right: -100%;
  }
  body.chat-panel-open main,
  body.chat-panel-open nav {
    margin-right: 0;
    display: none;
  }
}

/* ==========================================================================
   AI Chat Widget (legacy floating widget)
   ========================================================================== */

.ai-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 450px;
  height: 600px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-chat-widget-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 12px 12px 0 0;
}

.ai-chat-widget-body {
  display: flex;
  flex-direction: column;
  height: calc(100% - 60px);
  overflow: hidden;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
}

.ai-chat-input-area {
  padding: 15px;
  background: white;
  border-top: 1px solid #dee2e6;
}

.ai-welcome-message {
  background: white;
  padding: 20px;
  border-radius: 8px;
  border-left: 4px solid #667eea;
}

.ai-welcome-message ul {
  margin-bottom: 0;
}

.ai-chat-message {
  margin-bottom: 15px;
  animation: fadeIn 0.3s;
}

.ai-chat-message.user {
  text-align: right;
}

.ai-chat-message.user .message-content {
  background: #667eea;
  color: white;
  display: inline-block;
  padding: 10px 15px;
  border-radius: 12px 12px 4px 12px;
  max-width: 80%;
  text-align: left;
}

.ai-chat-message.assistant .message-content {
  background: white;
  display: inline-block;
  padding: 10px 15px;
  border-radius: 12px 12px 12px 4px;
  max-width: 80%;
  border: 1px solid #dee2e6;
}

.ai-chat-message.assistant .message-content a {
  color: #667eea;
  text-decoration: underline;
}

@media (max-width: 768px) {
  .ai-chat-widget {
    width: calc(100% - 40px);
    height: calc(100% - 40px);
    bottom: 20px;
    right: 20px;
  }
}
