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

body {
    margin: 0;
    font-family: Arial, sans-serif;
}

/* THEME: DARK & LIGHT */
body.dark {
    background-color: #121212;
    color: #e0e0e0;
}

body.light {
    background-color: #f5f5f5;
    color: #222222;
}

/* Navbar base layout */
.navbar {
    width: 100%;
    padding: 15px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.navbar .title {
    font-size: 20px;
    font-weight: bold;
}

/* Navbar colors per theme */
body.dark .navbar {
    background-color: #1e1e1e;
    color: #f5f5f5;
}

body.light .navbar {
    background-color: #ffffff;
    color: #222222;
}

/* Nav links */
.nav-right {
    display: flex;
    align-items: center;
}

.nav-right a {
    margin-left: 25px;
    text-decoration: none;
    font-size: 16px;
}

/* Link colors per theme */
body.dark .nav-right a {
    color: #f5f5f5;
}

body.light .nav-right a {
    color: #222222;
}

body.dark .nav-right a:hover {
    color: #ffb74d;
    text-decoration: underline;
}

body.light .nav-right a:hover {
    color: #ff9800;
    text-decoration: underline;
}

/* Theme toggle button */
.theme-toggle {
    margin-left: 25px;
    padding: 6px 12px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
}

/* Button colors per theme */
body.dark .theme-toggle {
    background-color: #2c2c2c;
    color: #f5f5f5;
    border-color: #555;
}

body.light .theme-toggle {
    background-color: #f0f0f0;
    color: #222;
    border-color: #ccc;
}

.theme-toggle:hover {
    opacity: 0.9;
}

/* Content area */
.content {
    padding: 20px 40px;
}

/* Headings / text */
body.dark h1,
body.dark h2,
body.dark h3,
body.dark h4,
body.dark h5 {
    color: #ffffff;
}

body.light h1,
body.light h2,
body.light h3,
body.light h4,
body.light h5 {
    color: #111111;
}

body.dark p,
body.dark li,
body.dark span {
    color: #e0e0e0;
}

body.light p,
body.light li,
body.light span {
    color: #333333;
}

.tabs-container {
    margin-top: 8px;
}

/* Tab headers */
.tabs-nav {
    display: flex;
    border-bottom: 1px solid #444;
    margin-bottom: 12px;
}

body.light .tabs-nav {
    border-bottom-color: #ccc;
}

.tab-link {
    padding: 8px 16px;
    border: none;
    cursor: pointer;
    background: none;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    margin-right: 4px;
}

body.dark .tab-link {
    color: #ddd;
}

body.light .tab-link {
    color: #333;
}

.tab-link.active {
    border-bottom-color: #ffb74d;
    font-weight: bold;
}

/* Panels */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Optional card styling if you use cards later */
.card {
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

body.dark .card {
    background-color: #1e1e1e;
}

body.light .card {
    background-color: #ffffff;
}

/* ------------------------------
   Rota optimizer popup + tooltips
   ------------------------------ */

.opt-modal-hidden { display: none !important; }

.opt-backdrop{
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0,0,0,0.55);
}

body.light .opt-backdrop{
    background: rgba(0,0,0,0.35);
}

.opt-modal{
    width: min(860px, 100%);
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(20,20,20,0.92);
    box-shadow: 0 18px 60px rgba(0,0,0,0.55);
    overflow: hidden;
}

body.light .opt-modal{
    background: rgba(255,255,255,0.96);
    border-color: rgba(0,0,0,0.12);
}

.opt-modal__header{
    padding: 14px 18px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.03);
}

body.light .opt-modal__header{
    border-bottom-color: rgba(0,0,0,0.12);
    background: rgba(0,0,0,0.02);
}

.opt-modal__title{
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.opt-modal__subtitle{
    margin: 6px 0 0;
    font-size: 12px;
    opacity: 0.75;
    line-height: 1.35;
}

.opt-close{
    border: 1px solid rgba(255,255,255,0.22);
    background: rgba(255,255,255,0.06);
    color: inherit;
    border-radius: 10px;
    width: 36px;
    height: 36px;
    cursor: pointer;
}

body.light .opt-close{
    border-color: rgba(0,0,0,0.18);
    background: rgba(0,0,0,0.04);
}

.opt-modal__body{
    padding: 14px 18px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 820px){
    .opt-modal__body{ grid-template-columns: 1fr; }
}

.opt-card{
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
    padding: 12px;
}

body.light .opt-card{
    border-color: rgba(0,0,0,0.12);
    background: rgba(0,0,0,0.02);
}

.opt-card h3{
    margin: 0 0 10px;
    font-size: 13px;
}

.opt-field{ display: grid; gap: 6px; margin-bottom: 10px; }

.opt-label-row{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.opt-label-row label{
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.opt-input-row{ display: flex; gap: 8px; align-items: center; }

/* checkbox row inside optimizer modal */
.opt-check-row input[type="checkbox"]{
    width: 18px;
    height: 18px;
    accent-color: #7aa2ff;
    cursor: pointer;
}
.opt-check-row{ align-items: center; }

.opt-input-row input[type="number"]{
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.20);
    background: rgba(0,0,0,0.20);
    color: inherit;
    font-size: 14px;
}

body.light .opt-input-row input[type="number"]{
    border-color: rgba(0,0,0,0.18);
    background: rgba(255,255,255,0.80);
}

.opt-unit{
    font-size: 12px;
    opacity: 0.75;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(255,255,255,0.06);
    white-space: nowrap;
}

body.light .opt-unit{
    border-color: rgba(0,0,0,0.14);
    background: rgba(0,0,0,0.03);
}

.opt-footer{
    padding: 12px 18px 16px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.02);
}

body.light .opt-footer{
    border-top-color: rgba(0,0,0,0.12);
    background: rgba(0,0,0,0.02);
}

.opt-btn{
    font-size: 13px;
    font-weight: 700;
    padding: 9px 12px;
    border-radius: 12px;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.22);
    background: rgba(255,255,255,0.06);
    color: inherit;
}

body.light .opt-btn{
    border-color: rgba(0,0,0,0.18);
    background: rgba(0,0,0,0.04);
}

.opt-btn.primary{
    border-color: rgba(255,183,77,0.55);
    background: rgba(255,183,77,0.18);
}

.opt-btn:disabled{ opacity: 0.55; cursor: default; }

/* Tooltip (pure CSS, hover or keyboard focus) */
.opt-tooltip{ position: relative; display: inline-flex; align-items: center; }

.opt-tip-btn{
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.22);
    background: rgba(255,255,255,0.06);
    color: inherit;
    font-size: 12px;
    line-height: 1;
    cursor: help;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

body.light .opt-tip-btn{
    border-color: rgba(0,0,0,0.18);
    background: rgba(0,0,0,0.04);
}

.opt-tip{
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    min-width: 260px;
    max-width: 360px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(10,10,10,0.96);
    box-shadow: 0 14px 44px rgba(0,0,0,0.55);
    font-size: 12px;
    line-height: 1.35;
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
    z-index: 50;
}

body.light .opt-tip{
    border-color: rgba(0,0,0,0.14);
    background: rgba(255,255,255,0.98);
    box-shadow: 0 14px 44px rgba(0,0,0,0.25);
}

.opt-tip:after{
    content: "";
    position: absolute;
    top: 100%;
    right: 12px;
    border: 8px solid transparent;
    border-top-color: rgba(10,10,10,0.96);
}

body.light .opt-tip:after{ border-top-color: rgba(255,255,255,0.98); }

.opt-tooltip:hover .opt-tip,
.opt-tooltip:focus-within .opt-tip{
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.theme-toggle {
    margin-left: 25px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: none;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.danger-btn {
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid #aa4444;
    background: transparent;
    color: #ff7777;
    cursor: pointer;
}

.danger-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

body.dark .theme-toggle {
    color: #f5f5f5;
    border-color: #555;
}

body.dark .theme-toggle:hover {
    background-color: #2c2c2c;
}

body.light .theme-toggle {
    color: #222;
    border-color: #ccc;
}

body.light .theme-toggle:hover {
    background-color: #e8e8e8;
}

.form-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

.form-row label {
    margin-bottom: 4px;
    font-size: 14px;
}

.form-row input {
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #555;
    font-size: 14px;
}

body.light .form-row input {
    border-color: #aaa;
}

button[type="submit"] {
    margin-top: 8px;
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 14px;
}

button[type="submit"]:disabled {
    opacity: 0.5;
    cursor: default;
}

body.dark button[type="submit"] {
    background-color: #4caf50;
    color: white;
}

body.light button[type="submit"] {
    background-color: #388e3c;
    color: white;
}

.shift-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 14px;
}

.shift-table th,
.shift-table td {
    padding: 8px;
    border-bottom: 1px solid #444;
    text-align: left;
}

body.light .shift-table th,
body.light .shift-table td {
    border-bottom-color: #ddd;
}

.actions-cell {
    white-space: nowrap;
}

.table-btn,
button.table-btn,
button.table-btn[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    font-size: 12px;
    line-height: 1;
    border-radius: 4px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    margin-right: 4px;
}

body.dark .table-btn {
    background-color: #4c6fff;
    color: #fff;
}

body.light .table-btn {
    background-color: #3f51b5;
    color: #fff;
}

body.dark .table-btn.danger,
body.light .table-btn.danger {
    background-color: #e53935;
    color: #fff;
}

.secondary-btn {
    margin-left: 8px;
    font-size: 14px;
    text-decoration: none;
}

body.dark .secondary-btn {
    color: #ddd;
}

body.light .secondary-btn {
    color: #444;
}

/* Shift picker popup – theme aware */
.shift-picker-menu {
    position: absolute;
    z-index: 1000;
    min-width: 220px;
    max-width: 280px;
    padding: 6px;
    border-radius: 8px;
    font-size: 0.8rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

body.dark .shift-picker-menu {
    background-color: #1e1e1e;
    color: #f5f5f5;
    border: 1px solid #555;
}

body.light .shift-picker-menu {
    background-color: #ffffff;
    color: #222222;
    border: 1px solid #ccc;
}

.shift-picker-item {
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

body.dark .shift-picker-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

body.light .shift-picker-item:hover {
    background: rgba(0, 0, 0, 0.06);
}

.shift-picker-empty {
    padding: 4px 6px;
    opacity: 0.7;
}

.shift-picker-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 4px;
    padding-top: 4px;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

body.light .shift-picker-footer {
    border-top-color: rgba(0, 0, 0, 0.08);
}

.shift-picker-footer button {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid #555;
    background: transparent;
    cursor: pointer;
}

body.dark .shift-picker-footer button {
    color: #f5f5f5;
    border-color: #777;
}

body.light .shift-picker-footer button {
    color: #222;
    border-color: #aaa;
}

/* Par Level Dropdown (single optimized copy) */
.par-dropdown {
    position: absolute;
    z-index: 1000;
    min-width: 220px;
    max-width: 260px;
    padding: 6px;
    border-radius: 8px;
    font-size: 0.8rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    border: 1px solid;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.par-opt-role { display: flex; gap: 6px; }

body.dark .par-dropdown,
.par-dropdown[data-theme="dark"] {
    background-color: #1e1e1e;
    color: #f5f5f5;
    border-color: #555;
}

body.light .par-dropdown,
.par-dropdown[data-theme="light"] {
    background-color: #ffffff;
    color: #222;
    border-color: #ccc;
}

.par-dropdown label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
}

body.dark .par-dropdown label:hover,
.par-dropdown[data-theme="dark"] label:hover {
    background: rgba(255, 255, 255, 0.08);
}

body.light .par-dropdown label:hover,
.par-dropdown[data-theme="light"] label:hover {
    background: rgba(0, 0, 0, 0.06);
}

.par-dropdown input[type="checkbox"] {
    cursor: pointer;
}

.par-btn.has-values {
    background-color: rgba(255, 184, 77, 0.15);
    border-color: #ffb74d;
    color: inherit;
}

/* Rota specific */
.rota-name-select,
.rota-group-select {
    width: 100%;
    font-size: 0.8rem;
    padding: 2px 4px;
    border-radius: 4px;
    box-sizing: border-box;
}

body.dark .rota-name-select,
body.dark .rota-group-select {
    background-color: #111;
    color: #f5f5f5;
    border: 1px solid #555;
}

body.light .rota-name-select,
body.light .rota-group-select {
    background-color: #ffffff;
    color: #222;
    border: 1px solid #bbb;
}

.rota-name-select:focus,
.rota-group-select:focus {
    outline: none;
}

body.dark .rota-name-select:focus,
body.dark .rota-group-select:focus {
    border-color: #888;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}

body.light .rota-name-select:focus,
body.light .rota-group-select:focus {
    border-color: #666;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.rota-week-par {
    display: grid;
    grid-template-columns: 180px repeat(7, minmax(90px, 1fr)) 80px;
    gap: 2px;
    margin-bottom: 4px;
}

.rota-par-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rota-week-par .rota-par-select {
    width: 100%;
    font-size: 0.8rem;
    padding: 2px 4px;
    box-sizing: border-box;
    border-radius: 4px;
    border: 1px solid #444;
    background: transparent;
    color: inherit;
}

body.light .rota-week-par .rota-par-select {
    border-color: #ccc;
}

.rota-par-display {
    font-size: 0.75rem;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rota-group-title-input,
.rota-name-cell,
.rota-name-text,
.rota-slot,
.rota-total-cell {
    font-weight: bold !important;
}
.nav-user {
  position: relative;
  display: inline-block;
}

.nav-username {
  cursor: pointer;
  padding: 8px 12px;
}

.nav-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: #222;
  border: 1px solid #444;
  border-radius: 8px;
  min-width: 160px;
  z-index: 1000;
}

.nav-dropdown a {
  display: block;
  padding: 10px 12px;
  text-decoration: none;
  color: #fff;
}

.nav-dropdown a:hover {
  background: #333;
}

.nav-user:hover .nav-dropdown {
  display: block;
}
/* --- User dropdown theme-aware --- */

body.dark .nav-dropdown {
  background-color: #1e1e1e;
  border-color: #555;
}

body.dark .nav-dropdown a {
  color: #f5f5f5;
}

body.dark .nav-dropdown a:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.light .nav-dropdown {
  background-color: #ffffff;
  border-color: #ccc;
}

body.light .nav-dropdown a {
  color: #222222;
}

body.light .nav-dropdown a:hover {
  background: rgba(0, 0, 0, 0.06);
}
/* Username should ALWAYS look hovered (override nav-right link color) */
body.dark .nav-right .nav-user .nav-username {
    color: #ffb74d;
    text-decoration: underline;
    font-weight: bold;
}

body.light .nav-right .nav-user .nav-username {
    color: #ff9800;
    text-decoration: underline;
    font-weight: bold;
}
