/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #2563eb;
  --secondary-color: #64748b;
  --success-color: #16a34a;
  --danger-color: #dc2626;
  --warning-color: #f59e0b;
  --info-color: #0891b2;
  --light-bg: #f8fafc;
  --white: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  /* Modern gradient background - Change to your preference 
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);*/

  background-image: url("/static/images/Steel-for-Forging.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}
/* Add this overlay */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.842); /* Black overlay at 50% opacity */
  pointer-events: none; /* Allows clicking through the overlay */
  z-index: -1; /* Keeps it behind content */
}
/* Login Page */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #434343 0%, #000000 100%);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 0;
}

.login-page::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 2px,
    rgba(255, 255, 255, 0.03) 2px,
    rgba(255, 255, 255, 0.03) 4px
  );
  pointer-events: none;
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-box {
  background: var(--white);
  padding: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

.login-box h1 {
  text-align: center;
  color: var(--primary-color);
  margin-bottom: 10px;
  font-size: 28px;
}

.login-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 30px;
}

/* Sidebar Navigation */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 260px;
  height: 100vh;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: var(--white);
  padding: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 25px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--white);
  margin: 0;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.sidebar-item {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  border-left-color: var(--primary-color);
}

.sidebar-item.active {
  background: rgba(37, 99, 235, 0.2);
  color: var(--white);
  border-left-color: var(--primary-color);
}

.sidebar-item .icon {
  font-size: 20px;
  margin-right: 12px;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
  display: flex;
  align-items: center;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  margin-bottom: 10px;
  color: var(--white);
}

.user-info .icon {
  font-size: 18px;
  margin-right: 10px;
}

.user-name {
  font-weight: 500;
  font-size: 14px;
}

.logout-link {
  display: flex;
  align-items: center;
  padding: 12px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s;
}

.logout-link:hover {
  background: rgba(220, 38, 38, 0.2);
  color: #fca5a5;
}

.logout-link .icon {
  font-size: 18px;
  margin-right: 10px;
}

/* Top Bar (Mobile Only) */
.topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--white);
  border-bottom: 1px solid var(--border-color);
  padding: 0 20px;
  align-items: center;
  z-index: 999;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-left: 15px;
}

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: none;
}

.sidebar-toggle span {
  display: block;
  width: 25px;
  height: 3px;
  background: var(--text-primary);
  margin: 5px 0;
  border-radius: 3px;
  transition: all 0.3s;
}

.sidebar-header .sidebar-toggle {
  display: none;
}

.sidebar-header .sidebar-toggle span {
  font-size: 30px;
  color: var(--white);
  line-height: 1;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

/* Main Content Wrapper */
.main-wrapper {
  margin-left: 260px;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

/* Main Content */
.main-content {
  padding: 30px;
  min-height: 100vh;
}

/* Remove padding for login page */
.main-content:has(.login-page) {
  padding: 0;
}

.container {
  background: rgb(255, 255, 255);
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--light-bg);
}

.page-header h1 {
  font-size: 32px;
  color: var(--text-primary);
}

/* Welcome Text */
.welcome-text {
  color: var(--text-secondary);
  margin-bottom: 30px;
  font-size: 16px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--light-bg);
  padding: 5px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 20px;
  border: 1px solid var(--border-color);
}

.stat-card.stat-warning {
  background: #fef3c7;
  border-color: var(--warning-color);
}

.stat-icon {
  font-size: 40px;
}

.stat-content h3 {
  font-size: 36px;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.stat-content p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Dashboard Section */
.dashboard-section {
  margin-top: 30px;
}

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

/* Forms */
.form-container {
  max-width: 800px;
  margin: 0 auto;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

.form-group input.error {
  border-color: var(--danger-color);
}

.form-group small {
  display: block;
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.readonly-field {
  background-color: var(--light-bg);
  cursor: not-allowed;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s;
}

.btn-primary {
  background-color: rgb(0, 173, 0);
  color: var(--white);
}

.btn-primary:hover {
  background-color: #1d4ed8;
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: var(--white);
}

.btn-secondary:hover {
  background-color: #475569;
}

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

.btn-success:hover {
  background-color: #15803d;
}

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

.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-info {
  background-color: var(--info-color);
  color: var(--white);
}

.btn-info:hover {
  background-color: #0e7490;
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-outline:hover {
  background-color: var(--light-bg);
}

.btn-block {
  width: 100%;
  text-align: center;
}

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

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

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 30px;
}

/* Filters */
.filters {
  margin-bottom: 30px;
}

.filter-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-form input,
.filter-form select {
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
}

.filter-form input {
  flex: 1;
  min-width: 250px;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

.table thead {
  background-color: rgb(37 42 68);
}

.table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: white;
  border-bottom: 2px solid var(--border-color);
}

.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
  background-color: var(--light-bg);
}

.table .actions {
  display: flex;
  gap: 8px;
}

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

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background-color: #dcfce7;
  color: #15803d;
}

.badge-danger {
  background-color: #fee2e2;
  color: #b91c1c;
}

.badge-warning {
  background-color: #fef3c7;
  color: #b45309;
}

.badge-info {
  background-color: #e0f2fe;
  color: #0369a1;
}

/* Alerts */
.flash-messages {
  margin-bottom: 20px;
}

.alert {
  padding: 15px 20px;
  border-radius: 6px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.alert-success {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.alert-danger {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.alert-warning {
  background-color: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.alert-info {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #7dd3fc;
}

.alert-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
}

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

/* Product Info */
.product-info {
  background: var(--light-bg);
  padding: 20px;
  border-radius: 8px;
  margin: 20px 0;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.info-item {
  display: flex;
  flex-direction: column;
}

.info-item label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.info-item span {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}

.quantity-display {
  font-size: 20px;
  font-weight: bold;
  color: var(--primary-color);
}

/* Roles Grid */
.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.role-card {
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
}

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

.role-header h3 {
  font-size: 20px;
  color: var(--text-primary);
}

.role-actions {
  display: flex;
  gap: 8px;
}

.role-description {
  color: var(--text-secondary);
  margin-bottom: 15px;
  font-size: 14px;
}

.role-stats {
  margin-bottom: 15px;
}

.stat-badge {
  display: inline-block;
  background: var(--light-bg);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.permissions-list {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

.permissions-list strong {
  display: block;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.permissions-list ul {
  list-style: none;
}

.permissions-list li {
  padding: 4px 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.permissions-list li:before {
  content: "✓ ";
  color: var(--success-color);
  font-weight: bold;
  margin-right: 8px;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  overflow: auto;
}

.modal-content {
  background-color: var(--white);
  margin: 50px auto;
  padding: 30px;
  border-radius: 12px;
  max-width: 500px;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.modal-large {
  max-width: 800px;
}

.close {
  position: absolute;
  right: 20px;
  top: 20px;
  font-size: 28px;
  font-weight: bold;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s;
}

.close:hover {
  color: var(--text-primary);
}

.modal h2 {
  margin-bottom: 20px;
  color: var(--text-primary);
}

/* Permissions Grid in Modal */
.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.permission-section h4 {
  margin-bottom: 10px;
  color: var(--text-primary);
  font-size: 16px;
}

.permission-section label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: normal;
}

/* Responsive Design */
@media (max-width: 768px) {
  /* Show mobile topbar */
  .topbar {
    display: flex;
  }

  /* Show hamburger menu */
  .topbar .sidebar-toggle {
    display: flex;
    flex-direction: column;
  }

  /* Hide sidebar by default on mobile */
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  /* Show close button in sidebar on mobile */
  .sidebar-header .sidebar-toggle {
    display: block;
  }

  /* Show overlay when sidebar is active */
  .sidebar-overlay.active {
    display: block;
  }

  /* Adjust main content for mobile */
  .main-wrapper {
    margin-left: 0;
    margin-top: 60px;
  }

  .main-content {
    padding: 20px;
  }

  .page-header {
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
  }

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

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

  .filter-form input {
    width: 100%;
  }

  .table {
    font-size: 12px;
  }

  .table th,
  .table td {
    padding: 8px;
  }

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

  .modal-content {
    margin: 20px;
    padding: 20px;
  }

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