/* Clean base setup */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f6f9;
    color: #333;
    margin: 0;
    padding: 0 20px 20px 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

/* Sticky top header */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: #f4f6f9; /* Solid background matching body so cards scroll cleanly behind */
    display: flex;
    flex-direction: column;
    align-items: stretch;
    border-bottom: 2px solid #ddd;
    padding-top: 20px;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 12px;
}

.filter-controls label {
    margin: 0;
}

.filter-options,
.sort-direction,
.mode-toggle {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-options[hidden] {
    display: none;
}

.mode-toggle,
.sort-direction {
    border: 0;
    padding: 0;
    margin: 0;
}

.mode-toggle {
    gap: 0;
    border: 1px solid #6c757d;
    border-radius: 4px;
    overflow: hidden;
}

.mode-toggle label {
    position: relative;
    cursor: pointer;
}

.mode-toggle input {
    position: absolute;
    opacity: 0;
}

.mode-toggle span {
    display: block;
    padding: 9px 12px;
    color: #333;
    background: white;
}

.mode-toggle input:checked + span {
    color: white;
    background: #495e73;
}

.mode-toggle input:focus-visible + span {
    outline: 3px solid #0056b3;
    outline-offset: -3px;
}

.active-settings {
    flex-basis: 100%;
    color: #555;
    font-size: 0.9rem;
}

.active-settings:empty {
    display: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.filter-controls select,
.filter-controls button {
    min-height: 36px;
}

.filter-controls button:disabled {
    opacity: 0.55;
    cursor: default;
}

/* Dashboard Grid Layout */
.watchlist-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

/* Full viewing history: scroll horizontally on narrow screens. */
.history-summary {
    color: #555;
    font-weight: 600;
}

.history-table-wrapper {
    overflow-x: auto;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.history-table th,
.history-table td {
    padding: 12px;
    border-bottom: 1px solid #e8e8e8;
    vertical-align: top;
}

.history-table th {
    background: #eef2f6;
    white-space: nowrap;
}

.history-table tbody tr:last-child td {
    border-bottom: 0;
}

#deleteSeriesDialog {
    max-width: min(480px, 85vw);
    border: 0;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

#deleteSeriesDialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

#deleteSeriesDialog h2 {
    margin-top: 0;
}

.dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.dialog-actions button {
    min-height: 36px;
}

/* Clutter-free Row Cards */
.show-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.show-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Layout within the row card */
.show-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Clear, high-contrast Series Title */
.show-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #111;
    margin: 0;
}

/* New: Gives the Last Watched Date identical size and bold emphasis */
.show-date-emphasized {
    font-size: 1.3rem;
    font-weight: 700;
    color: #0056b3; /* Rich blue text so your eyes scan it instantly */
}

/* Secondary tracking labels (Larger and clear for tablet viewing) */
.show-meta-secondary {
    font-size: 1.1rem; /* Bumps the size up significantly */
    color: #444;       /* Slightly darker contrast */
    margin-top: 6px;   /* Extra breathing room between lines */
    font-weight: 500;  /* Medium crisp weight */
}



/* Inline data entry drawer (Initially Hidden) */
.input-drawer {
    display: none; /* Hidden by default until card is clicked */
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #ddd;
    background-color: #fafafa;
    border-radius: 4px;
}

.input-drawer.active {
    display: block; /* Revealed on click */
}

/* Form layout inside the drawer */
/* Inline form layout for a single horizontal row */
.form-group {
    display: inline-block;
    vertical-align: bottom; /* Aligns inputs perfectly along their bottom edge */
    margin-right: 20px;     /* Comfortable horizontal breathing room between controls */
    margin-bottom: 10px;
}

label {
    display: block;
    font-size: 0.95rem;
    color: #555;
    margin-bottom: 6px;
    font-weight: 600;
}

/* Base style for select and number inputs */
select, input[type="number"] {
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    box-sizing: border-box;
}

/* WebKit specific tuning to enlarge native number arrows for touch screens */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;          /* Keeps spinner arrows permanently visible */
    height: 30px;        /* Stretches the vertical tap area */
    width: 24px;         /* Widens the arrows so they are easy to touch */
    cursor: pointer;
}

/* Buttons */
.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-primary {
    background-color: green;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
}

/* Cancel: Yellow background with black text */
.btn-cancel {
    background-color: #ffc107;
    color: #111;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

/* Add buttons: Dark green background with white text */
.btn-add {
    background-color: #198754;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

/* Delete button: Reserved red */
.btn-delete {
    background-color: #dc3545;
    color: white!important;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
}


/* Tight, inline container for the touch arrows and text box */
.stepper-group {
    display: inline-flex;
    align-items: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    overflow: hidden;
    height: 36px; /* Matches the source selector height exactly */
}

/* Compact text box display - tightly constrained width */
.stepper-group input.stepper-input {
    width: 35px !important; /* Forces the box to shrink to a compact size */
    height: 100%;
    border: none;
    text-align: center;
    font-size: 1.0rem; 
    font-weight: 700;
    background: transparent;
    color: #111;
    padding: 0;
}

/* Unlocked text state styling when editing is active */
.stepper-group input.stepper-input:not([readonly]) {
    background-color: #fffde7; /* Subtle light yellow highlight when keypad is active */
}

/* Touch-optimized step navigation buttons [v] and [^] */
.btn-step {
    background-color: #f0f0f0;
    color: #333;
    border: none;
    width: 30px;
    height: 100%;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.btn-step:active {
    background-color: #ddd; /* Responsive dark pulse when tapped on glass */
}
