/* 
  EduFlow SaaS Educational ERP - Communication & Messaging Module Stylesheet
  -------------------------------------------------------------------------
*/

/* Import app and design system styles */
@import url("app.css");

/* --- Main workspace grid --- */
.communication-workspace-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  width: 100%;
}

.communication-screen-element {
  display: none;
  width: 100%;
  animation: fadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.communication-screen-element.active {
  display: block;
}

/* --- Slack/Teams Split Screen Layout for Messaging (Screens 2 & 3) --- */
.chat-container {
  display: flex;
  height: 600px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Sidebar for Contacts / Channels */
.chat-sidebar {
  width: 280px;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  background-color: var(--color-surface-hover);
}

.chat-sidebar-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-surface);
}

.chat-search-wrapper {
  position: relative;
  margin-top: 8px;
}

.chat-search-input {
  width: 100%;
  padding: 6px 12px 6px 32px;
  font-size: 0.8125rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background-color: var(--color-surface-hover);
  outline: none;
}

.chat-search-input:focus {
  border-color: var(--color-primary);
  background-color: var(--color-surface);
}

.chat-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
}

.chat-item:hover {
  background-color: var(--color-surface-active);
}

.chat-item.active {
  background-color: var(--color-surface-active);
  border-left-color: var(--color-primary);
}

.chat-avatar-wrapper {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.chat-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--color-surface);
}

.status-online {
  background-color: var(--color-success);
}

.status-offline {
  background-color: var(--color-text-tertiary);
}

.chat-item-info {
  flex: 1;
  min-width: 0;
}

.chat-item-name-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}

.chat-item-name {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-time {
  font-size: 0.6875rem;
  color: var(--color-text-tertiary);
}

.chat-item-preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-item-preview {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-badge {
  background-color: var(--color-primary);
  color: var(--color-text-on-primary);
  font-size: 0.625rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

/* Chat Main Area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--color-surface);
}

.chat-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-history-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  background-color: var(--color-bg);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Message Bubbles */
.message-row {
  display: flex;
  gap: 12px;
  max-width: 75%;
}

.message-row.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-row.received {
  align-self: flex-start;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  position: relative;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-row.sent .message-bubble {
  background-color: var(--color-primary);
  color: var(--color-text-on-primary);
  border-top-right-radius: 2px;
}

.message-row.received .message-bubble {
  background-color: var(--color-surface);
  color: var(--color-text-primary);
  border-top-left-radius: 2px;
  border: 1px solid var(--color-border);
}

.message-text {
  font-size: 0.875rem;
  line-height: 1.4;
  word-break: break-word;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 0.6875rem;
}

.message-row.sent .message-meta {
  color: rgba(255, 255, 255, 0.7);
}

.message-row.received .message-meta {
  color: var(--color-text-tertiary);
}

.message-status-icon {
  width: 12px;
  height: 12px;
}

.typing-indicator-bubble {
  align-self: flex-start;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  background-color: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--color-text-secondary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Chat Input Footer */
.chat-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
  background-color: var(--color-surface);
}

.chat-input-wrapper {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-surface-hover);
  overflow: hidden;
}

.chat-input-textarea {
  width: 100%;
  border: none;
  background: transparent;
  padding: var(--space-3) var(--space-4);
  font-size: 0.875rem;
  resize: none;
  outline: none;
  min-height: 48px;
  max-height: 120px;
  color: var(--color-text-primary);
}

.chat-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.chat-toolbar-left {
  display: flex;
  gap: 4px;
}

.chat-tool-btn {
  background: none;
  border: none;
  padding: var(--space-2);
  color: var(--color-text-secondary);
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all var(--transition-fast);
}

.chat-tool-btn:hover {
  background-color: var(--color-surface-hover);
  color: var(--color-primary);
}

/* Emoji Picker Dropdown Simulation */
.emoji-picker-sim {
  position: absolute;
  bottom: 44px;
  left: 0;
  width: 220px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  z-index: 100;
  display: none;
}

.emoji-picker-sim.active {
  display: grid;
}

.emoji-btn {
  background: none;
  border: none;
  font-size: 1.125rem;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-xs);
}

.emoji-btn:hover {
  background-color: var(--color-surface-hover);
}

/* Shared Files Sidebar */
.shared-files-panel {
  width: 240px;
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  background-color: var(--color-surface);
}

/* Message Reactions */
.reaction-container {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.reaction-pill {
  background-color: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 2px;
}

.reaction-pill:hover {
  border-color: var(--color-primary);
}

.reaction-pill.active {
  background-color: rgba(97, 61, 223, 0.08);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Pin/Star markers */
.star-marker, .pin-marker {
  color: var(--color-accent);
}

/* --- Screen 4: Broadcast messaging --- */
.broadcast-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

@media (max-width: 768px) {
  .broadcast-form-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Screen 5: Announcements Center --- */
.announcement-card {
  border-left: 4px solid var(--color-border);
  position: relative;
  transition: transform var(--transition-fast);
}

.announcement-card:hover {
  transform: translateX(2px);
}

.priority-critical { border-left-color: var(--color-danger); }
.priority-high { border-left-color: var(--color-warning); }
.priority-normal { border-left-color: var(--color-info); }
.priority-low { border-left-color: var(--color-text-tertiary); }

.priority-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  display: inline-flex;
}

.priority-badge-critical { background-color: var(--color-danger-bg); color: var(--color-danger); }
.priority-badge-high { background-color: var(--color-warning-bg); color: var(--color-warning); }
.priority-badge-normal { background-color: var(--color-info-bg); color: var(--color-info); }
.priority-badge-low { background-color: var(--color-surface-soft); color: var(--color-text-secondary); }

/* --- Screen 6: Notification Drawer & Bell --- */
.notification-bell-btn {
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  color: var(--color-text-secondary);
}

.notification-drawer {
  position: fixed;
  top: 72px;
  right: -320px;
  width: 320px;
  height: calc(100vh - 72px);
  background-color: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  z-index: 98;
  display: flex;
  flex-direction: column;
  transition: right var(--transition-normal);
}

.notification-drawer.active {
  right: 0;
}

.drawer-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
}

.drawer-notification-item {
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.drawer-notification-item:hover {
  background-color: var(--color-surface-hover);
}

.drawer-notification-item.unread {
  background-color: rgba(97, 61, 223, 0.04);
}

.drawer-notification-item.unread::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-primary);
  margin-right: 6px;
}

/* Categories styles */
.cat-attendance { border-left: 3px solid var(--color-warning); }
.cat-academics { border-left: 3px solid var(--color-primary); }
.cat-finance { border-left: 3px solid var(--color-success); }
.cat-communication { border-left: 3px solid var(--color-info); }
.cat-system { border-left: 3px solid var(--color-text-tertiary); }

/* --- Screen 8: Templates Grid --- */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
}

.template-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 180px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.template-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}

/* --- Screen 9: Scheduled Messages Calendar --- */
.schedule-calendar-wrapper {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.schedule-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.schedule-calendar-cell {
  aspect-ratio: 1.2;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px;
  background-color: var(--color-surface-hover);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  position: relative;
}

.schedule-calendar-cell:hover {
  background-color: var(--color-surface-active);
}

.schedule-calendar-cell.active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(97, 61, 223, 0.2);
}

.schedule-calendar-cell.muted {
  opacity: 0.3;
}

.schedule-pins-container {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.schedule-pin-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* --- Screen 11: Permissions toggle matrix --- */
.permission-matrix-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-4);
}

.permission-matrix-table th, .permission-matrix-table td {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  text-align: center;
}

.permission-matrix-table th:first-child, .permission-matrix-table td:first-child {
  text-align: left;
  font-weight: 700;
}

/* Custom switch toggle */
.matrix-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.matrix-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.matrix-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-border);
  transition: .4s;
  border-radius: 34px;
}

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

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

input:checked + .matrix-slider:before {
  transform: translateX(20px);
}

/* Toast Notification Styling override */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  z-index: 1000;
}

.toast {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 300px;
  max-width: 400px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.removing {
  animation: toastOut 0.3s ease-in forwards;
}

.toast-success { border-left: 4px solid var(--color-success); }
.toast-danger { border-left: 4px solid var(--color-danger); }
.toast-info { border-left: 4px solid var(--color-info); }

.toast-icon {
  color: var(--color-text-secondary);
}

.toast-success .toast-icon { color: var(--color-success); }
.toast-danger .toast-icon { color: var(--color-danger); }
.toast-info .toast-icon { color: var(--color-info); }

.toast-body {
  flex: 1;
}

.toast-title {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--color-text-primary);
}

.toast-desc {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-tertiary);
  padding: 2px;
}

.toast-close:hover {
  color: var(--color-text-secondary);
}

/* Mobile responsive overlay overrides */
.mobile-sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(36, 22, 85, 0.3);
  backdrop-filter: blur(4px);
  z-index: 99;
  display: none;
}

.mobile-sidebar-overlay.active {
  display: block;
}
