﻿*{box-sizing:border-box;font-family:Inter,Segoe UI,Helvetica,Arial,sans-serif}
:root{
  --bg:#f4f7fb; /* lighter background */
  --card:#ffffff;
  --muted:#64748b;
  --accent:#2563eb;
  --success:#10b981;
  --warning:#f59e0b;
  --danger:#ef4444;
  --glass: rgba(15,23,42,0.03);
}
body{padding:20px;background:var(--bg);color:#0f1724;min-height:100vh}
.card{background:var(--card);padding:14px;border-radius:10px;box-shadow:0 6px 18px rgba(15,23,42,0.06);margin-bottom:14px}
header{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}
header h1{margin:0;font-size:20px}
.header-actions button{background:transparent;border:1px solid rgba(15,23,42,0.06);color:var(--muted);padding:8px 10px;border-radius:8px}
.controls label, .card label{display:block;margin-bottom:10px;color:var(--muted)}
.controls input, .controls select, textarea, input[type=text], input[type=password], input[type=date], input[type=number]{padding:10px;width:100%;max-width:420px;margin-top:6px;border-radius:8px;border:1px solid rgba(15,23,42,0.06);background:var(--glass);color:inherit}
.grid table{width:100%;border-collapse:collapse}
.grid th, .grid td{border-bottom:1px solid rgba(15,23,42,0.04);padding:10px;text-align:right}
.grid tbody tr:hover{background:linear-gradient(90deg, rgba(37,99,235,0.03), transparent);cursor:pointer}
#detailsPane{position:fixed;right:16px;top:80px;width:360px}
.actions{margin-top:12px}
.actions button{margin-left:8px;padding:8px 14px;border-radius:8px;border:0;background:var(--accent);color:#fff}
.note{font-size:12px;color:var(--muted)}
#login{max-width:480px;margin:50px auto}
#app main{display:grid;grid-template-columns:260px 1fr;gap:14px;align-items:start}
.calendar{min-height:120px}
.week-controls{display:flex;gap:8px;align-items:center;margin-bottom:8px}
.week-controls button{padding:6px 8px;border-radius:8px;background:transparent;border:1px solid rgba(15,23,42,0.06);color:var(--muted)}
#ordersTable th{color:var(--muted);font-size:13px}
.status-badge{display:inline-block;padding:4px 8px;border-radius:999px;font-size:12px;color:#fff}
.status-New{background:var(--accent)}
.status-InProgress{background:var(--warning)}
.status-Ready{background:#7c3aed}
.status-Delivered{background:var(--success)}
.status-Cancelled{background:var(--danger)}
.paid-yes{color:var(--success);font-weight:600}
.paid-no{color:var(--muted)}
.delivery-yes{color:#7c3aed;font-weight:600}
.delivery-no{color:var(--muted)}

/* Modal */
.modal{position:fixed;left:0;top:0;right:0;bottom:0;background:rgba(15,23,42,0.3);display:flex;align-items:center;justify-content:center;z-index:10000}
.modal-content{width:min(920px,96%);max-height:90vh;overflow:auto}
.modal-content label{margin-bottom:8px}

/* Calendar boxes */
.calendar-grid{display:flex;gap:8px}
.calendar-day{flex:1;padding:10px;border-radius:8px;background:linear-gradient(180deg, rgba(2,6,23,0.02), transparent);min-height:70px}
.calendar-day .date{font-weight:700;margin-bottom:8px}
.calendar-dot{width:10px;height:10px;border-radius:50%;display:inline-block;margin-left:6px}
.calendar-dot.new{background:var(--danger)}
.calendar-dot.progress{background:var(--warning)}
.calendar-dot.ready{background:#7c3aed}
.calendar-dot.done{background:var(--success)}

/* Loading overlay */
#loadingOverlay{position:fixed;left:0;top:0;right:0;bottom:0;background:rgba(255,255,255,0.6);display:flex;align-items:center;justify-content:center;z-index:9999}
.spinner{width:56px;height:56px;border-radius:50%;border:6px solid rgba(15,23,42,0.06);border-top-color:var(--accent);animation:spin 1s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

.items-block{margin-top:8px}
.items-label{font-weight:700;margin-bottom:6px;color:var(--muted)}
.items-table{width:100%;border-collapse:collapse}
.items-table th, .items-table td{border-bottom:1px solid rgba(15,23,42,0.06);padding:6px}
.items-table input{width:100%;padding:6px;border-radius:6px;border:1px solid rgba(15,23,42,0.06)}
.add-item-btn{padding:6px 10px;border-radius:6px;background:var(--accent);color:#fff;border:0}
.remove-item{background:transparent;border:0;cursor:pointer}

/* Ensure the grid card grows to contain the table content (desktop) */
.grid{
  overflow: visible; /* allow the card to grow to the table */
  min-height: 0;      /* remove any forcing min-height */
  display: block;
}

/* Use full-width table so it fills the card and the card height follows the table */
.grid table{
  width:auto; /* size to content so card grows to fit table */
  table-layout:auto;
}
.grid th, .grid td{
  white-space:normal; /* allow wrapping if needed */
  overflow:visible;
  text-overflow:unset;
}

/* Ensure the grid (orders card) sits in the main column (right side) instead of the left sidebar column */
.grid{
  grid-column: 2 / 3; /* occupy the second column (the main area) */
}

/* Keep the actions area on a single line to prevent the weekly sum from wrapping */
.controls .actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:nowrap; /* avoid line breaks in the actions row */
}
.controls .actions .note{
  white-space:nowrap; /* keep the week sum on one line */
  margin-right:8px;
}

@media (max-width:900px){
  #app main{grid-template-columns:1fr}
  .calendar{order:1}
  .grid{order:2}
  .grid{ overflow-x:auto; }
  .grid table{ width:100%; table-layout:auto; }
  /* On small screens use single column layout; allow grid to flow naturally */
  .grid{ grid-column: auto; }
  /* On small screens allow wrapping so layout doesn't overflow */
  .controls .actions{ flex-wrap:wrap; }
}
