/* Custom Title Bar for Tauri */
:root {
    --titlebar-offset: 0px;
    --tauri-topbar-height: 40px;
}

#tauri-titlebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--tauri-topbar-height);
    background: var(--header-bg);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border-bottom: 1px solid var(--grid-color);
    display: none;
    align-items: center;
    gap: 8px;
    padding: 0 8px 0 12px;
    z-index: var(--z-header);
    user-select: none;
    -webkit-user-select: none;
    transform-origin: top left;
    -webkit-app-region: drag;
}

.titlebar-drag-region {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 80px;
}

.titlebar-icon {
    width: 18px;
    height: 18px;
}

.titlebar-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.titlebar-controls {
    height: 100%;
    display: flex;
    align-items: stretch;
    margin-left: 4px;
    -webkit-app-region: no-drag;
}

.titlebar-btn {
    width: 42px;
    height: 100%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.titlebar-btn:hover {
    background: rgba(128, 128, 128, 0.14);
    color: var(--text-primary);
}

.titlebar-close:hover {
    background: #e81123;
    color: #fff;
}

.tauri-merged-left,
.tauri-merged-right,
.tauri-merged-center {
    display: none;
    align-items: center;
    min-height: 100%;
    -webkit-app-region: no-drag;
}

.tauri-merged-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    justify-content: center;
    min-width: 0;
    max-width: 50%;
    overflow: hidden;
    pointer-events: none;
}

.tauri-merged-center > * {
    pointer-events: auto;
}

.tauri-merged-spacer {
    display: none;
    flex: 1;
    min-width: 36px;
    height: 100%;
}

body.tauri-merged-topbar #app-header {
    display: none !important;
}

body.tauri-merged-topbar #tauri-titlebar {
    height: 40px;
    gap: 6px;
    padding: 0 6px 0 10px;
}

body.tauri-merged-topbar #tauri-titlebar .titlebar-drag-region {
    display: none;
}

body.tauri-merged-topbar #tauri-titlebar .tauri-merged-left,
body.tauri-merged-topbar #tauri-titlebar .tauri-merged-right,
body.tauri-merged-topbar #tauri-titlebar .tauri-merged-center {
    display: flex;
}

body.tauri-merged-topbar #tauri-titlebar .tauri-merged-spacer {
    display: block;
    -webkit-app-region: drag;
}

body.tauri-merged-topbar #tauri-titlebar .tauri-merged-right {
    margin-left: auto;
}

body.tauri-merged-topbar #tauri-titlebar .header-left,
body.tauri-merged-topbar #tauri-titlebar .header-right {
    display: flex;
    align-items: center;
}

body.tauri-merged-topbar #tauri-titlebar .header-left {
    gap: 6px;
}

body.tauri-merged-topbar #tauri-titlebar .header-right {
    gap: 8px;
}

body.tauri-merged-topbar #tauri-titlebar .header-left .icon {
    width: 24px !important;
    height: 24px !important;
    cursor: default !important;
}

body.tauri-merged-topbar #tauri-titlebar .header-right > div:last-child {
    margin-left: 0 !important;
}

body.tauri-merged-topbar #tauri-titlebar .menu-txt {
    padding: 5px 10px;
    font-size: 0.86rem;
    border-radius: var(--radius-sm);
    -webkit-app-region: no-drag;
}

body.tauri-merged-topbar #tauri-titlebar .presence-bar {
    margin-right: 0;
}

body.tauri-merged-topbar #tauri-titlebar .presence-bar .presence-avatar,
body.tauri-merged-topbar #tauri-titlebar .presence-bar .presence-more {
    width: 24px;
    height: 24px;
    border-width: 1px;
    margin-left: -6px;
}

body.tauri-merged-topbar #tauri-titlebar .cloud-account-btn {
    width: 30px;
    height: 30px;
}

body.tauri-merged-topbar #tauri-titlebar .cloud-badge-disc {
    right: -1px;
    bottom: -1px;
}

/* Project title in merged Tauri titlebar - override absolute positioning */
body.tauri-merged-topbar #tauri-titlebar .header-center {
    position: static;
    transform: none;
    pointer-events: auto;
}

body.tauri-merged-topbar #tauri-titlebar .project-title-chip {
    min-height: 28px;
    padding: 4px 10px;
    font-size: 0.78rem;
    max-width: min(40vw, 360px);
}

/* ─── Update Ready Button ─── */
.update-ready-btn {
    border-color: #22c55e !important;
    background: rgba(34, 197, 94, 0.1) !important;
    animation: update-pulse 2s ease-in-out infinite;
    -webkit-app-region: no-drag;
}

.update-ready-btn:hover {
    background: rgba(34, 197, 94, 0.25) !important;
    border-color: #16a34a !important;
}

@keyframes update-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

/* ─── Update Dialog ─── */
.update-dialog {
    max-width: 480px;
    width: 90vw;
    border-radius: 12px;
    overflow: hidden;
}

.update-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.update-dialog-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.update-dialog-body {
    padding: 16px 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.update-dialog-image {
    margin: 0 -20px 16px -20px;
}

.update-dialog-image img {
    width: 100%;
    display: block;
    max-height: 220px;
    object-fit: cover;
}

.update-dialog-version {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--accent-subtle, rgba(59, 130, 246, 0.1));
    color: var(--accent-color);
    margin-bottom: 14px;
}

.update-dialog-section {
    margin-bottom: 14px;
}

.update-dialog-section-title {
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.update-dialog-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 3px 0;
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.update-dialog-icon {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.update-dialog-notes {
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--bg-secondary, rgba(0,0,0,0.04));
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 8px;
}

.update-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
}

.update-dialog-btn {
    padding: 7px 18px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: all 0.15s;
}

.update-dialog-btn.secondary {
    background: transparent;
    color: var(--text-secondary);
}

.update-dialog-btn.secondary:hover {
    background: var(--bg-secondary);
}

.update-dialog-btn.primary {
    background: #22c55e;
    color: #fff;
    border-color: #16a34a;
}

.update-dialog-btn.primary:hover {
    background: #16a34a;
}

.update-dialog-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
