/* ==========================================================================
   UPL Schedule Widget – Front-end Styles
   ========================================================================== */

/* ---- Layout ---- */

.upl-schedule {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: #333;
    line-height: 1.5;
    box-sizing: border-box;
}

.upl-schedule *,
.upl-schedule *::before,
.upl-schedule *::after {
    box-sizing: inherit;
}

/* Top layout: filters above table */
.upl-layout-top .upl-main { display: block; }

/* Side layout: filters in left column */
.upl-layout-side {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.upl-layout-side .upl-sidebar {
    flex: 0 0 220px;
    min-width: 180px;
    position: sticky;
    top: 20px;
}

.upl-layout-side .upl-main {
    flex: 1 1 0;
    min-width: 0;
}

/* ---- Filter Bar ---- */

.upl-filters {
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 16px 20px;
    margin-bottom: 18px;
}

.upl-layout-side .upl-filters {
    margin-bottom: 0;
}

.upl-filters-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    align-items: flex-end;
}

.upl-layout-side .upl-filters-inner {
    flex-direction: column;
    align-items: stretch;
}

.upl-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
}

.upl-filter-group label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
}

.upl-filter-group select,
.upl-filter-group input[type="date"] {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    font-size: 13px;
    color: #333;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
    transition: border-color 0.2s;
}

.upl-filter-group select:focus,
.upl-filter-group input[type="date"]:focus {
    outline: none;
    border-color: #00a651;
    box-shadow: 0 0 0 2px rgba(0, 166, 81, 0.15);
}

.upl-date-range {
    display: flex;
    align-items: center;
    gap: 6px;
}

.upl-date-range input[type="date"] {
    flex: 1;
}

.upl-date-sep {
    color: #999;
    font-weight: 600;
}

/* Filter action buttons */
.upl-filter-actions {
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
}

.upl-layout-side .upl-filter-actions {
    flex-direction: row;
}

.upl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    border-radius: 4px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, opacity 0.2s;
    white-space: nowrap;
    text-decoration: none;
}

.upl-btn:focus { outline: 2px solid #00a651; outline-offset: 2px; }

.upl-btn-primary {
    background-color: #00a651;
    color: #fff;
    border-color: #00a651;
}

.upl-btn-primary:hover { opacity: 0.85; }

.upl-btn-secondary {
    background-color: #fff;
    color: #555;
    border-color: #ccc;
}

.upl-btn-secondary:hover {
    background-color: #f4f4f4;
}

/* ---- Results Info ---- */

.upl-results-info {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 6px 2px;
    margin-bottom: 6px;
    font-size: 12px;
    color: #888;
}

/* ---- Table ---- */

.upl-table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    background: #fff;
}

.upl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.upl-table thead th {
    background-color: #00a651;
    color: #fff;
    font-weight: 600;
    padding: 12px 14px;
    text-align: left;
    white-space: nowrap;
    font-size: 13px;
    letter-spacing: 0.3px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.upl-table thead th:first-child { border-radius: 8px 0 0 0; }
.upl-table thead th:last-child  { border-radius: 0 8px 0 0; }

.upl-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

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

.upl-table tbody tr:nth-child(odd) { background-color: #f4faf7; }
.upl-table tbody tr:nth-child(even) { background-color: #fff; }

.upl-table tbody tr:hover {
    background-color: #e6f5ee;
    transition: background-color 0.15s;
}

/* Column-specific widths */
.upl-col-date     { width: 110px; white-space: nowrap; }
.upl-col-time     { width: 90px;  white-space: nowrap; }
.upl-col-court    { width: 80px;  }
.upl-col-week     { width: 90px;  }
.upl-col-status   { width: 100px; text-align: center; }
.upl-col-score    { width: 80px;  text-align: center; }

/* Status badges */
.upl-status {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.upl-status--scheduled   { background: #e8f5e9; color: #2e7d32; }
.upl-status--completed   { background: #e3f2fd; color: #1565c0; }
.upl-status--postponed   { background: #fff8e1; color: #f57f17; }
.upl-status--cancelled   { background: #fce4ec; color: #c62828; }
.upl-status--in_progress { background: #f3e5f5; color: #6a1b9a; }

/* ---- Loading / Empty states ---- */

.upl-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px;
    justify-content: center;
    color: #666;
    font-size: 14px;
}

.upl-spinner {
    width: 18px;
    height: 18px;
    border: 3px solid #ddd;
    border-top-color: #00a651;
    border-radius: 50%;
    animation: upl-spin 0.7s linear infinite;
    display: inline-block;
}

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

.upl-empty {
    padding: 32px 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.upl-empty p { margin: 0; }

/* ---- Pagination ---- */

.upl-pagination {
    padding: 14px 16px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
    border-radius: 0 0 8px 8px;
}

.upl-pagination-list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.upl-pagination-list li { display: flex; }

.upl-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.upl-page-btn:hover { background: #f0f0f0; border-color: #bbb; }

.upl-page-btn.upl-page-active {
    background-color: #00a651;
    border-color: #00a651;
    color: #fff;
    font-weight: 700;
}

.upl-page-ellipsis {
    align-items: center;
    color: #999;
    padding: 0 4px;
}

/* ---- Editor placeholder ---- */

.upl-editor-preview {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    background: #fafafa;
}

.upl-editor-notice strong { font-size: 16px; display: block; margin-bottom: 8px; }
.upl-editor-notice p { color: #666; font-size: 13px; margin: 0; }

/* ---- Responsive ---- */

@media (max-width: 768px) {
    .upl-layout-side {
        flex-direction: column;
    }

    .upl-layout-side .upl-sidebar {
        flex: none;
        width: 100%;
        position: static;
    }

    .upl-filters-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .upl-filter-group {
        min-width: 0;
        width: 100%;
    }

    .upl-filter-actions {
        flex-direction: row;
    }

    .upl-table thead th,
    .upl-table tbody td {
        padding: 9px 10px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    /* On very small screens hide lower-priority columns */
    .upl-col-court,
    .upl-col-week  { display: none; }
}
