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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  min-height: 100vh;
  color: #e0e0e0;
}

.container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 20px;
}

.container.fullscreen-mode {
  max-width: 100%;
  padding: 10px;
}

header {
  text-align: center;
  padding: 30px 0;
}

header h1 {
  font-size: 2.5rem;
  color: #00d4ff;
  margin-bottom: 10px;
}

.subtitle {
  color: #888;
  font-size: 1.1rem;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  padding: 15px 20px;
  border-radius: 10px;
  margin-bottom: 25px;
  flex-wrap: wrap;
  gap: 10px;
}

.status {
  font-weight: 600;
  padding: 5px 15px;
  border-radius: 20px;
}

.status.connected { background: rgba(0, 255, 136, 0.2); color: #00ff88; }
.status.disconnected { background: rgba(255, 68, 68, 0.2); color: #ff4444; }

#last-updated { color: #888; }

.auto-refresh-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #888;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.interval-input {
  width: 50px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  text-align: center;
}

#next-refresh {
  color: #00d4ff;
  font-size: 0.85rem;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}

.btn-group {
  display: flex;
  gap: 10px;
}

.btn-primary {
  background: linear-gradient(135deg, #00d4ff, #0099cc);
  color: #fff;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(0, 212, 255, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #ccc;
}

.btn-secondary:hover {
  background: rgba(255, 68, 68, 0.3);
  color: #ff6666;
}

main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 20px;
}

.card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
  padding: 25px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.card h2 {
  color: #00d4ff;
  margin-bottom: 20px;
  font-size: 1.3rem;
}

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

.card-header h2 {
  margin-bottom: 0;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.1);
  color: #ccc;
}

.btn-small:hover {
  background: rgba(0, 212, 255, 0.2);
  color: #00d4ff;
}

/* Fullscreen mode */
#machining-section.fullscreen,
#assembly-section.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  margin: 0;
  border-radius: 0;
  overflow: hidden;
  background: #1a1a2e;
  backdrop-filter: none;
}

#machining-section.fullscreen .data-container,
#assembly-section.fullscreen .data-container {
  height: calc(100vh - 60px);
  overflow: hidden;
}

.data-container { min-height: 150px; }

.loading { color: #666; font-style: italic; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

th {
  color: #00d4ff;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
}

tr:hover { background: rgba(255, 255, 255, 0.05); }

.summary-card { grid-column: 1 / -1; }
.full-width { grid-column: 1 / -1; }

.days-urgent { color: #ff4444; font-weight: bold; }
.days-warning { color: #ffaa00; font-weight: bold; }
.days-ok { color: #00ff88; }

.idle-row { opacity: 0.5; }
.idle-row td { color: #cc6666; }
.idle-cell { font-style: italic; text-align: center; }

.current-job-header {
  background: rgba(0, 255, 136, 0.1);
  border-left: 2px solid rgba(0, 255, 136, 0.3);
  border-top: 2px solid rgba(0, 255, 136, 0.3);
  border-bottom: 2px solid rgba(0, 255, 136, 0.3);
}
.current-job-cell {
  border-left: 2px solid rgba(0, 255, 136, 0.2);
  border-top: 1px solid rgba(0, 255, 136, 0.15);
  border-bottom: 1px solid rgba(0, 255, 136, 0.15);
}

.next-job-header {
  background: rgba(0, 212, 255, 0.1);
  border-left: 2px solid rgba(0, 212, 255, 0.3);
  border-top: 2px solid rgba(0, 212, 255, 0.3);
  border-bottom: 2px solid rgba(0, 212, 255, 0.3);
}
.next-job-cell {
  color: #88aacc;
  border-left: 2px solid rgba(0, 212, 255, 0.2);
  border-top: 1px solid rgba(0, 212, 255, 0.15);
  border-bottom: 1px solid rgba(0, 212, 255, 0.15);
  font-size: 0.9em;
}

.no-next-job {
  font-style: italic;
  text-align: center;
  color: #6688aa;
}

/* Dashboard View Styles */

/* Toggle button in header - fixed size, not scaled */
.view-toggle-btn {
  background: linear-gradient(135deg, #00d4ff, #00ff88);
  color: #1a1a2e;
  font-weight: 600;
  padding: 8px 16px;
  font-size: 0.85rem;
  margin-left: 10px;
}

.view-toggle-btn:hover {
  transform: scale(1.05);
}

/* Dashboard layout container */
.dashboard-wrapper {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  overflow: hidden;
}

.dashboard-cards {
  --card-width: 24vw;
  --card-height: auto;
  --font-scale: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  flex: 1;
  overflow: hidden;
  align-content: center; /* Center rows vertically */
  justify-content: center; /* Center each row's cards */
}

.dashboard-card {
  width: var(--card-width);
  height: var(--card-height);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

.dashboard-card-header {
  background: linear-gradient(135deg, #3a3a5e, #2a2a4e);
  padding: calc(var(--font-scale) * 0.5vmin) calc(var(--font-scale) * 0.8vmin);
  font-size: calc(var(--font-scale) * 1.4vmin);
  font-weight: 700;
  color: #00d4ff;
  border-bottom: 2px solid rgba(0, 212, 255, 0.3);
}

.dashboard-card-body {
  display: flex;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.dashboard-section {
  flex: 1;
  padding: calc(var(--font-scale) * 0.8vmin);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dashboard-section.current-section {
  background: rgba(0, 255, 136, 0.05);
  border-right: 2px solid rgba(0, 255, 136, 0.3);
}

.dashboard-section.next-section {
  background: rgba(0, 212, 255, 0.05);
}

.dashboard-section-title {
  font-size: calc(var(--font-scale) * 1vmin);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: calc(var(--font-scale) * 0.2vh);
  padding-bottom: calc(var(--font-scale) * 0.2vh);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.current-section .dashboard-section-title {
  color: #00ff88;
}

.next-section .dashboard-section-title {
  color: #00d4ff;
}

.dashboard-field {
  display: flex;
  flex-direction: column;
  padding: calc(var(--font-scale) * 0.1vh) 0;
  flex-shrink: 0;
}

.field-label {
  color: #888;
  font-size: calc(var(--font-scale) * 0.7vmin);
  margin-bottom: 0;
}

.field-value {
  color: #fff;
  word-break: break-word;
  font-size: calc(var(--font-scale) * 1.1vmin);
}

.field-value.desc {
  font-size: calc(var(--font-scale) * 0.95vmin);
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.field-value.completion {
  color: #00ff88;
  font-weight: 600;
}

.no-next-job-card {
  color: #6688aa;
  font-style: italic;
  text-align: center;
  padding: calc(var(--font-scale) * 0.5vh) 0;
  font-size: calc(var(--font-scale) * 0.9vmin);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

/* Idle Resources Footer in Dashboard View - fixed 15% of screen */
.dashboard-idle-footer {
  background: #1a1a2e;
  border-top: 2px solid rgba(255, 255, 255, 0.2);
  height: 15vh;
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

.idle-footer-title {
  color: #888;
  font-size: 0.8rem;
  text-transform: uppercase;
  font-weight: 600;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.idle-tables-wrapper {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  gap: 0;
  padding: 5px 10px;
}

.idle-table-divider {
  width: 2px;
  background: linear-gradient(to bottom, transparent, rgba(0, 212, 255, 0.5), transparent);
  margin: 5px 15px;
  flex-shrink: 0;
}

.idle-table-container {
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

.idle-table {
  width: 100%;
  font-size: 0.7rem;
  table-layout: fixed;
}

.idle-table th {
  font-size: 0.65rem;
  padding: 3px 5px;
  color: #00d4ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.idle-table td {
  padding: 2px 5px;
  opacity: 0.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-grid {
  display: flex;
  gap: 40px;
  justify-content: center;
}

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

.summary-value {
  display: block;
  font-size: 2.5rem;
  font-weight: 700;
  color: #00ff88;
}

.summary-label {
  color: #888;
  font-size: 0.9rem;
  text-transform: uppercase;
}

footer {
  text-align: center;
  padding: 30px;
  color: #666;
}

.error { color: #ff4444; }

@media (max-width: 768px) {
  header h1 { font-size: 1.8rem; }
  main { grid-template-columns: 1fr; }
  .status-bar { flex-direction: column; text-align: center; }
}

