:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338ca;
    --text-color: #1f2937;
    --text-secondary: #6b7280;
    --bg-color: #f3f4f6;
    --card-bg: #e8e5e2;
    --header-bg: #f5c262;
    --footer-bg: #f5c262;
    --input-border: #d1d5db;
    --input-focus: #4F46E5;
    --error-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
}
.theme-dark {
    --primary-color: #4F46E5;
    --primary-hover: #4338ca;
    --text-color: #e5e7eb;
    --text-secondary: #9ca3af;
    --bg-color: #0f172a;
    --card-bg: #111827;
    --header-bg: #0b1220;
    --footer-bg: #0b1220;
    --input-border: #374151;
    --input-focus: #4F46E5;
    --error-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column; /* Alterado para column para melhor fluxo vertical */
    align-items: center;
    min-height: 100vh;
    color: var(--text-color);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

.login-container {
    background-color: var(--card-bg);
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-header {
    margin-bottom: 2rem;
    text-align: center;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.login-logo {
    max-width: 150px;
    margin-bottom: 1rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s;
    outline: none;
}

.form-group input:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.remember-me input[type="checkbox"] {
    border-radius: 0.25rem;
    border-color: var(--input-border);
    color: var(--primary-color);
}

.forgot-password {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.forgot-password:hover {
    text-decoration: underline;
}

.login-btn {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.login-btn:hover {
    background-color: var(--primary-hover);
}

.login-footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.login-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.login-footer a:hover {
    text-decoration: underline;
}

/* Melhorias para dispositivos móveis */
@media (max-width: 480px) {
    .login-container {
        padding: 1.5rem; /* Reduz padding interno em telas pequenas */
    }

    .login-header h1 {
        font-size: 1.25rem;
    }

    .form-actions {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .forgot-password {
        font-size: 0.8rem;
    }
}

/* Ajustes para notebooks 1366x768 */
@media (max-width: 1366px), (max-height: 800px) {
    .login-container {
        max-width: 360px;
        padding: 2rem;
    }
    .login-logo {
        max-width: 120px;
        margin-bottom: 0.75rem;
    }
    .login-header h1 {
        font-size: 1.35rem;
        margin-bottom: 0.4rem;
    }
    .login-header p {
        font-size: 0.82rem;
    }
    .form-group {
        margin-bottom: 1rem;
    }
    .form-group input {
        padding: 0.625rem 0.875rem;
        font-size: 0.85rem;
    }
    .form-actions {
        margin-bottom: 1.25rem;
    }
    .login-btn {
        padding: 0.625rem;
        font-size: 0.85rem;
    }
    .login-footer {
        margin-top: 1.25rem;
        font-size: 0.82rem;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Payroll */
.section {
    margin-top: 1rem;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
.card {
    background: var(--card-bg);
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    overflow: hidden;
}
.card-header {
    padding: 0.75rem 1rem;
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
    color: var(--text-color);
}
.card-body {
    padding: 1rem;
    overflow-x: auto;
}
.employees-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.employees-grid-header,
.employee-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1.5fr;
    gap: 0.5rem;
    align-items: center;
}
.employees-grid-header {
    font-weight: 600;
    background: var(--bg-color);
    color: var(--text-color);
    padding: 0.5rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
}
.employee-row {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--card-bg);
}
.employee-row .actions {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}
.table th, .table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 0.75rem;
    text-align: left;
    font-size: 0.875rem;
}
.table th {
    background: var(--bg-color);
    color: var(--text-color);
}
.table tfoot td {
    background: var(--bg-color);
    font-weight: 600;
}
.btn {
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    border: none;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
}
.btn svg, .btn-primary svg, .logout-btn svg, .btn-small svg {
    width: 18px;
    height: 18px;
    margin-right: 6px;
    stroke: currentColor;
    fill: none;
    vertical-align: middle;
}
.btn:hover {
    background: var(--primary-hover);
}
.module-card .module-icon {
    width: 42px;
    height: 42px;
    margin-bottom: 12px;
    stroke: currentColor;
}
.module-card .module-icon {
    transition: transform 0.2s ease;
}
.module-card:hover .module-icon {
    transform: scale(1.06);
}
.btn svg {
    transition: transform 0.2s ease;
}
.btn:hover svg, .logout-btn:hover svg, .btn-small:hover svg {
    transform: translateY(-1px);
}
.theme-dark .btn svg, .theme-dark .logout-btn svg, .theme-dark .btn-small svg {
    stroke: #ffffff;
}
.theme-dark .module-card .module-icon {
    stroke: #e5e7eb;
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}
.pulse {
    animation: pulse 1.6s ease-in-out infinite;
}
.logout-btn {
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    border: none;
    background: var(--error-color);
    color: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}
.logout-btn:hover {
    filter: brightness(0.9);
}
.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}
.btn-danger {
    background: var(--error-color);
}
.btn-danger:hover {
    filter: brightness(0.9);
}
.input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    outline: none;
    font-size: 0.875rem;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.theme-dark #memberFormSection .form-row,
#memberFormSection .form-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Flatten all rows into a single 4-column grid for the member form */
#memberFormSection {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}
#memberFormSection .form-row {
    display: contents;
}
#memberFormSection .form-group {
    min-width: 0;
}
#memberFormSection #mZip {
    width: 100%;
    max-width: 160px;
    justify-self: start;
}
#memberFormSection .inline-two {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0.75rem;
}
#memberFormSection .address-inline-five {
    display: grid;
    grid-template-columns: 2fr 0.8fr 1.3fr 1.6fr 0.9fr;
    gap: 0.75rem;
}
#memberFormSection .address-inline-five .inline-item {
    min-width: 0;
}
@media (max-width: 640px) {
    #memberFormSection .address-inline-five {
        grid-template-columns: 1fr;
    }
}
#memberFormSection .filiation-inline-four {
    display: grid;
    grid-template-columns: 1.3fr 1.3fr 1.6fr 0.6fr;
    gap: 0.75rem;
}
#memberFormSection .spouse-inline-three {
    display: grid;
    grid-template-columns: 1.6fr 1.4fr 1fr;
    gap: 0.75rem;
}
@media (max-width: 640px) {
    #memberFormSection .spouse-inline-three {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 640px) {
    #memberFormSection .filiation-inline-four {
        grid-template-columns: 1fr;
    }
}
.#memberFormSection .grid-break {}
#memberFormSection .grid-break {
    grid-column: 1 / -1;
}
@media (max-width: 1024px) {
    #memberFormSection {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 640px) {
    #memberFormSection {
        grid-template-columns: 1fr;
    }
}
.form-group label {
    margin-bottom: 0.25rem;
}

/* Theme Toggle */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
}

/* Dark Theme */
body.theme-dark {
    --bg-color: #0b0f19;
    --text-color: #e5e7eb;
    --text-secondary: #9ca3af;
    --card-bg: #111827;
    --header-bg: var(--card-bg);
    --footer-bg: var(--card-bg);
    --input-border: #374151;
    --primary-color: #4F46E5;
    --primary-hover: #4338ca;
}

/* Dark mode support adjustments */
body.theme-dark .module-card {
    background: #2d3748;
    border-color: #4b5563;
}
body.theme-dark .module-card:hover {
    background: #374151;
    border-color: var(--primary-color);
}

/* Fixed Layout Styles */
.app-header-fixed {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--input-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.app-logo {
    height: 48px;
    width: auto;
}

.app-footer-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background: var(--footer-bg);
    border-top: 1px solid var(--input-border);
    display: flex;
    align-items: center;
    justify-content: space-between; /* Garante que o conteúdo fique nas extremidades */
    padding: 0 2rem;
    z-index: 1000;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.main-content-adjusted {
    margin-top: 80px;
    margin-bottom: 60px;
    width: 100%;
    max-width: 1200px;
    display: flex;
    justify-content: center;
}

/* Center main content between fixed header and footer */
.app-main-center {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 80px;
    padding-bottom: 60px;
    width: 100%;
}

@media (max-width: 1366px) {
    .app-header-fixed {
        padding: 0.5rem 1rem;
        min-height: 72px;
        gap: 0.5rem;
        flex-wrap: wrap;
        position: relative; /* Mudança importante para telas pequenas */
    }
    .app-header-fixed .header-actions {
        flex-wrap: wrap;
        row-gap: 0.4rem;
    }
    .header-left .welcome-text h1 {
        font-size: 1.25rem;
    }
    .app-logo {
        height: 40px;
    }
    .app-main-center {
        padding-top: 20px; /* Reduzido pois o header não é mais fixo ou já foi compensado */
    }
    .main-content-adjusted {
        margin-top: 20px;
    }
}

@media (max-width: 768px) {
    .app-header-fixed {
        flex-direction: column;
        align-items: center;
        text-align: center;
        height: auto;
        padding: 1rem;
    }
    .header-left {
        flex-direction: column;
        margin-bottom: 1rem;
    }
    .header-actions {
        justify-content: center;
        width: 100%;
    }
    .app-footer-fixed {
        flex-direction: column;
        height: auto;
        padding: 1rem;
        text-align: center;
        gap: 0.5rem;
        position: relative;
    }
    .app-main-center {
        padding-bottom: 20px;
    }
}

@media (max-width: 1024px) {
    .grid {
        grid-template-columns: 1fr;
    }
    .employees-grid-header,
    .employee-row {
        grid-template-columns: 1.8fr 1fr 1fr 1fr 1fr 1.2fr;
    }
}
@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    .table {
        min-width: 560px;
    }
    .employees-grid-header,
    .employee-row {
        grid-template-columns: 1fr;
    }
    .table th, .table td {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }
}

.toast {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    min-width: 300px;
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid var(--primary-color);
}

.toast.error {
    border-left-color: var(--error-color);
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

.toast-message {
    font-size: 0.875rem;
    color: var(--text-color);
    font-weight: 500;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}
/* Background Slider */
#bg-slider {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.bg-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 2s ease-in-out;
}

.bg-slide.active {
    opacity: 1;
}

body.bg-active {
    background: linear-gradient(135deg, #0ea5e9, #8b5cf6, #ef4444, #f97316);
    background-size: 250% 250%;
    animation: bgFallbackMove 22s ease-in-out infinite;
}

@keyframes bgFallbackMove {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}
.login-audio-toggle {
    position: fixed !important;
    right: 20px;
    bottom: 80px;
    width: 48px;
    height: 48px;
    border-radius: 9999px;
    border: 1px solid var(--input-border);
    background: var(--card-bg) !important;
    color: var(--text-color) !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999 !important;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.login-audio-toggle:hover {
    filter: brightness(1.03);
    box-shadow: 0 8px 18px rgba(0,0,0,0.12);
}
.login-audio-toggle:focus-visible {
    outline: 3px solid rgba(79,70,229,0.25);
    outline-offset: 2px;
}
.login-audio-toggle svg {
    width: 22px;
    height: 22px;
    display: block;
}
.login-audio-label {
    position: fixed;
    right: 20px;
    bottom: 132px;
    max-width: 60vw;
    padding: 6px 10px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 1100;
}
.login-audio-label.muted {
    opacity: 0.65;
}
.login-audio-next {
    position: fixed !important;
    right: 74px;
    bottom: 80px;
    width: 48px;
    height: 48px;
    border-radius: 9999px;
    border: 1px solid var(--input-border);
    background: var(--card-bg) !important;
    color: var(--text-color) !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999 !important;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.login-audio-next:hover {
    filter: brightness(1.03);
    box-shadow: 0 8px 18px rgba(0,0,0,0.12);
}
.login-audio-next svg {
    width: 22px;
    height: 22px;
    display: block;
}
.login-audio-prev {
    position: fixed !important;
    right: 128px;
    bottom: 80px;
    width: 48px;
    height: 48px;
    border-radius: 9999px;
    border: 1px solid var(--input-border);
    background: var(--card-bg) !important;
    color: var(--text-color) !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999 !important;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.login-audio-prev:hover {
    filter: brightness(1.03);
    box-shadow: 0 8px 18px rgba(0,0,0,0.12);
}
.login-audio-prev svg {
    width: 22px;
    height: 22px;
    display: block;
}
.login-audio-list-btn {
    position: fixed !important;
    right: 182px;
    bottom: 80px;
    width: 48px;
    height: 48px;
    border-radius: 9999px;
    border: 1px solid var(--input-border);
    background: var(--card-bg) !important;
    color: var(--text-color) !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999 !important;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.login-audio-list-btn:hover {
    filter: brightness(1.03);
    box-shadow: 0 8px 18px rgba(0,0,0,0.12);
}
.login-audio-playlist-menu {
    position: fixed !important;
    right: 20px;
    bottom: 140px;
    width: 300px;
    max-height: 400px;
    background: var(--card-bg) !important;
    border: 1px solid var(--input-border);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    z-index: 10000 !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.login-audio-playlist-header {
    padding: 12px 16px;
    background: var(--header-bg);
    color: var(--text-color);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--input-border);
}
#loginMusicPlaylistClose {
    background: none;
    border: none;
    color: inherit;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}
.login-audio-playlist-body {
    overflow-y: auto;
    padding: 8px 0;
}
.playlist-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.playlist-item:hover {
    background: rgba(79, 70, 229, 0.1);
}
.playlist-item.active {
    background: rgba(79, 70, 229, 0.15);
    color: var(--primary-color);
    font-weight: 600;
}
.playlist-item-icon {
    opacity: 0.5;
}
.playlist-item.active .playlist-item-icon {
    opacity: 1;
}
.login-audio-vol {
    position: fixed !important;
    right: 236px;
    bottom: 80px;
    width: 160px;
    height: 48px;
    border-radius: 10px;
    border: 1px solid var(--input-border);
    background: var(--card-bg) !important;
    color: var(--text-color) !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 10px;
    z-index: 9999 !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.login-audio-vol input[type="range"] {
    width: 120px;
}

/* Responsividade para Controles de Áudio */
@media (max-width: 600px) {
    .login-audio-vol {
        right: 20px;
        bottom: 140px;
        width: calc(100% - 40px);
        max-width: 300px;
    }
    .login-audio-playlist-menu {
        bottom: 200px;
        width: calc(100% - 40px);
        right: 20px;
    }
    .login-audio-label {
        bottom: 200px;
    }
}

/* New Persistent Audio Player Styles */
.app-footer-fixed {
    justify-content: space-between; /* Alinha o conteúdo do rodapé */
}

.persistent-audio-player {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 10px;
    color: var(--text-color);
    font-size: 14px;
    transition: all 0.3s ease;
    width: auto; /* Ajusta-se ao conteúdo */
    max-width: 500px; /* Limite máximo de largura */
}

.persistent-audio-player.disabled {
    opacity: 0.6;
    pointer-events: none;
}

#pap-controls {
    display: flex;
    gap: 5px;
}

#pap-controls button,
#pap-playlist-toggle {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: background-color 0.2s;
}

#pap-controls button:hover,
#pap-playlist-toggle:hover {
    background: var(--primary-hover);
}

/* Garantir que o botão de playlist seja perfeitamente circular */
#pap-playlist-toggle {
    border-radius: 9999px;
    width: 48px;
    height: 48px;
    padding: 0;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
}

#pap-track-info {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 80px; /* Garante que o título tenha um espaço mínimo */
}

#pap-volume-container {
    display: flex;
    align-items: center;
    gap: 5px;
}

#pap-volume-slider {
    width: 80px;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--input-border);
    outline: none;
    border-radius: 2px;
}

#pap-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 0 2px rgba(0,0,0,0.3);
}

#pap-volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 0 2px rgba(0,0,0,0.3);
}

#pap-volume-icon {
    cursor: pointer;
    font-size: 18px;
}

/* Playlist Menu */
.pap-playlist-menu {
    position: fixed; /* Posição fixa em relação à janela */
    bottom: 55px; /* Altura do rodapé + um pequeno espaço */
    right: 20px; /* Alinhado à direita da página */
    background: var(--card-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    width: 280px;
    max-height: 300px;
    overflow-y: auto;
    display: none; /* Escondido por padrão */
    flex-direction: column;
    z-index: 9998;
}

.pap-playlist-menu.visible {
    display: flex;
}

.pap-playlist-item {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    transition: background 0.2s;
    border-bottom: 1px solid var(--input-border);
}

.pap-playlist-item:last-child {
    border-bottom: none;
}

.pap-playlist-item:hover {
    background: rgba(79, 70, 229, 0.1);
}

.pap-playlist-item.active {
    background: rgba(79, 70, 229, 0.15);
    color: var(--primary-color);
    font-weight: 600;
}

/* Autoplay Checkbox */
#pap-autoplay-container {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: 10px;
}

#pap-autoplay-checkbox {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#pap-autoplay-checkbox:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

#pap-autoplay-checkbox:checked::after {
    content: '✔';
    color: white;
    font-size: 10px;
    line-height: 1;
}

#pap-autoplay-label {
    font-size: 13px;
    cursor: pointer;
}

/* Background Player Toggle */
#pap-background-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-left: 10px;
}

#pap-background-btn {
    background: #ff6b6b;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#pap-background-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

#pap-background-btn.active {
    background: #4CAF50;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

#background-status {
    font-size: 10px;
    color: #666;
    text-align: center;
    line-height: 1;
}

#background-status.online {
    color: #4CAF50;
}

#background-status.offline {
    color: #ff6b6b;
}

/* Responsividade */
@media (max-width: 600px) {
    .persistent-audio-player {
        flex-wrap: wrap;
        justify-content: center;
        padding: 10px;
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: unset;
    }
    #pap-track-info {
        flex-basis: 100%;
        text-align: center;
        margin-top: 5px;
    }
    #pap-volume-container,
    #pap-autoplay-container {
        margin-top: 5px;
    }
    .pap-playlist-menu {
        width: calc(100% - 20px);
        right: 10px;
        left: 10px;
        bottom: calc(100% + 20px);
    }
}

/* Modal Backdrop and Animations (global) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: none !important;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.visible {
    display: flex !important;
    animation: modalFadeIn 160ms ease-out;
}
.modal {
    background: var(--card-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.75rem;
    width: 95%;
    max-width: 1000px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(8px);
}
.modal-overlay.visible .modal {
    animation: modalSlideUp 180ms ease-out forwards;
}
@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
