/*
 * Basic styling for the STRAXX‑LMS application.  Colour schemes are
 * defined using CSS variables with a dark mode override on the body
 * element.  The layout uses a fixed sidebar on the left and a
 * responsive content area on the right.  The sidebar can be
 * collapsed to a narrow bar using a body class.  The header and
 * footer share the same background as the sidebar for visual
 * consistency.
 */

/* Light theme variables */
:root {
  --color-bg: #f5f5f5;
  --color-text: #212529;
  --color-primary: #007bff;
  --color-sidebar-bg: #343a40;
  --color-sidebar-text: #ffffff;
  --color-card-bg: #ffffff;
  --color-border: #dee2e6;
}

/* Dark theme overrides */
body.dark {
  --color-bg: #212529;
  --color-text: #e9ecef;
  --color-primary: #66b2ff;
  --color-sidebar-bg: #1f1f1f;
  --color-sidebar-text: #f8f9fa;
  --color-card-bg: #2b2b2b;
  --color-border: #343a40;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.5;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
}
.navbar-left {
  display: flex;
  align-items: center;
}
.sidebar-toggle {
  background: none;
  border: none;
  color: var(--color-sidebar-text);
  font-size: 1.5rem;
  margin-right: 1rem;
  cursor: pointer;
}
.app-title {
  font-weight: bold;
  font-size: 1.25rem;
}
.navbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.lang-select {
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  border: 1px solid var(--color-border);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}
.theme-toggle {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--color-sidebar-text);
  cursor: pointer;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 200px;
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  overflow-y: auto;
  padding-top: 3.5rem; /* leave space for navbar */
  transition: width 0.2s ease;
}
body.sidebar-collapsed .sidebar {
  width: 60px;
}
.menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.menu-item a {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--color-sidebar-text);
  text-decoration: none;
  white-space: nowrap;
}
.menu-item a:hover,
.menu-item.active a {
  background: rgba(255, 255, 255, 0.1);
}

/* Content */
.content {
  margin-left: 200px;
  padding: 1rem;
  min-height: calc(100vh - 3.5rem - 2rem); /* account for navbar and footer */
  transition: margin-left 0.2s ease;
}
body.sidebar-collapsed .content {
  margin-left: 60px;
}
.content h1 {
  margin-top: 0;
}

/* Cards */
.card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.login-card {
  max-width: 400px;
  margin: 2rem auto;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
}
.form-control {
  width: 100%;
  padding: 0.5rem;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-card-bg);
  color: var(--color-text);
}
.form-actions {
  margin-top: 1rem;
  text-align: right;
}
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border-radius: 4px;
  border: 1px solid var(--color-primary);
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover {
  opacity: 0.9;
}

/* Footer */
.footer {
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  padding: 0.5rem 1rem;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 0.875rem;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Utility */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}
.alert-danger {
  background-color: #f8d7da;
  color: #842029;
  border-color: #f5c2c7;
}

.alert-success {
  background-color: #d1e7dd;
  color: #0f5132;
  border-color: #badbcc;
}

/* Muted text */
.text-muted {
  color: #6c757d;
  font-size: 0.9rem;
}

/* Tables */
.user-table {
  width: 100%;
  border-collapse: collapse;
}
.user-table th,
.user-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}
.user-table th {
  text-align: left;
  font-weight: bold;
}

/* ---- Users UI polish ---- */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .7rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table-compact th, .table-compact td { padding: .45rem .6rem; }
.no-wrap { white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }

.input, .select, .btn {
  font: inherit;
  padding: .5rem .6rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: .6rem;
  outline: none;
}
.input:focus, .select:focus { border-color: var(--color-primary); box-shadow: 0 0 0 .15rem rgba(128, 90, 213, .25); }

.btn { cursor: pointer; transition: .15s ease; }
.btn:hover { filter: brightness(1.05); }
.btn-primary { background: var(--color-primary); color: #fff; border-color: transparent; }
.btn-subtle  { background: transparent; border-color: var(--color-border); }
.btn-danger  { background: #c0392b; color: #fff; border-color: transparent; }

.section-title { margin: 1rem 0 .5rem; font-size: 1.05rem; font-weight: 700; }
.card-header { display:flex; align-items:flex-start; justify-content:space-between; gap:1rem; margin-bottom:.5rem; }
.muted { color: #6b7280; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }
.badge { background: var(--color-muted); color: var(--color-text); padding: .15rem .45rem; border-radius: .4rem; }

.form-grid {
  display: grid;
  grid-template-columns: 160px minmax(200px, 1fr);
  gap: .6rem .8rem;
  align-items: center;
}
.form-grid .span-2 { grid-column: 1 / span 2; }
.form-actions { display:flex; gap:.6rem; justify-content:flex-end; }

/* iOS/Android friendly switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background: #9ca3af; transition: .2s; border-radius: 999px;
}
.slider:before {
  position: absolute; content: ""; height: 18px; width: 18px; left: 2px; top: 2px;
  background: #fff; transition: .2s; border-radius: 50%;
}
.switch input:checked + .slider { background: var(--color-primary); }
.switch input:checked + .slider:before { transform: translateX(18px); }


/* === Login form refinements === */
.login-card { max-width: 460px; margin: 6rem auto; padding: 1.25rem 1.5rem; border-radius: 12px; }
.login-form .auth-row { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.login-form label { font-size: .95rem; color: var(--color-muted, #aab); }
.login-form .form-control { height: 44px; padding: 0 .9rem; font-size: 1rem; border-radius: 10px; }
.login-form .center-actions { display: flex; justify-content: center; margin-top: .5rem; }
.btn.btn-lg { min-width: 160px; height: 46px; border-radius: 12px; }

/* Status badges for Kaizen */
.badge{display:inline-block;padding:.25rem .5rem;border-radius:.5rem;font-size:.825rem;line-height:1}
.badge.status-open{background:#f0ad4e;color:#fff}
.badge.status-in_progress{background:#17a2b8;color:#fff}
.badge.status-done{background:#28a745;color:#fff}
.badge.status-rejected{background:#dc3545;color:#fff}

/* === Sidebar bottom group anchored === */
.sidebar {
  display: flex;
  flex-direction: column;
}
.sidebar .menu {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.sidebar .menu-group {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar .menu-group.menu-top {
  flex: 1 1 auto;
}
.sidebar .menu-group.menu-bottom {
  margin-top: auto;              /* push to bottom */
  border-top: 1px solid var(--sidebar-divider, rgba(128,128,128,0.35));
  padding-top: 0.75rem;
}
.sidebar .menu-item {
  margin: 0;
}
.sidebar .menu-item a {
  display: block;
  padding: 0.5rem 1rem;
}

/* === Fixed footer safe area === */
:root {
  --footer-height: 56px; /* adjust if footer height changes */
}
.content {
  padding-bottom: var(--footer-height);
}
.sidebar {
  padding-bottom: var(--footer-height);
}

/* === Sidebar layout: resources hugging divider === */
.sidebar{display:flex;flex-direction:column}
.sidebar .menu{display:flex;flex-direction:column;height:100%;flex:1 1 auto;min-height:0}
.sidebar .menu-group{list-style:none;margin:0;padding:0}
.sidebar .menu-group.menu-top{display:flex;flex-direction:column;flex:1 1 auto;min-height:0}
.sidebar .menu-group.menu-top .menu-spacer{flex:1 1 auto;height:0}
/* bottom group divider and spacing */
.sidebar .menu-group.menu-bottom{
  border-top:1px solid var(--sidebar-divider, rgba(128,128,128,0.35));
  margin-top:0;
  padding-top:.75rem;
}

/* Sidebar divider spacing tweak (tight) */
.sidebar .menu-group.menu-bottom{ padding-top: 0 !important; }
.sidebar .menu-group.menu-bottom .menu-item:first-child a{ padding-top: 8px !important; }
