/* BTC Courts - Raw CSS Styles */

/* ============ CSS Variables ============ */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;

    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --border-color: #e2e8f0;
    --text-color: #1e293b;
    --text-muted: #64748b;

    --navbar-bg: #1e293b;
    --navbar-text: #ffffff;

    --slot-height: 24px;
    --court-width: 120px;
    --time-column-width: 60px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
}

/* ============ Reset & Base ============ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-size: 14px;
    height: 100vh;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ============ Navbar ============ */
.navbar {
    background-color: var(--navbar-bg);
    color: var(--navbar-text);
    padding: 0.75rem 1rem;
    flex-shrink: 0;
    z-index: 100;
}

.navbar-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 600;
}

.navbar-actions {
    display: flex;
    gap: 0.5rem;
}

/* ============ Main Content ============ */
main {
    flex: 1;
    padding: 1rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Important for flex children to shrink */
}

/* ============ Footer ============ */
footer {
    background-color: var(--navbar-bg);
    color: var(--navbar-text);
    padding: 0.5rem 1rem;
    text-align: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #475569;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background-color: #16a34a;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: var(--danger-hover);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover:not(:disabled) {
    background-color: var(--bg-color);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-icon {
    padding: 0.375rem;
    min-width: 32px;
}

/* ============ Tabs ============ */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.tab {
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s ease;
}

.tab:hover {
    color: var(--text-color);
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* ============ Date/Time Controls ============ */
.datetime-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.datetime-controls input[type="date"],
.datetime-controls input[type="time"],
.datetime-controls select {
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

/* ============ Court Grid ============ */
.court-grid-container {
    flex: 1;
    overflow: auto;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-height: 0; /* Important for flex children to shrink */
}

.court-grid {
    display: grid;
    grid-template-columns: var(--time-column-width) repeat(10, var(--court-width));
    min-width: fit-content;
}

.court-header {
    position: sticky;
    top: 0;
    background-color: var(--surface-color);
    z-index: 10;
    display: contents;
}

.court-header-cell {
    padding: 0.75rem 0.5rem;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    background-color: var(--surface-color);
}

.time-column-header {
    position: sticky;
    left: 0;
    background-color: var(--bg-color);
    z-index: 11;
}

.court-body {
    display: contents;
}

.time-slot-row {
    display: contents;
}

.time-label {
    position: sticky;
    left: 0;
    background-color: var(--bg-color);
    padding: 0 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    height: var(--slot-height);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    border-right: 1px solid var(--border-color);
    z-index: 5;
}

.time-label.hour-mark {
    font-weight: 600;
    color: var(--text-color);
}

.court-cell {
    height: var(--slot-height);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid #f1f5f9;
    position: relative;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.court-cell:hover {
    background-color: #f1f5f9;
}

.court-cell.hour-mark {
    border-bottom-color: var(--border-color);
}

.court-cell.selected {
    background-color: #dbeafe;
}

.court-cell.has-group,
.court-cell.has-event {
    cursor: default;
}

/* ============ Court Assignments ============ */
.court-assignment {
    position: absolute;
    left: 2px;
    right: 2px;
    background-color: var(--primary-color);
    color: white;
    border-radius: var(--radius-sm);
    padding: 2px 4px;
    font-size: 0.7rem;
    overflow: hidden;
    z-index: 2;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.court-assignment:hover {
    box-shadow: var(--shadow-md);
}

.court-assignment.highlighted {
    outline: 2px solid #1e40af;
    outline-offset: 1px;
}

.court-assignment .player-names {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.court-assignment .time-info {
    font-size: 0.65rem;
    opacity: 0.9;
}

/* Scheduled Events */
.scheduled-event {
    position: absolute;
    left: 2px;
    right: 2px;
    background-color: var(--warning-color);
    color: white;
    border-radius: var(--radius-sm);
    padding: 2px 4px;
    font-size: 0.7rem;
    overflow: hidden;
    z-index: 1;
    cursor: pointer;
}

.scheduled-event.event-usta {
    background-color: #8b5cf6;
}

.scheduled-event.event-clinic {
    background-color: #06b6d4;
}

.scheduled-event.event-lesson {
    background-color: #10b981;
}

/* ============ Waitlist ============ */
.waitlist-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-height: 0;
    overflow: hidden;
}

.waitlist-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.waitlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.waitlist-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

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

.waitlist-table th,
.waitlist-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.waitlist-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.waitlist-table tr:last-child td {
    border-bottom: none;
}

.waitlist-table tr:hover {
    background-color: #f8fafc;
}

.waitlist-position {
    width: 40px;
    font-weight: 600;
    color: var(--text-muted);
}

.waitlist-players {
    font-weight: 500;
}

.waitlist-time {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.waitlist-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.waitlist-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

/* ============ Modals ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

/* ============ Forms ============ */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    transition: border-color 0.15s ease;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

/* ============ Player Entry ============ */
.player-entry {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    background-color: #fafafa;
}

.player-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.player-entry-label {
    font-weight: 500;
    font-size: 0.875rem;
}

.player-entry-remove {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
}

.player-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.player-selected-name {
    font-weight: 500;
}

.player-selected-guest {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============ Autocomplete ============ */
.autocomplete-container {
    position: relative;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
}

.autocomplete-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background-color: #f1f5f9;
}

.autocomplete-empty {
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.autocomplete-create {
    padding: 0.5rem 0.75rem;
    color: var(--primary-color);
    cursor: pointer;
    border-top: 1px solid var(--border-color);
}

.autocomplete-create:hover {
    background-color: #f1f5f9;
}

/* ============ Court Checkboxes ============ */
.court-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.court-checkbox {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.court-checkbox input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
}

/* ============ Confirmation Dialog ============ */
.confirm-dialog {
    text-align: center;
}

.confirm-dialog p {
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.confirm-dialog-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

/* ============ Action Buttons Overlay ============ */
.group-actions {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.25rem;
    background-color: var(--surface-color);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    white-space: nowrap;
    z-index: 20;
}

/* ============ Context Menu ============ */
.context-menu {
    position: fixed;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 150px;
    z-index: 1000;
    overflow: hidden;
}

.context-menu-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.context-menu-item:hover {
    background-color: #f1f5f9;
}

.context-menu-item.danger {
    color: var(--danger-color);
}

/* ============ Court Dropdown ============ */
.court-dropdown {
    position: absolute;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 20;
    min-width: 120px;
}

.court-dropdown-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.court-dropdown-item:hover {
    background-color: #f1f5f9;
}

.court-dropdown-item.disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}

/* ============ Toast Notifications ============ */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1rem;
    background-color: var(--text-color);
    color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.2s ease;
}

.toast.success {
    background-color: var(--success-color);
}

.toast.error {
    background-color: var(--danger-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============ Loading State ============ */
.loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-muted);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.5rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============ App Header ============ */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* ============ Utility Classes ============ */
.text-muted {
    color: var(--text-muted);
}

.text-danger {
    color: var(--danger-color);
}

.text-success {
    color: var(--success-color);
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
