/* ============================================================
   AuthPack Dashboard – Settings Modal
   ============================================================ */

/* ─── Profile Popup Menu ──────────────────────────────────── */
.sidebar-profile-wrapper {
    position: relative;
}

.sidebar-profile-chevron {
    margin-left: auto;
    flex-shrink: 0;
    color: var(--ap-text-muted);
    transition: transform 0.18s ease;
    opacity: 0.6;
}

#sidebar-profile.menu-open .sidebar-profile-chevron {
    transform: rotate(180deg);
}

.sidebar-profile-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--ap-bg-card);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    padding: 4px;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    pointer-events: none;
}

.sidebar-profile-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: all;
}

.sidebar-profile-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--ap-radius-sm);
    border: none;
    background: transparent;
    color: var(--ap-text-secondary);
    font-size: 13.5px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-profile-menu-item:hover {
    background: var(--ap-bg-hover);
    color: var(--ap-text-primary);
}

.sidebar-profile-menu-item--danger {
    color: var(--ap-danger);
}

.sidebar-profile-menu-item--danger:hover {
    background: var(--ap-danger-light);
    color: var(--ap-danger);
}

.sidebar-profile-menu-divider {
    height: 1px;
    background: var(--ap-border);
    margin: 3px 0;
}

/* ─── Settings Overlay ────────────────────────────────────── */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: var(--ap-bg-overlay);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s;
}

.settings-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* ─── Settings Modal ──────────────────────────────────────── */
.settings-modal {
    display: flex;
    width: 100%;
    max-width: 860px;
    height: min(640px, 90vh);
    background: var(--ap-bg-page);
    border-radius: var(--ap-radius-xl);
    border: 1px solid var(--ap-border);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    transform: scale(0.97) translateY(10px);
    transition: transform 0.22s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.settings-overlay.open .settings-modal {
    transform: scale(1) translateY(0);
}

/* ─── Settings Sidebar ────────────────────────────────────── */
.settings-sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--ap-bg-card);
    border-right: 1px solid var(--ap-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.settings-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 14px 14px;
    border-bottom: 1px solid var(--ap-border);
    flex-shrink: 0;
}

.settings-sidebar-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--ap-text-primary);
    letter-spacing: -0.01em;
}

.settings-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: var(--ap-radius-sm);
    border: none;
    background: transparent;
    color: var(--ap-text-muted);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    flex-shrink: 0;
    padding: 0;
}

.settings-close-btn:hover {
    background: var(--ap-bg-hover);
    color: var(--ap-text-primary);
}

.settings-nav {
    padding: 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--ap-radius-md);
    border: none;
    background: transparent;
    color: var(--ap-text-muted);
    font-size: 13.5px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s ease, color 0.12s ease;
}

.settings-nav-item:hover {
    background: var(--ap-bg-hover);
    color: var(--ap-text-secondary);
}

.settings-nav-item.active {
    background: var(--ap-bg-page);
    color: var(--ap-text-primary);
    font-weight: 600;
}

/* ─── Settings Content ────────────────────────────────────── */
.settings-content {
    flex: 1;
    overflow-y: auto;
    background: var(--ap-bg-page);
}

.settings-view {
    display: none;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
}

.settings-view.active {
    display: flex;
}

.settings-view-header {
    margin-bottom: 2px;
}

.settings-view-header h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--ap-text-primary);
    margin-bottom: 3px;
    letter-spacing: -0.01em;
}

.settings-view-header p {
    font-size: 13px;
    color: var(--ap-text-muted);
    line-height: 1.5;
}

/* ─── Loading ─────────────────────────────────────────────── */
.sc-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
}

/* ─── Settings Cards ──────────────────────────────────────── */
.settings-card {
    background: var(--ap-bg-card);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius-lg);
    overflow: hidden;
}

.settings-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--ap-border);
}

.settings-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--ap-accent-light);
    color: var(--ap-accent);
    flex-shrink: 0;
}

.settings-card-icon--google {
    background: var(--ap-bg-page);
    border: 1px solid var(--ap-border);
}

.settings-card-icon--star {
    background: #fffbeb;
    color: #f59e0b;
}

[data-theme="dark"] .settings-card-icon--star {
    background: rgba(251, 191, 36, 0.1);
}

.settings-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ap-text-primary);
}

.settings-card-body {
    padding: 18px;
}

/* Profile body: stretch to fill card height */
.sc-profile-body {
    display: flex;
    flex-direction: column;
    height: calc(100% - 59px);
}

.sc-full-btn {
    width: 100%;
    margin-top: auto;
    padding: 9px 14px;
    font-size: 13.5px;
    border-radius: var(--ap-radius-md);
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.sc-full-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Reuse dashboard btn styles */
.sc-full-btn.btn-primary {
    background: var(--ap-accent);
    color: #fff;
}

.sc-full-btn.btn-primary:hover:not(:disabled) {
    background: var(--ap-accent-hover);
}

.sc-full-btn.btn-danger {
    background: transparent;
    color: var(--ap-danger);
    border: 1px solid var(--ap-danger-border);
}

.sc-full-btn.btn-danger:hover:not(:disabled) {
    background: var(--ap-danger-light);
}

/* Top row: 2 cards side by side */
.settings-top-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: stretch;
}

.settings-top-row .settings-card {
    display: flex;
    flex-direction: column;
}

.settings-top-row .settings-card .settings-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ─── Google Account Row ──────────────────────────────────── */
.sc-google-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.sc-google-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--ap-border);
    flex-shrink: 0;
}

.sc-google-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sc-google-info {
    flex: 1;
    min-width: 0;
}

.sc-google-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ap-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sc-google-email {
    font-size: 12.5px;
    color: var(--ap-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Plan Card ───────────────────────────────────────────── */
.sc-plan-body {
    height: 100%;
}

.sc-plan-state {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
}

.sc-plan-text {
    font-size: 13.5px;
    color: var(--ap-text-secondary);
}

.sc-plan-text strong {
    color: var(--ap-text-primary);
    font-weight: 700;
}

.sc-plan-sub {
    font-size: 12.5px;
    color: var(--ap-text-muted);
}

.sc-plan-note {
    font-size: 12.5px;
    color: var(--ap-text-muted);
    font-style: italic;
}

.sc-plan-canceled-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--ap-danger);
}

/* ─── Device Rows ─────────────────────────────────────────── */
.device-row {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--ap-border);
    transition: background 0.15s;
    cursor: pointer;
    user-select: none;
}

.device-row:last-child {
    border-bottom: none;
}

.device-row:hover {
    background: var(--ap-bg-hover);
}

.device-row-main {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
}

.device-row-actions {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.28s ease, padding 0.28s ease;
    padding: 0;
}

.device-row--expanded .device-row-actions {
    max-height: 56px;
    padding: 0 12px 12px;
}

.device-type-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--ap-bg-page);
    border: 1px solid var(--ap-border);
    flex-shrink: 0;
    color: var(--ap-text-muted);
}

.device-row-info {
    flex: 1;
    min-width: 0;
}

.device-row-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ap-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-row-meta {
    font-size: 12px;
    color: var(--ap-text-muted);
    margin-top: 1px;
}

.device-row-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: var(--ap-radius-full);
    font-size: 11.5px;
    font-weight: 500;
}

.device-row-badge--current {
    background: var(--ap-accent-light);
    color: var(--ap-accent);
}

.device-row-badge--other {
    background: var(--ap-bg-page);
    color: var(--ap-text-muted);
    border: 1px solid var(--ap-border);
}

.btn-remove-device {
    font-size: 12.5px;
    padding: 5px 12px;
    border-radius: var(--ap-radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 700px) {
    .settings-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .settings-modal {
        max-width: 100%;
        width: 100%;
        height: 92vh;
        border-radius: var(--ap-radius-xl) var(--ap-radius-xl) 0 0;
        flex-direction: column;
    }

    .settings-sidebar {
        width: 100%;
        flex-direction: row;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--ap-border);
        flex-shrink: 0;
    }

    .settings-sidebar-header {
        border-bottom: none;
        padding: 14px 14px;
    }

    .settings-nav {
        flex-direction: row;
        padding: 8px 8px 8px 0;
        flex: 1;
    }

    .settings-nav-item {
        padding: 7px 12px;
        white-space: nowrap;
    }

    .settings-top-row {
        grid-template-columns: 1fr;
    }
}
