/* Global Variables */
:root {
  --bg-light: rgb(50, 207, 255);
  --bg-dark: #121212;
  --text-light: #333;
  --text-dark: #f5f5f5;
  --primary: #3498db;
  --primary-dark: #2980b9;
  --accent: #ffc107;
  --danger: #e74c3c;
  --warning: #f44336;
  --border: #1b7a7a;
  --load-button: #00bd6e;
}

/* Body Styling */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--text-light);
  background-color: var(--bg-light);
  margin: 0;
  padding: 20px;
  transition: background-color 0.3s, color 0.3s;
}

/* Dark Mode Body Styling */
body.dark-mode {
  background-color: var(--bg-dark);
  color: var(--text-dark);
}

/* Container Styling */
.container {
  max-width: 1600px;
  margin: auto;
  background-color: rgb(191, 240, 255);
  padding: 24px;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(70, 255, 230, 0.1);
  transition: background-color 0.3s;
}

/* Dark Mode Container */
body.dark-mode .container {
  background-color: #1e1e1e;
}

/* Headers with images */
header {
  display: flex;
  align-items: center;
  border-bottom: 2px solid #1b7a7a;
  margin-bottom: 30px;
  padding-bottom: 10px;
}
header img {
  height: 56px;
  width: 56px;
  margin-right: 15px;
  image-rendering: auto;
}
header h1 {
  font-size: 2.8rem;
  margin: 0;
}

/* Button Container */
.button-header {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Form Inputs & Textareas Styling */
input, select, textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  transition: background-color 0.3s, color 0.3s;
}

/* Dark Mode Form Inputs & Textareas */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background-color: #1f1f1f;
  color: #f5f5f5;
  border: 1px solid #444;
}

/* Focused Inputs & Textareas */
body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
}

/* Placeholder Text Styling */
body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: #aaa;
}

/* Result Section Styling */
body.dark-mode .result-section {
  background-color: #1e2a38;
  border-left: 4px solid var(--primary);
}

body.dark-mode .result-label {
  color: #f5f5f5;
}

body.dark-mode .result-value {
  color: #cccccc;
}

body.dark-mode .result-grid {
  color: #e0e0e0;
}

/* Note & Warning Styling */
body.dark-mode .note {
  background-color: #2a2a1f;
  border-left-color: var(--accent);
  color: #eee;
}

body.dark-mode .warning-message {
  background-color: #3a1f1f;
  border-left-color: var(--warning);
  color: #f8d7da;
}

/* Headings Styling */
h1, h2, h3, h4 {
  color: inherit;
  margin-top: 2em;
  color: #1b7a7a
}

/* Buttons Styling */
.toggle-theme, .profile-btn, .admin-btn, .logout-btn {
  background-color: var(--primary);
  color: rgb(191, 240, 255);;
  border: none;
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
}

/* Button Hover State */
.toggle-theme:hover, .profile-btn:hover, .admin-btn:hover, .logout-btn:hover {
  background-color: var(--primary-dark);
}

/* Form Section & Group Styling */
.form-section {
  margin-bottom: 32px;
}

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

label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
}

.form-text.text-muted {
  color: #2980b9 !important; 
}

/* Validation Styling */
input.input-error {
  border-color: var(--danger);
}

.validation-error {
  color: var(--danger);
  font-size: 0.875rem;
}

/* General Button Styling */
.button {
  background-color: var(--primary);
  color: rgb(191, 240, 255);
  border: none;
  padding: 6px 10px;
  font-size: 0.875rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-block;
  transition: background-color 0.3s;
  text-decoration: none;
}

.button:hover {
  background-color: rgb(191, 240, 255);
  text-decoration: none;
}

/* Specific Button Styles */
.load-button {
  background-color: var(--load-button);
}
.dark-mode .load-button {
  color: var(--load-button);
}

.update-btn {
  background-color: var(--primary);
}

.load-btn {
  background-color: var(--primary);
}
.load-btn:hover {
  background-color: var(--primary-dark);
}

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

.delete-btn:hover {
  background-color: #c0392b;
}

/* Result Section Styling */
.result-section {
  margin-top: 40px;
  padding: 16px;
  border-left: 5px solid var(--primary);
  background-color: rgba(52, 152, 219, 0.5);
  border-radius: 6px;
}

/* Result Grid Styling */
.result-grid {
  display: none;
}

.result-label {
  font-weight: 600;
}

/* Note & Warning Messages */
.note, .warning-message {
  margin: 16px 0;
  padding: 16px;
  border-radius: 4px;
  font-size: 0.95rem;
  line-height: 1.6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: background-color 0.3s ease;
}

.note {
  background-color: #fff8e1;
  border-left: 4px solid var(--accent);
}

.warning-message {
  background-color: #ffebee;
  border-left: 4px solid var(--warning);
}

/* Sidebar Styling */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 260px;
  background-color: rgb(191, 240, 255);;
  border-right: 1px solid #ddd;
  padding: 20px;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.3s ease;
  z-index: 1000;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.sidebar.collapsed {
  transform: translateX(-100%);
}

/* Sidebar Header */
.sidebar h2 {
  font-size: 1.4rem;
  margin-bottom: 20px;
  color: #333;
  padding-top: 20px;
}

/* Enable Sidebar Scrolling */
#sidebar-configurations {
  flex-grow: 1;
  overflow-y: auto;
  padding-right: 5px;
  max-height: calc(100vh - 60px);
}

/* Sidebar Configuration Buttons */
.config-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgb(50, 207, 255);;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 15px;
}

/* Site Name */
.config-name {
  font-size: 14px;
  font-weight: bold;
  color: #333;
  flex-grow: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Button Container (holds Load and Delete buttons) */
.button-container {
  display: flex;
  gap: 10px; /* Space between buttons */
}

/* Dark Mode Styles */
.dark-mode .config-wrapper {
  background-color: #333;
}

.dark-mode .config-name {
  color: #2980b9;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
  position: fixed;
  top: 10px;
  left: 10px;
  background-color: rgb(50, 207, 255);
  color: black;
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  z-index: 1100;
  transition: background-color 0.2s;
}

.sidebar-toggle:hover {
  background-color: #0056b3;
}

/* Main Content Spacing */
.main-content {
  margin-left: 280px;
  padding: 20px;
}

/* Dark Mode Styles */
.dark-mode .sidebar {
  background-color: #121212;
  border-right: 1px solid #333;
  color: #2980b9;
}

.dark-mode .sidebar button {
  background-color: #2a2a2a;
  color: #eee;
}

.dark-mode .sidebar button:hover {
  background-color: #3c3c3c;
}

.dark-mode .sidebar .delete-button {
  background-color: #b71c1c;
}
.sidebar .delete-button {
  background-color: #b71c1c;
}

.dark-mode .sidebar .delete-button:hover {
  background-color: #c62828;
}

/* Responsive Table Styling */
.table-container {
  overflow-x: auto;
  max-width: 100%;
}

#usersTable {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin-bottom: 1rem; /* Add space below the table */
}

#usersTable th, #usersTable td {
  padding: 10px; /* Increase padding for better readability */
  text-align: left; /* Align text to the left for easier reading */
  border: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Table Column Sizing */
#usersTable th:last-child, 
#usersTable td:last-child {
  min-width: 120px;
  white-space: nowrap;
}

#usersTable td {
  position: relative;
}

/* Add visual cues for sorting (optional) */
#usersTable th.sortable {
  cursor: pointer;
  position: relative;
}

#usersTable th.sortable::after {
  content: ' ▼';
  font-size: 0.75rem;
  position: absolute;
  right: 8px;
}

#usersTable th.sortable.sorted-asc::after {
  content: ' ▲';
}

#usersTable th.sortable.sorted-desc::after {
  content: ' ▼';
}

/* Tooltip on Hover */
#usersTable td:hover::after {
  content: attr(data-fulltext);
  position: absolute;
  background: #333;
  color: #fff;
  padding: 8px;
  font-size: 12px;
  white-space: nowrap;
  border-radius: 5px;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  min-width: 150px;
  max-width: 300px;
  word-wrap: break-word;
  box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
  opacity: 0; /* Make initially invisible */
  visibility: hidden; /* Make initially hidden */
  transition: opacity 0.3s ease, visibility 0.3s ease; /* Add transition for smooth appearance */
}

#usersTable td:hover::after {
  opacity: 1; /* Show tooltip */
  visibility: visible; /* Make tooltip visible */
}

/* Table Cells Styling */
#usersTable td {
  position: relative; /* Ensures positioning for tooltip */
}

#usersTable td:hover {
  cursor: pointer; /* Optional: Make sure the cursor indicates interactivity */
}

/* Profile Image Styling */
.profile-pic {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 50%;
}

.input-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

/* Input Field Styling */
.input-field {
  width: 95%;
  padding: 6px;
  font-size: 0.9rem;
  box-sizing: border-box;
  text-align: center;
}

/* Ensure the styles.css file is linked */
link[rel="stylesheet"][href="styles.css"] {
  display: block;
}

/* ===================== */
/* 📱 Mobile Enhancements */
/* ===================== */

@media (max-width: 768px) {
  /* Prevent horizontal scroll */
  body {
    overflow-x: hidden;
  }

  /* Collapse sidebar */
  .sidebar {
    position: fixed;
    top: 0;
    left: -100%; /* Initially hidden off-screen */
    width: 80%; /* Sidebar takes up 80% of the screen */
    background-color: var(--sidebar-bg, #fff);
    height: 100vh;
    padding: 10px 20px;
    z-index: 1000;
    transition: transform 0.3s ease-in-out;
    transform: translateX(-100%); /* Initially hidden */
  }

  .sidebar.collapsed {
    transform: translateX(0); /* Slide in when open */
    left: 0; /* Ensure it's positioned correctly */
  }

  .sidebar-toggle {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1100;
    background-color: var(--primary);
    color: white;
    border-radius: 6px;
    width: 36px; /* Reduced width */
    height: 36px; /* Reduced height */
    font-size: 1.2rem; /* Icon size */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0; /* Removed padding */
    box-sizing: border-box;
    cursor: pointer;
    transition: background-color 0.2s ease;
  }

  .main-content {
    margin-left: 0;
    margin-top: 20px;
    padding: 16px;
    transition: margin-left 0.3s ease-in-out; /* Smooth transition when sidebar opens */
  }

  /* When sidebar is open, shift the main content */
  .sidebar.collapsed + .main-content {
    padding-left: 16px; /* Allow content to stay in place */
  }

  /* Sidebar Image */
  .sidebar img {
    width: 80px; /* Adjust the width to a smaller size */
    height: auto; /* Ensure the height adjusts proportionally */
    max-width: 100%; /* Prevent image from exceeding the container */
    object-fit: contain; /* Maintain image aspect ratio and prevent distortion */
    margin-left: auto; /* Add space below the image */
    margin-right: auto;

  }

  /* Adjust container */
  .container {
    padding: 16px;
    box-shadow: none;
    border-radius: 0;
  }

  header {
    display: flex;
    align-items: center;
    border-bottom: 2px solid #1b7a7a;
    margin-bottom: 10px;
    padding-bottom: 10px;
  }

  header h1 {
    font-size: 1.6rem;
  }

  header img {
    height: 40px;
    width: 40px;
  }

  /* Form controls */
  input, select, textarea {
    font-size: 0.9rem;
    padding: 8px 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Buttons */
  .button,
  .toggle-theme,
  .profile-btn,
  .admin-btn,
  .logout-btn {
    font-size: 0.75rem;
    padding: 3px 8px; /* Tighten vertical and horizontal space */
    line-height: 1;    /* Tight line height */
    border-radius: 3px;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
    margin-bottom: 4px;
    display: inline-block;
    white-space: nowrap; /* Prevent line wraps */
}

  /* Result Section */
  .result-section {
    margin-top: 24px;
    padding: 12px;
    border-left-width: 3px;
    font-size: 0.9rem;
    word-wrap: break-word;
  }

  /* Result grid */
  .result-grid {
    display: none;
  }

  ul, ol {
    padding-left: 20px;
    margin: 12px 0;
  }
  
  li {
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 3px;
    word-wrap: break-word;
  }

  .note, .warning-message {
    padding: 5px;
    font-size: 0.9rem;
    word-break: break-word;
    line-height: 1.4;
  }

  /* Responsive table and layout */
  #usersTable {
    border: 0;
  }

  #usersTable thead {
    display: none;
  }

  #usersTable,
  #usersTable tbody,
  #usersTable tr,
  #usersTable td {
    display: block;
    width: 95%;
  }

  #usersTable tr {
    margin-bottom: 16px;
    border-radius: 8px;
    padding: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  }

  #usersTable td {
    display: flex;
    flex-direction: row;
    align-items: left;
    justify-content: flex-start; /* Center content */
    text-align: left;
    font-size: 0.9rem;
    position: relative;
    word-break: break-word;
    width: 100%;
    box-sizing: border-box;
  }
  
  #usersTable td::before {
    content: attr(data-label);
    position: absolute;
    font-weight: bold;
    color: #444;
    white-space: nowrap;
    text-align: left;
    width: 40%; /* Align label width with padding */
  }

  .config-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgb(50, 207, 255);;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
  }
  
  /* Site Name */
  .config-name {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Button Container */
  .button-header {
    flex-direction: column;
    align-items: center; /* full width buttons */
    justify-content: flex-start;
  }
  
  /* Button Container (holds Load and Delete buttons) */
  .button-container {
    display: flex;
    gap: 10px; /* Space between buttons */
  }
}