/* styles.css - Premium Mobile PWA Design v25 */

:root {
    --primary: #6c5ce7;
    --primary-dark: #5f27cd;
    --primary-light: #a29bfe;
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --bg-input: #f1f2f6;
    --text-main: #2d3436;
    --text-sub: #636e72;
    --border: #dfe6e9;
    --success: #00b894;
    --error: #d63031;
    --warning: #fdcb6e;
    --header-height: 56px;
    --nav-height: 64px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    background: var(--bg-body);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    overscroll-behavior-y: none;
}

/* === Layout === */
.app-container {
    max-width: 100%;
    min-height: 100vh;
    padding: var(--header-height) 0 calc(var(--nav-height) + 16px) 0;
}

h1,
h2,
h3 {
    font-weight: 700;
    letter-spacing: -0.3px;
}

button,
input,
select {
    font-family: inherit;
}

/* === Header === */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: var(--shadow-sm);
}

.brand {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-btn {
    background: transparent;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--text-main);
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.header-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

.status-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 2px solid #fff;
    transition: background 0.3s;
}

.status-dot.online {
    background: var(--success);
}

.status-dot.offline {
    background: var(--error);
}

/* === Panels === */
.panel {
    padding: 16px;
    animation: fadeIn 0.2s ease-out;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* === Search === */
.search-bar {
    position: relative;
    margin-bottom: 12px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    opacity: 0.5;
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 44px;
    padding: 0 14px 0 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 0.95rem;
    transition: border 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

/* === Filter Bar === */
.filter-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    min-height: 0;
}

.filter-bar:empty {
    display: none;
}

.filter-chip {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    white-space: nowrap;
}

.filter-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.filter-chip.tag-active {
    color: #fff;
    border-color: transparent;
}

.filter-clear {
    padding: 5px 8px;
    font-size: 0.75rem;
    color: var(--text-sub);
    background: none;
    border: none;
    cursor: pointer;
}

.filter-clear:hover {
    color: var(--error);
}

.result-count {
    font-size: 0.75rem;
    color: var(--text-sub);
    margin-bottom: 8px;
}

/* === Song Cards === */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.song-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.1s;
}

.song-card:active {
    transform: scale(0.98);
}

.song-info {
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

.song-title {
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
}

.song-title-artist-divider {
    color: var(--text-muted);
    font-weight: 400;
    margin: 0 4px;
    font-size: 0.85rem;
}

.song-title .song-inline-artist {
    font-size: 0.8rem;
    color: var(--text-sub);
    font-weight: 500;
    word-break: break-word;
}

.song-subtitle {
    font-size: 0.78rem;
    color: var(--text-sub);
    margin-top: 2px;
    line-height: 1.3;
    word-break: break-word;
}

.song-artist-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    flex-wrap: wrap;
}

.song-artist-row .song-artist {
    font-size: 0.8rem;
    color: var(--text-sub);
    flex-shrink: 1;
    word-break: break-word;
}

.song-tags-inline {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
}

.song-artist {
    font-size: 0.8rem;
    color: var(--text-sub);
    margin-top: 2px;
    word-break: break-word;
}

.song-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.song-type {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 8px;
    background: #f0efff;
    color: var(--primary);
    font-weight: 600;
    white-space: normal;
    word-break: break-word;
}

.tag-pill {
    font-size: 0.65rem;
    padding: 1px 7px;
    border-radius: 8px;
    font-weight: 500;
}

.song-tags-center {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

.song-tag-sm {
    font-size: 0.65rem;
    padding: 0px 6px;
    border-radius: 8px;
    font-weight: 500;
    border: 1px solid;
    white-space: normal;
    word-break: break-word;
}

.song-note {
    font-size: 0.72rem;
    color: var(--text-sub);
    font-style: italic;
    margin-top: 2px;
    opacity: 0.8;
    line-height: 1.25;
    word-break: break-word;
}

.song-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.song-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.song-edit-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-sub);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
}

.song-edit-btn:active {
    background: var(--primary-light);
    color: #fff;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-sub);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    display: block;
    opacity: 0.5;
}

/* === Forms === */
.form-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.form-card.compact {
    padding: 14px;
}

.section-title {
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
}

.required {
    color: var(--error);
}

.form-input,
.form-select {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-input);
    font-size: 0.95rem;
    transition: border 0.2s, box-shadow 0.2s;
    appearance: none;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
    background: #fff;
}

.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: "▼";
    font-size: 0.7rem;
    color: var(--text-sub);
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

/* === Chip Selector === */
.chip-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip-option {
    padding: 7px 14px;
    border-radius: 20px;
    background: var(--bg-input);
    color: var(--text-sub);
    border: 1px solid transparent;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    user-select: none;
}

.chip-option.selected {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 3px 10px rgba(108, 92, 231, 0.35);
}

.chip-option:empty {
    display: none;
}

.btn-submit {
    width: 100%;
    height: 48px;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}

.btn-submit:active {
    transform: scale(0.98);
}

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

/* === Management === */
.mgmt-tabs {
    display: flex;
    background: var(--bg-input);
    padding: 3px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.mgmt-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 9px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.2s;
}

.mgmt-tab.active {
    background: #fff;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.sub-panel.hidden {
    display: none;
}

.mgmt-list {
    margin-top: 12px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.mgmt-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    background: #fff;
    font-size: 0.9rem;
}

.mgmt-list-item:last-child {
    border-bottom: none;
}

.mgmt-item-name {
    font-weight: 500;
    flex: 1;
}

.mgmt-item-count {
    font-size: 0.75rem;
    color: var(--text-sub);
    margin-right: 8px;
}

.mgmt-item-actions {
    display: flex;
    gap: 4px;
}

.add-inline-row {
    display: flex;
    gap: 8px;
}

.btn-icon-add {
    min-width: 44px;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: none;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.btn-icon-sm:active {
    background: rgba(0, 0, 0, 0.05);
}

/* === Bottom Nav === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    background: var(--bg-body);
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    flex: 1;
    height: 100%;
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #b2bec3;
    cursor: pointer;
    transition: color 0.2s;
    padding-bottom: 2px;
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 1.3rem;
    transition: transform 0.2s;
}

.nav-item.active .nav-icon {
    transform: translateY(-1px);
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 600;
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    backdrop-filter: blur(3px);
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #fff;
    width: 90%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.25s ease-out;
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-overlay.show .modal-content {
    transform: translateY(0);
}

.modal-sm {
    max-width: 320px;
}

/* Full screen song detail modal */
.modal-full {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.modal-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    flex-shrink: 0;
}

.modal-back-btn {
    background: none;
    border: none;
    font-size: 0.95rem;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
}

.modal-header-title {
    font-size: 1rem;
    font-weight: 700;
}

.modal-delete-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px;
}

.modal-body-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.detail-field {
    margin-bottom: 16px;
}

.detail-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-sub);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.detail-value {
    font-size: 0.95rem;
}

.modal-title {
    font-size: 1.15rem;
    margin-bottom: 14px;
}

.btn-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: transparent;
    cursor: pointer;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.btn-cancel {
    flex: 1;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #fff;
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-danger {
    flex: 1;
    height: 44px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--error);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary-sm {
    height: 40px;
    padding: 0 20px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
}

/* === Toast === */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-80px);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 3000;
    pointer-events: none;
    transition: transform 0.3s ease;
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

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

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

/* === Inline Edit === */
.inline-edit-row {
    display: flex;
    gap: 6px;
    align-items: center;
    width: 100%;
}

.inline-edit-input {
    flex: 1;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--primary);
    background: #fff;
    font-size: 0.85rem;
}

.inline-edit-input:focus {
    outline: none;
}

.btn-save-sm {
    height: 36px;
    padding: 0 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-cancel-sm {
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-sub);
    font-size: 0.8rem;
    cursor: pointer;
}

/* New Features: Searchable Select & Central Tags */
.searchable-select-container {
    position: relative;
}

.searchable-select-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--bg-input);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.searchable-select-input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.searchable-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    z-index: 100;
    box-shadow: var(--shadow-lg);
    display: none;
    margin-top: 4px;
}

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

.searchable-select-option {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--bg-input);
    font-size: 0.95rem;
}

.searchable-select-option:last-child {
    border-bottom: none;
}

.searchable-select-option:hover,
.searchable-select-option.selected {
    background: var(--bg-input);
    color: var(--primary);
    font-weight: 500;
}

.song-tags-center {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 16px 0;
    padding: 0 10px;
}

.song-tag-lg {
    font-size: 0.9rem;
    padding: 8px 16px;
    background: var(--bg-input);
    border-radius: 20px;
    color: var(--text-sub);
    font-weight: 500;
    border: 1px solid transparent;
}

.song-tag-lg:hover {
    border-color: var(--border);
    background: #fff;
}