/* widget-voicepicker.css
 *
 * Styles for the VoicePickerWidget - a selectable table of voices with tags and filtering.
 */

/* *******************************************************
 * Widget container
 * ******************************************************* */

.vp-widget {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 200px;
    gap: 10px;
}

/* *******************************************************
 * Filter bar
 * ******************************************************* */

.vp-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.vp-filter-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    white-space: nowrap;
}

.vp-filter-input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    font-size: 0.88rem;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.9);
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.vp-filter-input::placeholder {
    color: rgba(255, 255, 255, 0.28);
}

.vp-filter-input:focus {
    outline: none;
    border-color: #2dd4bf;
}

.vp-filter-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.4);
    font-size: 1.1rem;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    display: none;
}

.vp-filter-clear.visible {
    display: block;
}

.vp-filter-clear:hover {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.1);
}

/* *******************************************************
 * Table
 * ******************************************************* */

.vp-table-container {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow-y: auto;
    max-height: 360px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.vp-table-container::-webkit-scrollbar {
    width: 6px;
}

.vp-table-container::-webkit-scrollbar-track {
    background: transparent;
}

.vp-table-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 3px;
}

.vp-table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

.vp-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.85rem;
    background: #1e2030;
}

/* th inner flex layout (sort label + indicator) */
.vp-th-inner {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Sort indicator triangle */
.vp-sort-indicator {
    font-size: 0.68rem;
    color: #2dd4bf;
    flex-shrink: 0;
    line-height: 1;
}

/* Sortable header */
.vp-th-sortable {
    cursor: pointer;
    user-select: none;
}

.vp-th-sortable:hover .vp-th-inner span:first-child {
    color: rgba(255, 255, 255, 0.85);
}

/* Resizable th — needs relative positioning for the handle */
.vp-th-resizable {
    position: relative;
}

/* Column resize handle — sits on the right edge of the th */
.vp-col-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    width: 5px;
    height: 100%;
    cursor: col-resize;
    z-index: 11;
}

.vp-col-resize-handle::after {
    content: '';
    position: absolute;
    right: 0;
    top: 20%;
    height: 60%;
    width: 2px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 1px;
    transition: background 0.15s ease;
}

.vp-col-resize-handle:hover::after {
    background: #2dd4bf;
}


.vp-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    transition: background-color 0.15s ease;
    cursor: pointer;
}

.vp-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

.vp-table tbody tr.selected {
    background-color: rgba(45, 212, 191, 0.18);
}

.vp-table tbody tr.vp-row-default {
    background-color: rgba(255, 255, 255, 0.03);
}

.vp-table tbody tr.vp-row-default:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.vp-table tbody tr.vp-row-default.selected {
    background-color: rgba(45, 212, 191, 0.22);
}

.vp-table tbody tr.vp-hidden {
    display: none;
}

.vp-table td {
    padding: 10px 12px;
    vertical-align: middle;
}


/* *******************************************************
 * Name / description cell
 * ******************************************************* */

.vp-name-cell {
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.88);
    font-weight: 500;
}

.vp-description {
    display: block;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 400;
    margin-top: 2px;
}

/* *******************************************************
 * Tags cell
 * ******************************************************* */

.vp-tags-cell {
    min-width: 140px;
    max-width: 260px;
}

.vp-tags-area {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 24px;
    align-items: center;
}

/* Individual tag pill */
.vp-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    cursor: default;
    user-select: none;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.vp-tag.vp-tag-user {
    cursor: context-menu;
}

/* *******************************************************
 * Context menu
 * ******************************************************* */

.vp-context-menu {
    position: fixed;
    background: #1e2030;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    z-index: 99999;
    min-width: 150px;
    padding: 4px 0;
    animation: vp-menu-appear 0.1s ease;
}

@keyframes vp-menu-appear {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.vp-context-menu-item {
    padding: 8px 16px;
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.82);
    cursor: pointer;
    user-select: none;
    transition: background 0.1s ease;
}

.vp-context-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.95);
}

.vp-context-menu-item.danger {
    color: #ff8080;
}

.vp-context-menu-item.danger:hover {
    background: rgba(211, 47, 47, 0.2);
}

.vp-context-menu-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

/* *******************************************************
 * Add / Edit tag overlay (inline small dialog)
 * ******************************************************* */

.vp-tag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
}

.vp-tag-dialog {
    background: #16161f;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    width: 300px;
    overflow: hidden;
}

.vp-tag-dialog-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.vp-tag-dialog-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    flex: 1;
}

.vp-tag-dialog-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 1.4rem;
    line-height: 1;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.vp-tag-dialog-close:hover {
    background: rgba(255,255,255,0.35);
}

.vp-tag-dialog-body {
    padding: 18px 20px;
    background: #1e2030;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.vp-tag-form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.vp-tag-form-group label {
    font-size: 0.83rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
}

.vp-tag-form-group input[type="text"] {
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.9);
    box-sizing: border-box;
    width: 100%;
    transition: border-color 0.2s;
}

.vp-tag-form-group input[type="text"]::placeholder {
    color: rgba(255, 255, 255, 0.28);
}

.vp-tag-form-group input[type="text"]:focus {
    outline: none;
    border-color: #2dd4bf;
}

.vp-tag-color-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.vp-color-swatches {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.vp-color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    box-sizing: border-box;
    transition: transform 0.1s, border-color 0.1s;
}

.vp-color-swatch:hover {
    transform: scale(1.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.vp-tag-preview-group {
    align-items: flex-start;
}

.vp-tag-color-input {
    width: 38px;
    height: 30px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 2px;
    cursor: pointer;
    background: #2a2a3a;
}

.vp-tag-preview {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
    min-width: 40px;
    justify-content: center;
}

.vp-tag-dialog-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: #16161f;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.vp-tag-btn {
    padding: 7px 18px;
    border-radius: 6px;
    border: none;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.vp-tag-btn-primary {
    background: #667eea;
    color: white;
}

.vp-tag-btn-primary:hover {
    background: #5a6fd6;
}

.vp-tag-btn-secondary {
    background: #3a3a4a;
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.vp-tag-btn-secondary:hover {
    background: #484858;
    color: rgba(255, 255, 255, 0.9);
}

/* *******************************************************
 * Sample player column
 * ******************************************************* */

.vp-sample-col {
    width: 48px;
    text-align: center;
}

.vp-sample-cell {
    width: 48px;
    text-align: center;
    padding: 6px 8px;
}

.vp-sample-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.vp-sample-btn:active:not(:disabled) {
    transform: scale(0.92);
}

.vp-sample-btn-play {
    background: #28a745;
    color: white;
}

.vp-sample-btn-play:hover:not(:disabled) {
    background: #218838;
}

.vp-sample-btn-stop {
    background: #007bff;
    color: white;
}

.vp-sample-btn-stop:hover:not(:disabled) {
    background: #0056b3;
}

.vp-sample-btn-loading {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.5);
    cursor: default;
}

.vp-sample-icon {
    width: 16px;
    height: 16px;
    display: none;
    flex-shrink: 0;
}

.vp-sample-btn-play .vp-sample-icon-play,
.vp-sample-btn-stop .vp-sample-icon-stop {
    display: block;
}

.vp-sample-btn-loading .vp-sample-icon-loading {
    display: block;
    animation: vp-spin 0.9s linear infinite;
}

@keyframes vp-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* *******************************************************
 * States
 * ******************************************************* */

.vp-empty-state {
    padding: 40px 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.45);
    font-size: 1rem;
}

.vp-loading-state {
    padding: 40px 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.55);
    font-size: 1rem;
}

/* *******************************************************
 * Light mode overrides (.vp-widget-light)
 * ******************************************************* */

.vp-widget-light .vp-filter-label {
    color: #555;
}

.vp-widget-light .vp-filter-input {
    border-color: #d0d4dc;
    background: white;
    color: #333;
}

.vp-widget-light .vp-filter-input::placeholder {
    color: #aaa;
}

.vp-widget-light .vp-filter-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.vp-widget-light .vp-filter-clear {
    color: #aaa;
}

.vp-widget-light .vp-filter-clear:hover {
    color: #555;
    background: rgba(0, 0, 0, 0.06);
}

.vp-widget-light .vp-table-container {
    border-color: #dde1ea;
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.vp-widget-light .vp-table-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}

.vp-widget-light .vp-table th {
    background: #dde1ea;
    color: #555;
    border-bottom-color: #c5cad6;
}

.vp-widget-light .vp-th-sortable:hover .vp-th-inner span:first-child {
    color: #222;
}

.vp-widget-light .vp-col-resize-handle::after {
    background: rgba(0, 0, 0, 0.2);
}

.vp-widget-light .vp-col-resize-handle:hover::after {
    background: #0d9488;
}

.vp-widget-light .vp-table tbody tr {
    border-bottom-color: #f0f2f7;
}

.vp-widget-light .vp-table tbody tr:hover {
    background-color: #f5f6fc;
}

.vp-widget-light .vp-table tbody tr.selected {
    background-color: #eef0ff;
}

.vp-widget-light .vp-table tbody tr.vp-row-default {
    background-color: #fafbff;
}

.vp-widget-light .vp-table tbody tr.vp-row-default:hover {
    background-color: #f0f2fc;
}

.vp-widget-light .vp-table tbody tr.vp-row-default.selected {
    background-color: #e6e9ff;
}

.vp-widget-light .vp-name-cell {
    color: #222;
}

.vp-widget-light .vp-description {
    color: #888;
}

.vp-widget-light .vp-sample-btn-loading {
    background: rgba(0, 0, 0, 0.08);
    color: rgba(0, 0, 0, 0.35);
}

.vp-widget-light .vp-empty-state {
    color: #aaa;
}

.vp-widget-light .vp-loading-state {
    color: #888;
}

/* Context menu — light theme (appended to body, scoped by .vp-theme-light) */
.vp-context-menu.vp-theme-light {
    background: white;
    border-color: #dde1ea;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.vp-context-menu.vp-theme-light .vp-context-menu-item {
    color: #333;
}

.vp-context-menu.vp-theme-light .vp-context-menu-item:hover {
    background: #f0f2f7;
    color: #111;
}

.vp-context-menu.vp-theme-light .vp-context-menu-item.danger {
    color: #d32f2f;
}

.vp-context-menu.vp-theme-light .vp-context-menu-item.danger:hover {
    background: rgba(211, 47, 47, 0.08);
}

.vp-context-menu.vp-theme-light .vp-context-menu-separator {
    background: #e8eaf0;
}

/* Tag dialog — light theme */
.vp-tag-dialog.vp-theme-light {
    background: white;
}

.vp-tag-dialog.vp-theme-light .vp-tag-dialog-body {
    background: #f7f8fc;
}

.vp-tag-dialog.vp-theme-light .vp-tag-form-group label {
    color: #555;
}

.vp-tag-dialog.vp-theme-light .vp-tag-form-group input[type="text"] {
    border-color: #d0d4dc;
    background: white;
    color: #333;
}

.vp-tag-dialog.vp-theme-light .vp-tag-form-group input[type="text"]::placeholder {
    color: #aaa;
}

.vp-tag-dialog.vp-theme-light .vp-tag-form-group input[type="text"]:focus {
    border-color: #667eea;
}

.vp-tag-dialog.vp-theme-light .vp-tag-color-input {
    background: white;
    border-color: #d0d4dc;
}

.vp-tag-dialog.vp-theme-light .vp-tag-dialog-footer {
    background: #f0f2f7;
    border-top-color: #dde1ea;
}

.vp-tag-dialog.vp-theme-light .vp-tag-btn-secondary {
    background: white;
    color: #555;
    border-color: #c0c4cc;
}

.vp-tag-dialog.vp-theme-light .vp-tag-btn-secondary:hover {
    background: #f0f2f7;
    color: #333;
}
