/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons+Outlined');

/* Global Reset */
* {
  box-sizing: border-box;
}

/* Material Design Color System & Variables */
:root {
  /* Colors */
  --md-primary: #1a73e8; /* Google Blue */
  --md-primary-hover: #1765cc;
  --md-success: #0f9d58; /* Google Green */
  --md-warning: #f4b400; /* Google Yellow */
  --md-error: #d93025;   /* Google Red */
  --md-neutral: #5f6368; /* Google Grey */
  
  /* Surfaces */
  --md-bg: #f8f9fa;
  --md-surface: #ffffff;
  
  /* Text */
  --md-text-primary: #202124;
  --md-text-secondary: #5f6368;
  --md-text-hint: #80868b;
  
  /* Elevation (Shadows) */
  --md-elevation-1: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
  --md-elevation-2: 0 1px 2px 0 rgba(60,64,67,0.3), 0 2px 6px 2px rgba(60,64,67,0.15);
  --md-elevation-3: 0 4px 6px 0 rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15);
  --md-elevation-8: 0 8px 10px 1px rgba(0,0,0,0.14),0 3px 14px 2px rgba(0,0,0,0.12),0 5px 5px -3px rgba(0,0,0,0.20);
  
  /* Structure */
  --md-radius: 0;
  --md-radius-lg: 0;
}

body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background-color: var(--md-bg);
  color: var(--md-text-primary);
  margin: 0;
  padding: 24px;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--md-text-primary);
  margin-top: 0;
}

/* Material Header */
.header {
  margin-bottom: 32px;
  padding: 0 8px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.header-titles h1 {
  font-size: 28px;
  margin-bottom: 4px;
}
.header-titles p {
  color: var(--md-text-secondary);
  margin: 0;
  font-size: 15px;
}

/* Material Buttons */
.btn {
  background-color: var(--md-primary);
  color: white;
  border: none;
  padding: 0 24px;
  height: 40px;
  border-radius: 0;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.25px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--md-elevation-1);
}
.btn:hover:not(:disabled) {
  background-color: var(--md-primary-hover);
  box-shadow: var(--md-elevation-2);
}
.btn:disabled {
  background-color: rgba(0,0,0,0.12);
  color: rgba(0,0,0,0.38);
  box-shadow: none;
  cursor: not-allowed;
}
.btn-secondary {
  background-color: transparent;
  color: var(--md-primary);
  border: 1px solid #dadce0;
  padding: 0 24px;
  height: 40px;
  border-radius: 0;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.25px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.2s;
}
.btn-secondary:hover:not(:disabled) {
  background-color: rgba(26,115,232,0.04);
}
.btn-secondary:disabled {
  color: rgba(0,0,0,0.38);
  border-color: rgba(0,0,0,0.12);
  cursor: not-allowed;
}

/* Material Text Fields & Selects */
.form-group {
  margin-bottom: 24px;
  position: relative;
}
.form-group label {
  display: block;
  font-size: 12px;
  color: var(--md-text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
  letter-spacing: 0.2px;
}
.md-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 0;
  border: none;
  border-bottom: 1px solid #e0e0e0;
  border-radius: 0;
  font-family: 'Roboto', sans-serif;
  font-size: 16px;
  color: var(--md-text-primary);
  background-color: transparent;
  transition: border-color 0.2s;
}
.md-input:focus {
  outline: none;
  border-bottom-color: var(--md-primary);
}

/* Auth View */
.auth-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #fafafa;
}
.login-card {
  background: #ffffff;
  padding: 60px 48px;
  border-radius: 0;
  border: 1px solid #eeeeee;
  width: 100%;
  max-width: 440px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.login-card h2 {
  font-size: 28px;
  font-weight: 400;
  margin-bottom: 32px;
  text-align: center;
  color: var(--md-text-primary);
  letter-spacing: -0.5px;
}
#login-error {
  color: var(--md-error);
  font-size: 13px;
  margin-bottom: 16px;
  text-align: center;
  min-height: 18px;
}

/* Dashboard Layout Grid */
.dashboard-controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 24px;
  width: 100%;
}

.controls-card {
  flex: 2.5; 
  min-width: 480px;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  row-gap: 24px;
  align-items: flex-end;
  background: var(--md-surface);
  padding: 24px !important;
  box-shadow: var(--md-elevation-1);
}

.chart-card {
  flex: 1;
  min-width: 320px;
  padding: 24px !important;
  background: var(--md-surface);
  box-shadow: var(--md-elevation-1);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 140px;
  margin-bottom: 0;
}

.control-group label {
  display: block;
  font-size: 12px;
  color: var(--md-text-secondary);
  font-weight: 500;
  margin-bottom: 0;
}

.control-group input, 
.control-group select {
  width: 100%;
  padding: 10px;
  border: 1px solid #e0e0e0;
  border-radius: 0;
  font-family: inherit;
  font-size: 14px;
  background-color: white;
  height: 40px;
}

/* Search input specific with icon */
.search-wrapper {
  position: relative;
  width: 100%;
}
.search-wrapper .material-icons-outlined {
  position: absolute;
  left: 10px;
  top: 10px;
  color: var(--md-text-hint);
  pointer-events: none;
}
.search-wrapper input {
  padding-left: 36px !important;
}

.control-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

/* Filter Bar (Deprecated) */
.filters-container {
  display: none;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}
.kpi-card {
  background: var(--md-surface);
  padding: 24px;
  border-radius: var(--md-radius-lg);
  box-shadow: var(--md-elevation-1);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background-color: var(--md-primary);
}
.kpi-card.success::before { background-color: var(--md-success); }
.kpi-card.warning::before { background-color: var(--md-warning); }
.kpi-card.info::before { background-color: #9c27b0; }

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.kpi-label {
  color: var(--md-text-secondary);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.kpi-icon {
  color: var(--md-text-hint);
  font-size: 20px;
}
.kpi-value {
  font-size: 36px;
  font-weight: 400;
  color: var(--md-text-primary);
  line-height: 1;
}

/* Enhanced Table */
.table-container {
  background: var(--md-surface);
  border-radius: var(--md-radius-lg);
  box-shadow: var(--md-elevation-1);
  overflow: hidden;
}
.table-responsive {
  width: 100%;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
th {
  background-color: var(--md-surface);
  color: var(--md-text-secondary);
  font-weight: 500;
  font-size: 13px;
  padding: 16px 24px;
  border-bottom: 1px solid #e0e0e0;
  white-space: nowrap;
}
td {
  padding: 16px 24px;
  border-bottom: 1px solid #f1f3f4;
  color: var(--md-text-primary);
  font-size: 14px;
}
th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
}
th.sortable:hover {
  background-color: #f8f9fa;
  color: var(--md-text-primary);
}
.sort-icon {
  margin-left: 4px;
  font-size: 16px;
  vertical-align: middle;
  color: var(--md-text-hint);
}
tbody tr {
  cursor: pointer;
  transition: background-color 0.15s;
}
tbody tr:hover {
  background-color: rgba(26,115,232,0.04);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: capitalize;
}
.status-completed { background: #e6f4ea; color: #137333; }
.status-pending { background: #fef7e0; color: #b06000; }
.status-cancelled { background: #fce8e6; color: #c5221f; }
.status-default { background: #f1f3f4; color: #5f6368; }

/* Visual Indicator Tags */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 0;
  font-size: 11px;
  font-weight: 500;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
}
.tag-manual { background: #e8f0fe; color: #1967d2; border: 1px solid #d2e3fc; }
.tag-reprint { background: #fef7e0; color: #b06000; border: 1px solid #feefc3; }
.tag-preplanned { background: #e6f4ea; color: #137333; border: 1px solid #ceead6; }
.tag-oos { background: #fce8e6; color: #c5221f; border: 1px solid #fad2cf; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--md-surface);
  border-top: 1px solid #e0e0e0;
}
.page-info {
  font-size: 13px;
  color: var(--md-text-secondary);
  font-weight: 500;
}

/* Dialog / Modal (Material) */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(32, 33, 36, 0.6);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-overlay.show {
  opacity: 1;
}
.modal-content {
  background: var(--md-surface);
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  border-radius: var(--md-radius-lg);
  box-shadow: var(--md-elevation-8);
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-overlay.show .modal-content {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 {
  margin: 0;
  font-size: 20px;
}
.icon-btn {
  background: none;
  border: none;
  color: var(--md-text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 0;
  display: inline-flex;
  transition: background-color 0.2s;
}
.icon-btn:hover {
  background-color: rgba(0,0,0,0.04);
  color: var(--md-text-primary);
}
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* Modal Internal Tables */
.modal-table-container {
  margin-top: 16px;
  border: 1px solid #e0e0e0;
  border-radius: 0;
  overflow: hidden;
}
.modal-table {
  width: 100%;
  border-collapse: collapse;
}
.modal-table th {
  background-color: #f8f9fa;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--md-text-secondary);
  border-bottom: 1px solid #e0e0e0;
}
.modal-table td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--md-text-primary);
  border-bottom: 1px solid #f1f3f4;
}
.modal-table tr:last-child td {
  border-bottom: none;
}
.modal-table td .muted-text {
  color: var(--md-text-hint);
  font-size: 12px;
  display: block;
  margin-top: 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 32px;
}
.detail-section h3 {
  font-size: 14px;
  color: var(--md-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}
.detail-row {
  display: flex;
  margin-bottom: 12px;
  line-height: 1.5;
}
.detail-label {
  color: var(--md-text-secondary);
  font-size: 13px;
  font-weight: 500;
  width: 140px;
  flex-shrink: 0;
}
.detail-value {
  color: var(--md-text-primary);
  font-size: 14px;
  word-break: break-word;
}
