/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 15px;
    font-weight: 700;
}

.auth-info {
    margin-top: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#auth-user-display {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.9em;
}

.timezone-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px 24px;
    flex-wrap: wrap;
    font-size: 0.95em;
    opacity: 0.95;
}

.timezone-picker {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    text-align: left;
}

.timezone-picker label {
    font-size: 0.88em;
    font-weight: 600;
    opacity: 0.95;
}

.timezone-select,
#timezone-select {
    min-width: min(280px, 85vw);
    max-width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    font-size: 0.9em;
    cursor: pointer;
}

.timezone-select:focus,
#timezone-select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.timezone-info .timezone-applied,
.timezone-info #current-time {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 6px;
}

.timezone-applied {
    max-width: min(420px, 90vw);
    line-height: 1.35;
    text-align: center;
}

/* Main content */
main {
    padding: 30px;
}

/* Sections */
section {
    margin-bottom: 40px;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

/* Filters + Update Kill Time row */
.filters-update-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: stretch;
    margin-bottom: 40px;
}

.filters-update-row > section {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

@media (max-width: 992px) {
    .filters-update-row {
        grid-template-columns: 1fr;
    }
}

/* Filter section */
.filter-section {
    background: #e7f3ff;
    border-color: #b3d9ff;
}

.update-kill-section {
    background: #e7f3ff;
    border-color: #b3d9ff;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.9em;
    color: #495057;
}

.filter-group input {
    padding: 10px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.95em;
}

.filter-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-group-status {
    grid-column: 1 / -1;
    align-items: center;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 12px 16px;
}

.filter-status-heading {
    flex-shrink: 0;
    margin-bottom: 0;
    font-weight: 600;
    font-size: 0.9em;
    color: #495057;
}

.filter-status-checkboxes {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px 18px;
    align-items: center;
    min-width: 0;
}

.filter-status-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88em;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 6px 12px 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.filter-status-label input {
    width: auto;
    margin: 0;
    cursor: pointer;
}

/* Match RB card status colours: green / yellow / red blocks */
.filter-status-label-green {
    background-color: #f0fff4;
    border-left: 4px solid #28a745;
    color: #155724;
}

.filter-status-label-yellow {
    background-color: #fffbf0;
    border-left: 4px solid #ffc107;
    color: #856404;
}

.filter-status-label-red {
    background-color: #fff5f5;
    border-left: 4px solid #dc3545;
    color: #721c24;
}

.filter-status-label:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.filter-group:last-child {
    grid-column: 1 / -1;
    flex-direction: row;
    gap: 10px;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.btn-time-filter {
    background: #17a2b8;
    color: white;
}

.btn-time-filter:hover {
    background: #138496;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(23, 162, 184, 0.3);
}

section h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

/* RB Lists */
.rb-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* All RBs list - limit to 2 rows with scroll */
#all-rbs-list {
    max-height: 520px; /* Approximately 2 rows of cards (2 * ~250px card + 20px gap) */
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 5px; /* Space for scrollbar */
}

.rb-card {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.rb-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

.rb-card h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 10px;
}

/* RB Card Status Colors */
.rb-card-future {
    border-left: 5px solid #ffc107;
    background-color: #fffbf0;
}

.rb-card-future h3 {
    color: #ffc107;
}

.rb-card-under-respawn {
    border-left: 5px solid #28a745;
    background-color: #f0fff4;
}

.rb-card-under-respawn h3 {
    color: #28a745;
}

.rb-card-spoiled {
    border-left: 5px solid #dc3545;
    background-color: #fff5f5;
}

.rb-card-spoiled h3 {
    color: #dc3545;
}

.rb-info p {
    margin: 8px 0;
    font-size: 0.95em;
    line-height: 1.6;
}

.rb-info strong {
    color: #495057;
    font-weight: 600;
}

.time-remaining {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #e9ecef;
    font-size: 1.05em;
}

.rb-card-actions {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e9ecef;
}

.rb-card-edit-btn {
    padding: 8px 16px;
    font-size: 0.85em;
    text-transform: none;
    letter-spacing: normal;
}

.countdown {
    color: #667eea;
    font-weight: 700;
    font-size: 1.1em;
}

.empty-message {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 40px;
    background: white;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
}

.loading {
    text-align: center;
    color: #6c757d;
    padding: 20px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #495057;
    font-weight: 600;
    font-size: 0.95em;
}

.edit-load-btn {
    margin-top: 12px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1em;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Searchable select */
.searchable-select > select {
    display: none;
}

.searchable-select {
    position: relative;
}

.searchable-select #rb-select-input,
.searchable-select #edit-rb-select-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1em;
    cursor: pointer;
}

.searchable-select #rb-select-input:focus,
.searchable-select #edit-rb-select-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #667eea;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal .select-dropdown {
    z-index: 2100;
}

.select-dropdown.show {
    display: block;
}

.select-dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s;
}

.select-dropdown-item:hover {
    background-color: #f8f9fa;
}

.select-dropdown-item:last-child {
    border-bottom: none;
}

.select-dropdown-item.selected {
    background-color: #667eea;
    color: white;
}


/* Input with button */
.input-with-button {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-with-button input {
    flex: 1;
}

.btn-time-now {
    padding: 10px 16px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-time-now:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.btn-time-now:active {
    transform: translateY(0);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.4);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.35);
}

.btn-danger:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Result messages */
.result-message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 6px;
    font-weight: 500;
    display: none;
}

.result-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.result-message.error {
    background: linear-gradient(135deg, #fff5f5 0%, #fde8ec 100%);
    color: #5c1620;
    border: 1px solid #e8a4af;
    display: block;
    white-space: pre-line;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(114, 28, 36, 0.08);
}

/* Save section */
.save-section {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    background: #e7f3ff;
    border-color: #b3d9ff;
}

.auto-save-indicator {
    color: #28a745;
    font-weight: 600;
    font-size: 0.95em;
}

.edit-rb-trigger-hint {
    margin-bottom: 14px;
    color: #495057;
    font-size: 0.95em;
    line-height: 1.5;
}

.checkbox-inline-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
}

.checkbox-inline-group label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

/* Cookie login (main + admin) */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-overlay[hidden] {
    display: none !important;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 12px;
    padding: 32px 28px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

.login-title {
    color: #667eea;
    font-size: 1.75rem;
    margin-bottom: 8px;
    text-align: center;
}

.login-hint {
    color: #6c757d;
    text-align: center;
    margin-bottom: 22px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.login-footer-link {
    text-align: center;
    margin-top: 18px;
    margin-bottom: 0;
}

.login-footer-link a {
    color: #667eea;
    font-weight: 600;
}

.login-error.is-visible {
    display: block;
    margin-top: 14px;
    padding: 12px;
    border-radius: 6px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    font-size: 0.9rem;
}

.login-submit-btn {
    width: 100%;
    margin-top: 8px;
}

/* Admin page ( /admin ) */
.admin-gate-message {
    padding: 40px 30px;
    text-align: center;
}

.admin-gate-message h1 {
    color: #667eea;
    margin-bottom: 16px;
}

.admin-gate-message p {
    margin-bottom: 20px;
    color: #495057;
    line-height: 1.5;
}

.admin-main {
    padding: 30px;
}

.admin-header-actions {
    margin-top: 16px;
}

.auth-info a.btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.admin-users-list {
    margin-top: 18px;
    display: grid;
    gap: 12px;
}

.admin-user-row {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 14px;
}

.admin-user-row-title {
    margin-bottom: 10px;
}

.admin-user-you {
    font-weight: 600;
    opacity: 0.85;
}

.admin-user-row-perms {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 12px;
}

.admin-user-row-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Edit RB modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.is-open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    cursor: pointer;
}

.modal-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 40px);
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
    border-bottom: 2px solid #667eea;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 1.35em;
    color: #667eea;
}

.modal-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    color: #6c757d;
    padding: 4px 8px;
    border-radius: 6px;
}

.modal-close:hover {
    color: #333;
    background: rgba(0, 0, 0, 0.06);
}

.modal-body {
    padding: 22px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.edit-modal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    padding-top: 18px;
    border-top: 1px solid #dee2e6;
}

.edit-modal-footer-start {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .timezone-info {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .timezone-picker {
        align-items: center;
        width: 100%;
    }

    #timezone-select {
        width: 100%;
    }

    .timezone-applied {
        text-align: center;
    }
    
    main {
        padding: 20px;
    }
    
    section {
        padding: 20px;
    }

    .filter-group-status {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .filter-status-checkboxes {
        flex-wrap: wrap;
    }
    
    .rb-list {
        grid-template-columns: 1fr;
    }
    
    .save-section {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rb-card {
    animation: fadeIn 0.3s ease-out;
}
