/* ═══════════════════════════════════════════════════════
   Account Panel — Slide-out drawer from right
   ═══════════════════════════════════════════════════════ */

/* Overlay */
.account-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.account-panel-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Panel Container */
.account-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bg-primary, #030014);
    border-left: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.4);
}

.account-panel.active {
    transform: translateX(0);
}

body.light-theme .account-panel {
    background: #fdfcff;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.12);
}

/* Close Button */
.ap-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    z-index: 2;
}

.ap-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    transform: rotate(90deg);
}

body.light-theme .ap-close {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.08);
    color: #94a3b8;
}

body.light-theme .ap-close:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #334155;
}

/* Profile Header */
.ap-profile {
    padding: 32px 24px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.ap-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent, #8b5cf6), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 14px;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.35);
    position: relative;
}

.ap-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.ap-avatar .ap-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--success, #10b981);
    border: 3px solid var(--bg-primary, #030014);
}

body.light-theme .ap-avatar .ap-status-dot {
    border-color: #fdfcff;
}

.ap-user-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.ap-user-email {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    word-break: break-all;
}

.ap-plan-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.ap-plan-badge.free {
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent);
    border: 1px solid rgba(139, 92, 246, 0.25);
}

.ap-plan-badge.pro {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.15));
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Scrollable Content Area */
.ap-content {
    flex: 1;
    min-height: 0; /* critical for flex scroll */
    overflow-y: auto;
    padding: 20px 24px;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}

.ap-content::-webkit-scrollbar {
    width: 5px;
}

.ap-content::-webkit-scrollbar-track {
    background: transparent;
}

.ap-content::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 3px;
}

.ap-content::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}

/* Section Headers */
.ap-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ap-section-title.ap-collapsible {
    justify-content: space-between;
    cursor: pointer;
    transition: color 0.2s ease;
    -webkit-user-select: none;
    user-select: none;
}

.ap-section-title.ap-collapsible:hover {
    color: var(--text-primary);
}

.ap-section-title-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ap-toggle-icon {
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ap-toggle-icon.rotated {
    transform: rotate(-180deg);
}

.ap-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, margin-bottom 0.3s ease;
    opacity: 0;
}

.ap-section-content.expanded {
    max-height: 1000px; /* arbitrary large value for animation */
    opacity: 1;
}

.ap-section-title i {
    font-size: 1rem;
    color: var(--accent);
}

body.light-theme .ap-section-title {
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

/* Document History Cards */
.ap-doc-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 28px;
}

.ap-doc-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: all 0.2s ease;
    cursor: default;
}

.ap-doc-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(139, 92, 246, 0.2);
}

.ap-doc-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.ap-doc-icon.fax {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.ap-doc-icon.pdf {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.ap-doc-icon.pending {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.ap-doc-icon.failed {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.ap-doc-info {
    flex: 1;
    min-width: 0;
}

.ap-doc-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ap-doc-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ap-doc-method {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ap-doc-method.fax {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.ap-doc-method.pdf {
    background: rgba(99, 102, 241, 0.12);
    color: #818cf8;
}

.ap-doc-method.post {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.ap-doc-status {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.ap-doc-status.delivered {
    color: var(--success);
}

.ap-doc-status.pending {
    color: var(--warning);
}

.ap-doc-status.failed {
    color: var(--danger);
}

.ap-doc-date {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.ap-doc-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.ap-doc-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.ap-doc-btn:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.ap-doc-btn i {
    font-size: 0.85rem;
}

/* Empty state */
.ap-empty {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-muted);
}

.ap-empty i {
    font-size: 2.5rem;
    margin-bottom: 10px;
    opacity: 0.3;
    display: block;
}

.ap-empty p {
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Account Actions Section */
.ap-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 20px;
}

.ap-action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.ap-action-btn i {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.ap-action-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.ap-action-btn:hover i {
    color: var(--accent);
}

/* ── Light Theme — Document Cards ────────────────────────────────── */
body.light-theme .ap-doc-card {
    background: #fff;
    border: 1px solid #d1d5db;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

body.light-theme .ap-doc-card:hover {
    background: #f9fafb;
    border-color: #8b5cf6;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.1);
}

body.light-theme .ap-doc-btn {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #374151;
}

body.light-theme .ap-doc-btn:hover {
    background: #ede9fe;
    border-color: #8b5cf6;
    color: #7c3aed;
}

body.light-theme .ap-doc-title {
    color: #111827;
}

body.light-theme .ap-doc-date {
    color: #6b7280;
}

body.light-theme .ap-doc-status {
    color: #6b7280;
}

body.light-theme .ap-doc-method.pdf {
    background: rgba(99, 102, 241, 0.08);
    color: #6366f1;
}

body.light-theme .ap-doc-method.fax {
    background: rgba(16, 185, 129, 0.08);
    color: #059669;
}

body.light-theme .ap-doc-method.post,
body.light-theme .ap-doc-method.einschreiben {
    background: rgba(139, 92, 246, 0.08);
    color: #7c3aed;
}

body.light-theme .ap-action-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

.ap-action-btn.danger {
    color: var(--danger);
}

.ap-action-btn.danger i {
    color: var(--danger);
}

.ap-action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.08);
}

/* Footer / Logout in Panel */
.ap-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.ap-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.06);
    color: #ef4444;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ap-logout-btn:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    transform: translateY(-1px);
}

.ap-logout-btn i {
    font-size: 1.1rem;
}

/* Avatar clickable indicator */
.sidebar-footer .user-avatar {
    cursor: pointer;
    transition: all 0.25s ease;
}

.sidebar-footer .user-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 0 16px rgba(139, 92, 246, 0.4);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .account-panel {
        width: 100vw;
        max-width: 100vw;
    }
}

/* ── Personal Data Form ────────────────────────────── */
.ap-autofill-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: -6px 0 10px;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Completeness Progress Bar */
.ap-completeness {
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.ap-completeness-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#ap-completeness-pct {
    color: var(--accent);
    font-weight: 700;
}

.ap-completeness-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.ap-completeness-fill {
    height: 100%;
    width: 0;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
}

.ap-completeness-fill.complete {
    background: var(--success);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.ap-personal-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.ap-field-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ap-field-group label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.ap-span-2 {
    grid-column: span 2;
}

.ap-field-narrow {
    max-width: 100px;
}

.ap-optional-tag {
    font-size: 0.65rem;
    font-weight: 400;
    opacity: 0.6;
    text-transform: none;
    letter-spacing: 0;
}

.ap-input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-family: inherit;
    transition: all 0.2s ease;
    outline: none;
    box-sizing: border-box;
}

.ap-input::placeholder {
    color: var(--text-muted);
    opacity: 0.4;
}

.ap-input:focus {
    border-color: var(--accent, #8b5cf6);
    background: rgba(139, 92, 246, 0.06);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.ap-input:invalid {
    border-color: var(--danger, #ef4444) !important;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15) !important;
}

.ap-input:invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25) !important;
}

body.light-theme .ap-input {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1e293b;
}

body.light-theme .ap-input::placeholder {
    color: #64748b;
    opacity: 0.8;
}

body.light-theme .ap-input:focus {
    background: rgba(139, 92, 246, 0.04);
    border-color: var(--accent);
}

/* Save Button */
.ap-save-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 9px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--accent, #8b5cf6), #6366f1);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-bottom: 20px;
}

.ap-save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.35);
    filter: brightness(1.08);
}

.ap-save-btn:active {
    transform: translateY(0);
}

.ap-save-btn.saved {
    background: linear-gradient(135deg, #10b981, #059669);
    pointer-events: none;
}

.ap-save-btn i {
    font-size: 1.1rem;
}

/* ── Receipt Cards ─────────────────────────────────── */
.ap-receipt-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 28px;
}

.ap-receipt-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.ap-receipt-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(139, 92, 246, 0.2);
}

.ap-receipt-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    background: rgba(16, 185, 129, 0.12);
    color: var(--success, #10b981);
}

.ap-receipt-icon.fax { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.ap-receipt-icon.post { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.ap-receipt-icon.pdf { background: rgba(99, 102, 241, 0.12); color: #818cf8; }

.ap-receipt-info {
    flex: 1;
    min-width: 0;
}

.ap-receipt-title {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ap-receipt-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.ap-receipt-amount {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(139, 92, 246, 0.1);
    padding: 4px 10px;
    border-radius: 8px;
    white-space: nowrap;
}

.ap-receipt-status {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 8px;
    border-radius: 6px;
}

.ap-receipt-status.paid {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

/* Pulse animation for pending status */
@keyframes ap-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.ap-doc-status.pending {
    animation: ap-pulse 2s ease-in-out infinite;
}

/* ── Confirm Dialog (`css/account-panel.css`) ── */
.ap-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.ap-confirm-overlay.active {
    opacity: 1;
    visibility: visible;
}

.ap-confirm-box {
    background: var(--bg-card, #0f111a);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 20px;
    width: 320px;
    padding: 24px;
    text-align: center;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(139, 92, 246, 0.2);
}

.ap-confirm-overlay.active .ap-confirm-box {
    transform: scale(1) translateY(0);
}

.ap-confirm-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.ap-confirm-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary, #fff);
    margin-bottom: 8px;
}

.ap-confirm-text {
    font-size: 0.85rem;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 24px;
    line-height: 1.5;
}

.ap-confirm-actions {
    display: flex;
    gap: 12px;
}

.ap-confirm-btn {
    flex: 1;
    padding: 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.ap-confirm-cancel {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary, #cbd5e1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ap-confirm-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.ap-confirm-delete {
    background: #ef4444;
    color: #fff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.ap-confirm-delete:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

body.light-theme .ap-confirm-box {
    background: #fff;
    border-color: #e5e7eb;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(139, 92, 246, 0.1);
}

body.light-theme .ap-confirm-title { color: #1e293b; }
body.light-theme .ap-confirm-text { color: #64748b; }
body.light-theme .ap-confirm-cancel {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
}
body.light-theme .ap-confirm-cancel:hover {
    background: #e2e8f0;
    color: #0f172a;
}
