/*
 * Community SaaS Chat - Modern UI/UX Stylesheet
 * This is the primary stylesheet for the chat and profile UI.
 */

/* -------------------------------------------------------------------------- */
/* Variables                                 */
/* -------------------------------------------------------------------------- */

:root {
  --theme-primary: #10b981;
  --theme-primary-dark: #059669;
  --theme-primary-light: #d1fae5;
  --theme-primary-text: #ffffff;

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;

  --bg-body: #f3f4f6;
  --bg-main: #ffffff;
  --bg-sidebar: linear-gradient(180deg, #065f46, #064e3b);
  --bg-messages: #f9fafb;
  --bg-hover: rgba(255, 255, 255, 0.1);
  --bg-message-other: #e5e7eb;

  --border-color: #e5e7eb;
  --border-radius-sm: 6px;
  --border-radius-md: 12px;
  --border-radius-lg: 16px;
  --border-radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --max-width: 1400px;
}

/* -------------------------------------------------------------------------- */
/* Global Styles                               */
/* -------------------------------------------------------------------------- */

.cs-chat-root {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  padding: 2rem 1rem;
}

.cs-chat-root * {
  box-sizing: border-box;
}

/* -------------------------------------------------------------------------- */
/* Chat Layout                                 */
/* -------------------------------------------------------------------------- */

.cs-saas-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: flex-start;
}

.cs-sidebar {
  background: var(--bg-sidebar);
  color: #e5e5e5;
  border-radius: var(--border-radius-lg);
  padding: 1.5rem;
  position: sticky;
  top: 2rem;
  height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
}

.cs-main {
  background: var(--bg-main);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
}

/* -------------------------------------------------------------------------- */
/* Sidebar                                   */
/* -------------------------------------------------------------------------- */

.cs-brand {
  font-weight: 800;
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--theme-primary-text);
}
.cs-brand span { color: var(--theme-primary); }

.cs-user {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 2rem;
  padding: 0.75rem;
  background: rgba(0,0,0,0.2);
  border-radius: var(--border-radius-md);
}
.cs-user .cs-name { font-weight: 600; color: var(--theme-primary-text); }
.cs-user .cs-avatar img { border-radius: 50%; border: 2px solid var(--theme-primary); }

.cs-channels h4 {
    font-size: 0.875rem;
    text-transform: uppercase;
    font-weight: 700;
    color: #a3a3a3;
    padding: 0 0.5rem;
    margin-bottom: 0.5rem;
}
.cs-channels ul {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
}
.cs-channel {
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-sm);
  margin-bottom: 0.25rem;
  cursor: pointer;
  transition: background 0.2s ease-in-out, color 0.2s ease-in-out;
  font-weight: 600;
  color: #d4d4d4;
}
.cs-channel:hover { background: var(--bg-hover); color: var(--theme-primary-text); }
.cs-channel.active {
  background: var(--theme-primary);
  color: var(--theme-primary-text);
  font-weight: 700;
}
.cs-login { padding: 1rem; text-align: center; }
.cs-login a { color: var(--theme-primary-light); text-decoration: none; font-weight: 600; }
.cs-login a:hover { text-decoration: underline; }

/* -------------------------------------------------------------------------- */
/* Main Chat                                 */
/* -------------------------------------------------------------------------- */

.cs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.cs-header h2 { margin: 0; font-size: 1.25rem; }
.cs-header #cs-refresh {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-full);
  cursor: pointer;
  transition: all 0.2s;
}
.cs-header #cs-refresh:hover { background: var(--bg-body); border-color: #d1d5db; }

.cs-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--bg-messages);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cs-message {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-md);
  align-self: flex-start;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  word-wrap: break-word;
}

.cs-message.me {
  align-self: flex-end;
  background: var(--theme-primary);
  color: var(--theme-primary-text);
  border: none;
}

.cs-msg-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.cs-author { font-weight: 700; font-size: 0.9rem; }
.cs-message.me .cs-author { color: var(--theme-primary-light); }

.cs-msg-head time { font-size: 0.75rem; color: var(--text-muted); }
.cs-message.me .cs-msg-head time { color: rgba(255, 255, 255, 0.7); }

.cs-msg-body {
  font-size: 1rem;
  line-height: 1.5;
}

.cs-msg-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.cs-message:hover .cs-msg-actions { opacity: 1; }
.cs-msg-actions button {
  background: rgba(0,0,0,0.05);
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-full);
  color: var(--text-secondary);
}
.cs-message.me .cs-msg-actions button {
  background: rgba(255, 255, 255, 0.2);
  color: var(--theme-primary-text);
}

.cs-message.pinned {
  border-left: 4px solid var(--theme-primary-dark);
  background: #f0fdf4;
}

.cs-loading, .cs-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.cs-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-main);
}
.cs-send-form { display: flex; gap: 0.75rem; align-items: center; }
.cs-input-wrapper { flex: 1; position: relative; }
#cs-message-input {
  width: 100%;
  padding: 0.75rem 1.25rem;
  border-radius: var(--border-radius-full);
  border: 1px solid var(--border-color);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#cs-message-input:focus {
  outline: none;
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}
#cs-send-btn {
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius-full);
  border: none;
  background: var(--theme-primary);
  color: var(--theme-primary-text);
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.2s;
}
#cs-send-btn:hover, #cs-send-btn:focus { background: var(--theme-primary-dark); }
#cs-send-btn:disabled { background: #9ca3af; cursor: not-allowed; }

.cs-guest { text-align: center; color: var(--text-muted); }
.cs-guest a { color: var(--theme-primary); text-decoration: none; font-weight: 600; }
.cs-guest a:hover { text-decoration: underline; }

/* -------------------------------------------------------------------------- */
/* Profile Page                                */
/* -------------------------------------------------------------------------- */
.cs-profile-wrap {
  max-width: 900px;
  margin: 0 auto;
}
.cs-profile-card {
  background: var(--bg-main);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.cs-top {
  display: flex;
  gap: 2rem;
  align-items: center;
  padding: 2.5rem;
  background: var(--bg-body);
  border-bottom: 1px solid var(--border-color);
}
.cs-avatar-large img {
  border-radius: 50%;
  border: 4px solid var(--bg-main);
  box-shadow: var(--shadow-md);
}
.cs-meta h2 {
  margin: 0 0 0.25rem 0;
  font-size: 2rem;
  font-weight: 800;
}
.cs-meta .cs-email, .cs-meta .cs-joined {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1rem;
}

.cs-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 2.5rem 0;
  border-bottom: 1px solid var(--border-color);
}
.cs-tab {
  padding: 0.75rem 1rem;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.cs-tab:hover { color: var(--text-primary); }
.cs-tab.active {
  color: var(--theme-primary);
  border-color: var(--theme-primary);
}
.cs-tab-contents { padding: 2.5rem; }
.cs-tab-content h3 {
  font-size: 1.25rem;
  margin: 0 0 1.5rem 0;
  font-weight: 700;
}
.cs-badges {
  list-style: none;
  padding: 0;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.cs-badge {
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-full);
  background: var(--theme-primary-light);
  color: var(--theme-primary-dark);
  font-weight: 600;
}
.cs-history { list-style: none; padding: 0; }
.cs-history li {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.cs-history li:last-child { border-bottom: none; }
.cs-history .cs-time {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* -------------------------------------------------------------------------- */
/* Responsive                                 */
/* -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .cs-saas-grid {
    grid-template-columns: 240px 1fr;
    gap: 1rem;
  }
  .cs-sidebar, .cs-main {
    height: calc(100vh - 3rem);
    top: 1.5rem;
  }
}

@media (max-width: 768px) {
  .cs-chat-root { padding: 0; }
  .cs-saas-grid {
    grid-template-columns: 1fr;
    height: 100vh;
    gap: 0;
  }
  .cs-sidebar {
    display: none;
  }
  .cs-main {
    height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }
  .cs-top {
    flex-direction: column;
    text-align: center;
  }
  .cs-tabs {
    justify-content: center;
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .cs-tab-contents {
    padding: 1.5rem;
  }
}


/* -------------------------------------------------------------------------- */
/* Modern Profile Page Design                         */
/* -------------------------------------------------------------------------- */

.cs-profile-wrap {
    max-width: 1100px;
    margin: 0 auto;
}

.cs-profile-header {
    background: var(--bg-main);
    border-radius: var(--border-radius-lg);
    padding: 2rem 2.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

.cs-profile-avatar img {
    border-radius: 50%;
    border: 4px solid var(--theme-primary-light);
}

.cs-profile-name {
    margin: 0 0 0.5rem 0;
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.cs-profile-joined {
    margin: 0 0 1.5rem 0;
    color: var(--text-muted);
    font-size: 1rem;
}

.cs-profile-stats {
    display: flex;
    gap: 2rem;
}

.cs-stat {
    text-align: center;
}

.cs-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--theme-primary);
}

.cs-stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.cs-profile-body {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    align-items: flex-start;
}

.cs-profile-main {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.cs-profile-card {
    background: var(--bg-main);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

.cs-profile-card h3 {
    margin: 0 0 1.5rem 0;
    font-size: 1.25rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.cs-profile-bio p:first-child { margin-top: 0; }
.cs-profile-bio p:last-child { margin-bottom: 0; }

.cs-badges-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.cs-badge {
    background-color: var(--theme-primary-light);
    color: var(--theme-primary-dark);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-full);
    font-weight: 600;
    font-size: 0.875rem;
}

.cs-activity-feed {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cs-activity-feed li {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.cs-activity-feed li:first-child { padding-top: 0; }
.cs-activity-feed li:last-child { border-bottom: none; padding-bottom: 0; }

.cs-activity-feed p {
    margin: 0 0 0.5rem 0;
    color: var(--text-secondary);
}
.cs-activity-feed blockquote {
    margin: 0;
    padding-left: 1rem;
    border-left: 3px solid var(--border-color);
    color: var(--text-primary);
    font-style: italic;
}
.cs-activity-feed time {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.cs-text-muted {
    color: var(--text-muted);
    font-style: italic;
}

/* Responsive adjustments for profile page */
@media (max-width: 900px) {
    .cs-profile-body {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .cs-profile-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    .cs-profile-stats {
        justify-content: center;
    }
}

/* -------------------------------------------------------------------------- */
/* Interactive Chat Action Buttons                         */
/* -------------------------------------------------------------------------- */

.cs-msg-actions button.active {
    background-color: var(--theme-primary-light);
    color: var(--theme-primary-dark);
    font-weight: 600;
}

.cs-message.me .cs-msg-actions button.active {
    background-color: var(--theme-primary-text);
    color: var(--theme-primary);
}

.cs-msg-actions button.cs-flag.active {
    cursor: default;
    opacity: 0.7;
}

/* -------------------------------------------------------------------------- */
/* Profile Page Tabs & Settings Form                         */
/* -------------------------------------------------------------------------- */
.cs-profile-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
}
.cs-tab {
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px; /* Overlap border */
    transition: all 0.2s ease-in-out;
}
.cs-tab:hover {
    color: var(--text-primary);
}
.cs-tab.active {
    color: var(--theme-primary);
    border-bottom-color: var(--theme-primary);
}

.cs-tab-content {
    display: none;
    flex-direction: column;
    gap: 2rem;
}
.cs-tab-content.active {
    display: flex;
}

/* Settings Form Styles */
#cs-profile-edit-form h3 {
    margin-top: 0;
}
.cs-form-group {
    margin-bottom: 1.5rem;
}
.cs-form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}
.cs-form-group input[type="text"],
.cs-form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-family: var(--font-sans);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.cs-form-group input[type="text"]:focus,
.cs-form-group textarea:focus {
    outline: none;
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}
.cs-form-group textarea {
    resize: vertical;
    min-height: 120px;
}
.cs-avatar-note {
    display: flex;
    align-items: center;
    gap: 1rem;
    background-color: var(--bg-messages);
    padding: 1rem;
    border-radius: var(--border-radius-sm);
}
.cs-avatar-note img {
    border-radius: 50%;
}
.cs-avatar-note span {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}
.cs-form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}
.cs-button-primary {
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-full);
    border: none;
    background: var(--theme-primary);
    color: var(--theme-primary-text);
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: background-color 0.2s;
}
.cs-button-primary:hover {
    background: var(--theme-primary-dark);
}
.cs-button-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}
#cs-profile-feedback {
    font-weight: 600;
}
#cs-profile-feedback.success {
    color: var(--theme-primary-dark);
}
#cs-profile-feedback.error {
    color: #be123c; /* Red */
}