/* ============================================
   Tellme Admin Panel — Main Layout Styles
   ============================================ */

:root {
  --bg-primary: #1a1a2e;
  --bg-sidebar: #16213e;
  --bg-accent: #0f3460;
  --text-primary: #e0e0e0;
  --highlight: #e94560;

  --bg-card: #1f1f3a;
  --bg-input: #252545;
  --bg-hover: #2a2a4a;
  --bg-modal: rgba(0, 0, 0, 0.7);

  --border-color: #2e2e52;
  --border-radius: 8px;

  --color-success: #2ecc71;
  --color-danger: #e74c3c;
  --color-warning: #f1c40f;
  --color-info: #3498db;

  --sidebar-width: 60px;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: 0.2s ease;
}

/* --- Reset & Base --- */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow: hidden;
}

a {
  color: var(--highlight);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Scrollbar --- */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-accent);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--highlight);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-accent) var(--bg-primary);
}

/* --- Login Overlay --- */

.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(6px);
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 40px 32px;
  width: 360px;
  max-width: 90vw;
  text-align: center;
}

.login-box h2 {
  margin-bottom: 24px;
  font-size: 20px;
  color: var(--text-primary);
}

.login-box input {
  width: 100%;
  margin-bottom: 16px;
}

.login-box .btn-primary {
  width: 100%;
}

.login-error {
  color: var(--color-danger);
  font-size: 13px;
  margin-top: 8px;
}

/* --- Sidebar --- */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  z-index: 100;
  border-right: 1px solid var(--border-color);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  margin-bottom: 20px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  background: var(--highlight);
  color: #fff;
  flex-shrink: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  width: 100%;
}

.sidebar-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  opacity: 0.5;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all var(--transition);
  position: relative;
}

.sidebar-btn:hover {
  opacity: 0.8;
  background: var(--bg-hover);
}

.sidebar-btn.active {
  opacity: 1;
  background: var(--bg-accent);
  color: var(--highlight);
}

.sidebar-btn .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--highlight);
  border-radius: 50%;
  border: 2px solid var(--bg-sidebar);
}

.sidebar-btn .badge-count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  background: var(--highlight);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-sidebar);
}

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* --- Main Content --- */

.main-content {
  margin-left: var(--sidebar-width);
  height: 100vh;
  overflow-y: auto;
  padding: 24px;
}

/* --- Sections --- */

.section {
  display: none;
  height: 100%;
}

.section.active {
  display: block;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-header h1 {
  font-size: 22px;
  font-weight: 600;
}

/* --- Cards / Panels --- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--highlight);
}

.stat-card .stat-label {
  font-size: 12px;
  opacity: 0.6;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Tables --- */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: var(--bg-accent);
}

th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  opacity: 0.8;
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-top: 1px solid var(--border-color);
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: var(--bg-hover);
}

/* --- Buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--bg-accent);
  color: var(--text-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--highlight);
  color: #fff;
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #c0392b;
}

.btn-success {
  background: var(--color-success);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  background: #27ae60;
}

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  opacity: 0.6;
}

.btn-ghost:hover:not(:disabled) {
  opacity: 1;
  background: var(--bg-hover);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 6px;
}

/* --- Form Inputs --- */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="date"],
textarea,
select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--highlight);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-primary);
  opacity: 0.3;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 4px;
  opacity: 0.7;
}

.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > * {
  flex: 1;
}

/* --- Modal Overlay --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 24px;
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-primary);
  opacity: 0.5;
  font-size: 20px;
  cursor: pointer;
}

.modal-close:hover {
  opacity: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* --- Status Indicators --- */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--color-success);
  box-shadow: 0 0 6px rgba(46, 204, 113, 0.5);
}

.status-dot.idle {
  background: var(--color-warning);
  box-shadow: 0 0 6px rgba(241, 196, 15, 0.4);
}

.status-dot.offline {
  background: #666;
}

.status-dot.dnd {
  background: var(--color-danger);
}

/* --- Badges --- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.badge-info {
  background: rgba(52, 152, 219, 0.2);
  color: var(--color-info);
}

.badge-success {
  background: rgba(46, 204, 113, 0.2);
  color: var(--color-success);
}

.badge-danger {
  background: rgba(231, 76, 60, 0.2);
  color: var(--color-danger);
}

.badge-warning {
  background: rgba(241, 196, 15, 0.2);
  color: var(--color-warning);
}

/* --- Utilities --- */

.text-muted {
  opacity: 0.5;
}

.text-center {
  text-align: center;
}

.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.flex-1 {
  flex: 1;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

/* --- Toasts / Notifications --- */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 13px;
  min-width: 280px;
  max-width: 400px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.3s ease;
}

.toast.toast-error {
  border-left: 3px solid var(--color-danger);
}

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

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* --- Loading / Spinner --- */

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-top-color: var(--highlight);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  opacity: 0.5;
}

/* --- Responsive --- */

@media (max-width: 768px) {
  :root {
    --sidebar-width: 50px;
  }

  .main-content {
    padding: 16px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
  }

  .modal {
    width: 95vw;
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .sidebar {
    bottom: auto;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 54px;
    flex-direction: row;
    justify-content: space-around;
    padding: 0 8px;
    border-right: none;
    border-top: 1px solid var(--border-color);
  }

  .sidebar-logo {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    gap: 0;
  }

  .sidebar-bottom {
    flex-direction: row;
    margin-top: 0;
  }

  .main-content {
    margin-left: 0;
    margin-bottom: 54px;
    height: calc(100vh - 54px);
  }
}
