/* Global Styles */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

:root {
  --primary-color: #1976d2; /* Blue 700 */
  --secondary-color: #0d47a1; /* Blue 900 */
  --accent-color: #42a5f5; /* Blue 400 */
  --background-color: #f0f2f5; /* Very light gray/blueish */
  --card-bg: #ffffff;
  --text-primary: #1e293b; /* Slate 800 */
  --text-secondary: #64748b; /* Slate 500 */
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", sans-serif;
  background-color: var(--background-color);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100vh;
}

/* Auth Pages (Login/Signup) */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-image: url("../imagens/back_romaneio.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.auth-card {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.auth-card h2 {
  margin-bottom: 1.5rem;
  color: var(--primary-color);
  font-weight: 700;
}

.form-group {
  margin-bottom: 1rem;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.btn-primary {
  /* width: 100%; - Removed full width to allow side-by-side */
  min-width: 120px;
  padding: 0.75rem 1.5rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background-color: var(--secondary-color);
}

.btn-cancel {
  min-width: 120px;
  padding: 0.75rem 1.5rem;
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel:hover {
  background-color: #f1f5f9;
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.form-actions {
  /* grid-column: 1 / -1; Removed to allow inline flow */
  display: flex;
  gap: 1rem;
  /* margin-top: 1rem; Changed to match form-group spacing if needed, or remove to align with input baseline */
  margin-bottom: 1rem; /* Match form-group */
  justify-content: flex-start;
}

.auth-switch {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.auth-switch a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

/* Dashboard & Layout */
/* Layout & Sidebar Fixed */
.app-container {
  display: flex;
  height: 100vh; /* Force full viewport height */
  overflow: hidden; /* Prevent body scroll */
}

.sidebar {
  width: 250px;
  background-color: var(--secondary-color);
  color: white;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  transition: width 0.3s ease;
  overflow-x: hidden; /* Hide overflow during transition */
}

.sidebar.collapsed {
  width: 80px;
  padding: 1.5rem 0.5rem; /* Reduce padding */
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  min-height: 40px; /* Prevent jump */
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
}

.sidebar h1 {
  font-size: 1.5rem;
  margin-bottom: 0;
  font-weight: 700;
  white-space: nowrap;
  transition: opacity 0.2s;
  opacity: 1;
}

.sidebar.collapsed h1 {
  display: none;
  opacity: 0;
}

.sidebar-toggle-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.sidebar-toggle-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.nav-links {
  list-style: none;
  flex: 1;
}

.nav-links li {
  margin-bottom: 0.5rem;
}

.nav-links a {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap; /* Prevent text wrapping */
  overflow: hidden;
}

.nav-links a i {
  min-width: 24px;
  text-align: center;
  margin-right: 12px;
  font-size: 1.1rem;
}

.sidebar.collapsed .nav-links a {
  justify-content: center;
  padding: 0.75rem;
}

.sidebar.collapsed .nav-links a i {
  margin-right: 0;
}

.sidebar.collapsed .nav-links a span {
  display: none;
}

.nav-links a:hover,
.nav-links a.active {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

/* Tooltip for collapsed state (Optional but good) */
.sidebar.collapsed .nav-links a:hover {
  position: relative;
}

/*
.sidebar.collapsed .nav-links a:hover::after {
  content: attr(title);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: #333;
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 100;
  margin-left: 10px;
  font-size: 0.8rem;
  pointer-events: none;
}
*/

.logout-btn {
  margin-top: auto;
  padding: 0.75rem 1rem;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
}

.logout-btn i {
  margin-right: 8px;
}

.sidebar.collapsed .logout-btn i {
  margin-right: 0;
}

.sidebar.collapsed .logout-btn span {
  display: none;
}

.main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto; /* Internal scroll for content */
  height: 100%; /* Full height container */
  position: relative;
}

/* User Header Display */
.header-with-user {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.user-header-display {
  display: flex;
  align-items: center;
  margin-bottom: 0 !important; /* Override potential margins */
}

.user-info-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  padding: 8px 16px;
  border-radius: 50px;
  box-shadow: var(--shadow-sm);
}

.user-details {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.user-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.user-profile {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.user-avatar {
  width: 40px;
  height: 40px;
  background-color: var(--primary-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1rem;
  box-shadow: 0 2px 4px rgba(25, 118, 210, 0.2);
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.stat-card h3 {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
}

/* Tables & Lists */
.table-container {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.weights-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.weights-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 2 columns: Weight | Date */
  column-gap: 2rem;
  row-gap: 1rem;
}

.weight-row {
  display: contents; /* Allows children to participate in grid */
}

/* Utility */
.hidden {
  display: none;
}

/* Toast Notifications */
.success-message {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 9999;
  animation: slideIn 0.3s ease-out;
  font-weight: 500;
  color: white;
}

.toast-success {
  background: #27ae60;
}

.toast-edit {
  background: #2980b9;
}

.toast-error {
  background: #c0392b;
}

.toast-warning {
  background: #f39c12; /* Orange/Yellow */
  color: white;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  max-width: 400px;
  width: 90%;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-container {
  transform: translateY(0);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.modal-body {
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.toast-title {
  font-weight: bold;
  display: block;
  margin-bottom: 0.25rem;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

/* Pagination */
.pagination-btn {
  padding: 0.5rem 1rem;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#page-size {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.2s;
}

#page-size:hover {
  border-color: var(--primary-color);
}

#page-size:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* WhatsApp Float Button */
.whatsapp-float {
  position: fixed;
  width: 60px;
  height: 60px;
  bottom: 30px;
  right: 30px;
  background-color: #25d366;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-decoration: none;
}

.whatsapp-float:hover {
  background-color: #128c7e;
  transform: scale(1.1);
  box-shadow: 2px 6px 16px rgba(0, 0, 0, 0.25);
}

.whatsapp-float img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

/* Footer Bottom */
.footer-bottom {
  position: fixed;
  bottom: 10px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.8rem;
  color: white;
  z-index: 100;
  padding: 10px;
  pointer-events: none; /* Permite clicar no que estiver atrás, exceto no link */
}

.footer-bottom a {
  color: white;
  text-decoration: none;
  font-weight: 600;
  pointer-events: auto; /* Reativa cliques para o link */
}

.footer-bottom a:hover {
  text-decoration: underline;
}
