/* CSS Styles for OLED Production App */
:root {
  --bg-color: #0f172a;
  --panel-bg: #1e293b;
  --panel-border: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  --primary-color: #6366f1;
  --accent-color: #06b6d4;
  --success-color: #10b981;
  --error-color: #ef4444;
  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --border-radius-lg: 16px;
  --border-radius-md: 10px;
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: 40px;
}

/* Header */
header {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  padding: 8px 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background-color: rgba(30, 41, 59, 0.85);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

.app-title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  background: var(--primary-gradient);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: white;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

header h1 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

header .subtitle {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.btn-install {
  background: var(--primary-gradient);
  border: none;
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
  transition: var(--transition-smooth);
}

.btn-install:active {
  transform: scale(0.95);
}

/* Layout Container */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.section {
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-lg);
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 10px;
}

.section-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Badges */
.badge {
  background-color: #334155;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.required-label::after {
  content: " *";
  color: var(--error-color);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.form-control {
  background-color: #0f172a;
  border: 1.5px solid var(--panel-border);
  border-radius: var(--border-radius-md);
  color: var(--text-primary);
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  transition: var(--transition-smooth);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  padding-right: 40px;
}

/* Date Pickers specific styling */
input[type="date"].form-control {
  padding: 10px 12px;
}

/* Order Grid / Cards */
.order-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-card {
  background-color: #0f172a;
  border: 1.5px solid var(--panel-border);
  border-radius: var(--border-radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.order-card:active {
  transform: scale(0.98);
}

.order-card.selected {
  border-color: var(--primary-color);
  background-color: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.2);
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.order-line {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent-color);
  background: rgba(6, 182, 212, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
}

.order-shift {
  font-size: 11px;
  color: var(--text-secondary);
}

.order-model {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.order-details {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  border-top: 1px dashed var(--panel-border);
  padding-top: 8px;
}

.order-po {
  font-family: monospace;
}

.order-plan span {
  font-weight: 600;
  color: var(--text-primary);
}

/* Buttons */
.btn {
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
  transform: scale(0.98);
}

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

.btn-block {
  width: 100%;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

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

/* Selected Order Detail Panel */
.selected-order-summary {
  background-color: #0f172a;
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-md);
  padding: 14px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.summary-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-row span {
  font-size: 11px;
  color: var(--text-secondary);
}

.summary-row strong {
  font-size: 13px;
  color: var(--text-primary);
}

/* Loader Spinner */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  gap: 12px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 4px stroke var(--panel-border);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading p {
  font-size: 13px;
  color: var(--text-secondary);
}

.no-data {
  text-align: center;
  padding: 40px 0;
  color: var(--text-secondary);
  font-size: 13px;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: #1e293b;
  border: 1.5px solid var(--panel-border);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
  z-index: 1000;
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: var(--success-color);
  background-color: rgba(16, 185, 129, 0.1);
}

.toast.error {
  border-color: var(--error-color);
  background-color: rgba(239, 68, 68, 0.1);
}

/* Defects Grid Custom Styles */
.defects-section {
  margin-top: 10px;
  margin-bottom: 20px;
  background-color: rgba(15, 23, 42, 0.4);
  padding: 14px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--panel-border);
}

.defects-section .section-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.defects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.defect-item {
  background-color: #1e293b;
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-md);
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  box-shadow: var(--shadow-md);
}

.defect-item label {
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  color: var(--text-secondary);
  line-height: 1.2;
}

.defect-item input.defect-input {
  width: 100%;
  text-align: center;
  padding: 6px;
  font-size: 13px;
  background-color: #0f172a;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text-primary);
}

.defect-item input.defect-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.15);
}

/* Tablet screen adjustment */
@media (min-width: 480px) {
  .defects-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Recent Dates Buttons styling */
.date-buttons-container {
  display: flex;
  gap: 6px;
  margin-top: 0;
}

.date-btn {
  flex: 1;
  background-color: #0f172a;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text-secondary);
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.date-btn:active {
  transform: scale(0.95);
}

.date-btn.active {
  background: var(--primary-gradient);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.date-btn .date-day {
  font-size: 11px;
  font-weight: 700;
}

.date-btn .date-label {
  font-size: 8px;
  opacity: 0.7;
  font-weight: 500;
}

/* Tab Buttons */
.tab-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 0 4px 0;
  background: rgba(30, 41, 59, 0.6);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.15);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.tab-btn {
  flex: 0 0 calc(25% - 4px);
  box-sizing: border-box;
  padding: 6px 2px;
  border-radius: 8px;
  border: none;
  font-weight: 800;
  font-size: 10px;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  line-height: 1.2;
}

.tab-btn.active {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  transform: translateY(-1px);
}

/* Horizontal Bar Chart Styles */
.chart-line-row {
  margin-bottom: 20px;
}

.chart-line-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.chart-bars-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(30, 41, 59, 0.5);
  padding: 8px;
  border-radius: var(--border-radius-md);
  border: 1px solid rgba(51, 65, 85, 0.2);
}

.chart-bar-container {
  display: flex;
  align-items: center;
  width: 100%;
}

.chart-bar {
  height: 18px;
  border-radius: 4px;
  min-width: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.chart-bar.plan {
  background: linear-gradient(90deg, #06b6d4, #0891b2);
}

.chart-bar.actual {
  background: linear-gradient(90deg, #ec4899, #be123c);
}

.chart-bar-value {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
}

/* White background theme for Shift Report Sheet */
.report-sheet-wrapper {
  background: #ffffff !important;
  color: #0f172a !important;
  padding: 16px 14px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  margin-top: 10px;
}

/* Banner header */
.report-sheet-wrapper .title-banner {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
}
.report-sheet-wrapper .title-banner strong,
.report-sheet-wrapper .title-banner span {
  color: #0f172a !important;
}
.report-sheet-wrapper .title-banner label {
  color: #0284c7 !important;
}

/* Group sections header */
.report-sheet-wrapper span[style*="text-transform: uppercase"] {
  color: #1e293b !important;
  font-weight: 800 !important;
}

/* Tables styling override */
.report-sheet-wrapper table {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 6px;
}
.report-sheet-wrapper thead tr {
  background: #f1f5f9 !important;
  color: #334155 !important;
  border-bottom: 2px solid #cbd5e1 !important;
}
.report-sheet-wrapper th {
  color: #334155 !important;
  border: 1px solid #e2e8f0 !important;
  font-weight: bold !important;
}
.report-sheet-wrapper tbody tr {
  background: #ffffff !important;
  border-bottom: 1px solid #e2e8f0 !important;
}
.report-sheet-wrapper td {
  color: #1e293b !important;
  border: 1px solid #e2e8f0 !important;
}
.report-sheet-wrapper td[style*="color: white"],
.report-sheet-wrapper td[style*="color:white"] {
  color: #0f172a !important;
}
.report-sheet-wrapper td[style*="color: var(--text-primary)"],
.report-sheet-wrapper td[style*="color:var(--text-primary)"] {
  color: #334155 !important;
}
.report-sheet-wrapper td[style*="color: var(--text-secondary)"],
.report-sheet-wrapper td[style*="color:var(--text-secondary)"] {
  color: #475569 !important;
}
.report-sheet-wrapper tr[style*="color: white"],
.report-sheet-wrapper tr[style*="color:white"] {
  background: #f8fafc !important;
  color: #0f172a !important;
  border-top: 2px solid #cbd5e1 !important;
}
.report-sheet-wrapper tr[style*="color: white"] td,
.report-sheet-wrapper tr[style*="color:white"] td {
  color: #0f172a !important;
}

/* Bottom summary text card */
.report-sheet-wrapper .summary-card {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #334155 !important;
}
.report-sheet-wrapper .summary-card span,
.report-sheet-wrapper .summary-card div,
.report-sheet-wrapper .summary-card strong {
  color: #334155 !important;
}
.report-sheet-wrapper .summary-card div[style*="color: white"],
.report-sheet-wrapper .summary-card div[style*="color:white"] {
  color: #0f172a !important;
}
.report-sheet-wrapper .summary-card div[style*="color: var(--text-secondary)"],
.report-sheet-wrapper .summary-card div[style*="color:var(--text-secondary)"] {
  color: #475569 !important;
}

/* Compact Manpower Form Textbox Spacing */
#manpowerForm .form-group {
  margin-bottom: 2px;
  gap: 3px;
}
#manpowerForm .form-row {
  gap: 8px;
}
#manpowerForm .form-control {
  padding: 8px 12px;
  font-size: 13px;
}
#manpowerForm label {
  font-size: 11.5px;
  margin-bottom: 1px;
}

/* Line Layout Tab styles */
.line-layout-stats {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-md);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.line-layout-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 80px;
}
.line-layout-stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: center;
}
.line-layout-stat-value {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 800;
  margin-top: 2px;
}
.line-layout-stat-value.total {
  color: #06b6d4;
}

.line-card-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.line-card {
  background: rgba(30, 41, 59, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.line-card-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-primary);
  border-left: 3px solid var(--primary-color);
  padding-left: 6px;
  margin-bottom: 0;
}
.line-machines-wrapper {
  overflow-x: auto;
  padding-bottom: 6px;
}
.line-machines-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 100%;
  padding: 4px 0;
}
.machine-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
  position: relative;
}
.machine-img-box {
  width: 70px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.4);
  border-radius: var(--border-radius-md);
  border: 1px solid rgba(51, 65, 85, 0.5);
  margin: 6px 0;
  padding: 2px;
}
.machine-img-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.machine-name-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-secondary);
}
.operator-tag {
  font-size: 9px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 20px;
  max-width: 95px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.operator-tag.day {
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
}
.operator-tag.night {
  background-color: #fff7ed;
  border: 1px solid #fed7aa;
  color: #7c2d12;
}
.operator-tag.empty {
  background-color: transparent;
  border: 1px dashed rgba(148, 163, 184, 0.3);
  color: rgba(148, 163, 184, 0.4);
}

/* Drag and Drop Diagram styling */
.draggable-active {
  cursor: move;
  outline: 1.5px dashed var(--accent-color) !important;
  background-color: rgba(6, 182, 212, 0.1) !important;
  z-index: 10;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}
.line-machines-canvas {
  position: relative;
  height: 145px;
  min-width: 100%;
  background: rgba(15, 23, 42, 0.3);
  border-radius: var(--border-radius-md);
  border: 1px dashed rgba(51, 65, 85, 0.4);
  margin-top: 2px;
  overflow: hidden;
}
.machine-column {
  position: absolute; /* absolutely positioned */
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 95px;
  user-select: none;
  touch-action: auto;
}
.operator-tag-absolute {
  position: absolute;
  user-select: none;
  touch-action: auto;
  z-index: 5;
}
.line-machines-canvas.editing .machine-column,
.line-machines-canvas.editing .operator-tag-absolute {
  touch-action: none;
}


