:root {
  --sidebar-width: 280px;
  --color-primary: #f97316; /* Orange 500 */
  --color-primary-600: #ea580c; /* Orange 600 */
  --color-secondary: #0f172a; /* Slate 900 / Black */
  --color-accent: #fb923c; /* Orange 400 */
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-muted: #64748b;
  --gradient-primary: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  --gradient-dark: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  --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);
  --radius-md: 12px;
  --radius-lg: 16px;
}

[data-bs-theme="dark"] {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-border: #334155;
  --color-muted: #94a3b8;
}

body { 
  background-color: var(--color-bg); 
  color: var(--color-secondary); 
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[data-bs-theme="dark"] body {
  color: #f1f5f9;
}

.navbar {
  box-shadow: var(--shadow-sm); 
  background: var(--color-surface); 
  border-bottom: 1px solid var(--color-border) !important;
}

.icon-nav .nav-link { 
  padding: 12px; 
  font-size: 1.25rem; 
  color: var(--color-muted); 
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.icon-nav .nav-link:hover, .icon-nav .nav-link.active { 
  background: var(--gradient-primary); 
  color: white !important;
  box-shadow: var(--shadow-md);
}

.card { 
  border: 1px solid var(--color-border); 
  border-radius: var(--radius-lg); 
  background: var(--color-surface); 
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.card-title { 
  color: var(--color-secondary); 
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
}

[data-bs-theme="dark"] .card-title {
  color: #f1f5f9;
}

.btn-primary { 
  background: var(--gradient-primary); 
  border: none;
  border-radius: var(--radius-md); 
  font-weight: 500;
  padding: 0.6rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover { 
  background: var(--color-primary-600); 
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--color-secondary);
  border: none;
  border-radius: var(--radius-md);
}

.btn-outline-danger { border-radius: var(--radius-md); }

.form-control { 
  border-radius: var(--radius-md); 
  border-color: var(--color-border); 
  padding: 0.6rem 1rem;
}

.form-control:focus { 
  border-color: var(--color-primary); 
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.1); 
}

.table { 
  border-radius: var(--radius-md); 
  overflow: hidden; 
}

.table thead th { 
  background: #f8fafc; 
  color: var(--color-secondary); 
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 1rem;
  border-bottom: 2px solid var(--color-border);
}

[data-bs-theme="dark"] .table thead th {
  background: #0f172a;
  color: #f1f5f9;
}

.table td {
  padding: 1rem;
  vertical-align: middle;
}

.table-striped tbody tr:nth-of-type(odd){ background-color: rgba(248, 250, 252, 0.5); }
[data-bs-theme="dark"] .table-striped tbody tr:nth-of-type(odd){ background-color: rgba(30, 41, 59, 0.5); }

.login-body { 
  background: var(--gradient-dark); 
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.container-login { 
  width: 100%; 
  max-width: 420px; 
  background: white;
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.bottom-nav { 
  position: fixed; 
  bottom: 0; 
  left: 0; 
  right: 0; 
  background: var(--color-surface); 
  border-top: 1px solid var(--color-border); 
  box-shadow: 0 -4px 12px rgba(0,0,0,0.05); 
  z-index: 1030;
}

.bottom-nav .nav-link { 
  padding: 12px; 
  font-size: 1.3rem; 
  color: var(--color-muted); 
}

.bottom-nav .nav-link.active {
  color: var(--color-primary);
}

.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
}

.badge-custom {
  padding: 0.5em 1em;
  border-radius: 20px;
  font-weight: 500;
}

@media (min-width: 992px) {
  .sidebar-persistent {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    z-index: 1040;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
  }
  
  .app-main, .app-navbar {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease, width 0.3s ease;
  }
  
  /* Collapsed State */
  body.sidebar-collapsed .sidebar-persistent {
    transform: translateX(-100%);
  }
  body.sidebar-collapsed .app-main,
  body.sidebar-collapsed .app-navbar {
    margin-left: 0 !important;
    width: 100% !important;
  }

  /* Login State */
  body.login-body .sidebar-persistent {
    display: none;
  }
  body.login-body .app-main, body.login-body .app-navbar {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .navbar .btn-outline-primary[data-bs-toggle="offcanvas"] {
    display: none !important;
  }
}

@media (max-width: 991.98px) {
  .sidebar-persistent {
    display: none;
  }
}

/* Chat widget */
.ss-chat-launcher{
  position: fixed;
  right: 18px;
  bottom: 88px; /* above mobile bottom nav */
  width: 56px;
  height: 56px;
  border-radius: 18px;
  border: 0;
  background: var(--bs-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 1055; /* above offcanvas backdrop */
}
.ss-chat-launcher i{ font-size: 1.3rem; }
.ss-chat-badge{
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.ss-chat-thread{
  height: 320px;
  overflow: auto;
}
.ss-chat-msg{
  display: flex;
  margin-bottom: 10px;
}
.ss-chat-msg.me{ justify-content: flex-end; }
.ss-chat-bubble{
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
}
.ss-chat-msg.me .ss-chat-bubble{
  background: rgba(59,130,246,0.12);
  border-color: rgba(59,130,246,0.18);
}
.ss-chat-meta{
  font-size: 11px;
  color: rgba(100,116,139,1);
  margin-top: 4px;
}

@media (min-width: 992px){
  .ss-chat-launcher{ bottom: 22px; }
}

.ss-chat-gallery-grid-body{
  max-height: 72vh;
  overflow: auto;
}

.timeline-post .timeline-comments{
  max-height: 220px;
  overflow: auto;
}

.timeline-attachment-image{
  width: 112px;
  display: block;
}
.timeline-attachment-image img{
  width: 112px;
  height: 112px;
  object-fit: cover;
}
.timeline-attachment-audio{
  min-width: 220px;
}

.timeline-comment-attachment-image{
  width: 72px;
  display: block;
}
.timeline-comment-attachment-image img{
  width: 72px;
  height: 72px;
  object-fit: cover;
}
.timeline-comment-attachment-audio{
  min-width: 180px;
}

#timelineLightboxModal .modal-body{
  min-height: 220px;
}
#timelineLightboxImage{
  max-height: 72vh;
  object-fit: contain;
}
