/* ==========================================================================
   1. Theme Variables
   ========================================================================== */

/* Default / Root Variables (Fallback & Common Styles) */
:root {
  --font-sans: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --transition-speed: 0.3s;
  --transition-ease: ease-in-out;
}

/* Light Mode Variables */
:root,
body.light-mode {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-surface: #f1f3f5;
  
  --text-primary: #212529;
  --text-secondary: #495057;
  --text-muted: #868e96;
  
  --accent: #3b82f6;
  --accent-hover: #1d4ed8;
  --border-color: #dee2e6;
}

/* Dark Mode Variables */
body.dark-mode {
  --bg-primary: #121212;
  --bg-secondary: #1e1e1e;
  --bg-surface: #2d2d2d;
  
  --text-primary: #f8f9fa;
  --text-secondary: #e9ecef;
  --text-muted: #adb5bd;
  
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --border-color: #444444;
}

/* Optional: Respect system preferences by default if no class is present */
@media (prefers-color-scheme: dark) {
  body:not(.light-mode) {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-surface: #2d2d2d;
    
    --text-primary: #f8f9fa;
    --text-secondary: #e9ecef;
    --text-muted: #adb5bd;
    
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --border-color: #444444;
  }
}

/* ==========================================================================
   2. Base Styles & Layouts
   ========================================================================== */

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  /* Smooth transition when toggling themes */
  transition: background-color var(--transition-speed) var(--transition-ease),
              color var(--transition-speed) var(--transition-ease),
              border-color var(--transition-speed) var(--transition-ease);
}

/* ==========================================================================
   3. Sample Components
   ========================================================================== */

/* Container/Cards */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: background-color var(--transition-speed) var(--transition-ease),
              border-color var(--transition-speed) var(--transition-ease);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  margin-bottom: 1rem;
}

p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

small {
  color: var(--text-muted);
}

/* Links & Buttons */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-speed) var(--transition-ease);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.btn {
  display: inline-block;
  background-color: var(--accent);
  color: #ffffff; /* Keeps button text readable in both modes */
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: background-color var(--transition-speed) var(--transition-ease);
}

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

body.dark-mode .btn {
  color: #121212; /* Contextual shift for dark mode button text clarity if needed */
  background-color: var(--accent);
}


/* ==========================================================================
   4. Layout Architecture (TOC Sidebar & Main Content)
   ========================================================================== */

.site-wrapper {
  display: flex;
  min-height: 100vh;
}

/* TOC Sidebar Styles */
.toc-sidebar {
  width: 280px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 2rem 1.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: background-color var(--transition-speed) var(--transition-ease),
              border-color var(--transition-speed) var(--transition-ease);
}

.toc-title {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.toc-links {
  list-style: none;
}

.toc-links li {
  margin-bottom: 0.75rem;
}

.toc-links a {
  display: block;
  padding: 0.5rem;
  border-radius: 4px;
  color: var(--text-secondary);
}

.toc-links a:hover {
  background-color: var(--bg-surface);
  color: var(--accent);
  text-decoration: none;
}

/* Theme Toggle Container at the bottom of TOC */
.theme-toggle-container {
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.toggle-btn {
  width: 100%;
  padding: 0.75rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color var(--transition-speed) var(--transition-ease);
}

.toggle-btn:hover {
  background-color: var(--border-color);
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 3rem;
  background-color: var(--bg-primary);
  transition: background-color var(--transition-speed) var(--transition-ease);
}

/* Mobile responsiveness adjustments */
@media (max-width: 768px) {
  .site-wrapper {
    flex-direction: column;
  }
  .toc-sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  .main-content {
    padding: 1.5rem;
  }
  .dashboard-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Specific login form styling for the TOC sidebar wrapper */
.toc-login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.toc-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.toc-input-group label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.toc-input {
  width: 100%;
  padding: 0.5rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 4px;
  font-size: 0.9rem;
}

.toc-input:focus {
  outline: 1px solid var(--accent);
}

.login-submit-btn {
  width: 100%;
  padding: 0.5rem;
  background-color: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  margin-top: 0.5rem;
  transition: background-color var(--transition-speed) var(--transition-ease);
}

.login-submit-btn:hover {
  background-color: var(--accent-hover);
}

body.dark-mode .login-submit-btn {
  color: #121212;
  background-color: var(--accent);
}

.login-error-msg {
  color: #ef4444;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* User Profile & Logout Elements */
.user-profile-container {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--border-color);
}

.user-status-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.user-status-name {
  font-weight: 600;
  color: var(--text-primary);
}

.logout-form {
  margin-top: 0.5rem;
}

.logout-btn {
  width: 100%;
  padding: 0.4rem;
  background-color: transparent;
  border: 1px solid #ef4444;
  color: #ef4444;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background-color var(--transition-speed) var(--transition-ease), 
              color var(--transition-speed) var(--transition-ease);
}

.logout-btn:hover {
  background-color: #ef4444;
  color: #ffffff;
}

body.dark-mode .logout-btn:hover {
  color: #121212;
}

/* ==========================================================================
   5. Dashboard Sub-Layout Components
   ========================================================================== */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem;
  align-items: start;
}

/* Removed fixed min-height to enable dynamic scaling wrapper behaviors */
.dashboard-section,
.files-section {
  display: flex;
  flex-direction: column;
}

.files-section {
  min-height: 350px;
}

.section-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

.section-header h1,
.section-header h2 {
  margin-bottom: 0;
}

.placeholder-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  border: 2px dashed var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-primary);
}

.placeholder-content p {
  color: var(--text-muted);
  max-width: 280px;
  margin-bottom: 0;
  font-size: 0.95rem;
}

/* Mobile responsive mapping override for summary data cards */
@media (max-width: 768px) {
  .metrics-container {
    grid-template-columns: 1fr !important;
  }
}

/* Add these status badge utility variants underneath section 5 */

.status-badge.status-open {
  background-color: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
  color: #10b981;
}

body.dark-mode .status-badge.status-open {
  background-color: rgba(16, 185, 129, 0.2);
  border-color: #34d399;
  color: #34d399;
}

.status-badge.status-closed {
  background-color: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #ef4444;
}

body.dark-mode .status-badge.status-closed {
  background-color: rgba(239, 68, 68, 0.2);
  border-color: #f87171;
  color: #f87171;
}

.status-badge.status-other {
  background-color: rgba(234, 144, 16, 0.15);
  border-color: #ea9010;
  color: #ea9010;
}

body.dark-mode .status-badge.status-other {
  background-color: rgba(249, 115, 22, 0.2);
  border-color: #fb923c;
  color: #fb923c;
}