/* ChloeOS — Top Panel & Taskbar */

#panel {
    height: var(--panel-height);
    background: var(--panel-bg);
    border-bottom: 1px solid var(--ctp-surface0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    z-index: 1000;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#panel-left {
    display: flex;
    align-items: center;
    gap: 4px;
}

#panel-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-weight: bold;
    font-size: 13px;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

#panel-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Panel button */
.panel-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    font-size: 18px;
    transition: background 0.15s, color 0.15s;
}
.panel-btn:hover {
    background: var(--ctp-surface0);
    color: var(--accent-blue);
}

/* Workspace switcher */
#workspace-switcher {
    display: flex;
    gap: 2px;
}

.workspace-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-size: 12px;
    transition: all 0.15s;
    border-bottom: 2px solid transparent;
}
.workspace-btn:hover {
    background: var(--ctp-surface0);
    color: var(--text-primary);
}
.workspace-btn.active {
    color: var(--accent-blue);
    background: var(--ctp-surface0);
    border-bottom-color: var(--accent-pink);
}
.workspace-btn .material-symbols-outlined {
    font-size: 16px;
}
.workspace-label {
    font-size: 11px;
}

/* System tray */
#system-tray {
    display: flex;
    gap: 6px;
    align-items: center;
}
.tray-icon {
    font-size: 16px;
    color: var(--text-dim);
    cursor: default;
}
.tray-icon.tray-clickable {
    cursor: pointer;
    transition: color 0.15s;
}
.tray-icon.tray-clickable:hover {
    color: var(--accent-pink);
}

/* Clock */
#panel-clock {
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 48px;
    text-align: right;
}

/* Taskbar (bottom) */
#taskbar {
    height: var(--taskbar-height);
    background: var(--panel-bg);
    border-top: 1px solid var(--ctp-surface0);
    display: flex;
    align-items: center;
    padding: 0 8px;
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
}

#taskbar-windows {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    flex: 1;
}

.taskbar-entry {
    background: var(--ctp-surface0);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-size: 11px;
    white-space: nowrap;
    transition: all 0.15s;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.taskbar-entry:hover {
    background: var(--ctp-surface1);
}
.taskbar-entry.active {
    background: var(--ctp-surface1);
    color: var(--accent-blue);
    border-bottom: 2px solid var(--accent-pink);
}
.taskbar-entry .material-symbols-outlined {
    font-size: 14px;
}

/* Context menu */
#context-menu {
    position: absolute;
    background: var(--ctp-mantle);
    border: 1px solid var(--ctp-surface1);
    border-radius: var(--border-radius);
    padding: 4px 0;
    min-width: 180px;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.ctx-item {
    padding: 8px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-primary);
    transition: background 0.1s;
}
.ctx-item:hover {
    background: var(--ctp-surface0);
    color: var(--accent-blue);
}
.ctx-item .material-symbols-outlined {
    font-size: 16px;
    width: 20px;
    text-align: center;
}
.ctx-separator {
    height: 1px;
    background: var(--ctp-surface1);
    margin: 4px 8px;
}

/* App launcher menu */
#app-menu {
    position: absolute;
    top: var(--panel-height);
    left: 8px;
    background: var(--ctp-mantle);
    border: 1px solid var(--ctp-surface1);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    min-width: 220px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 9998;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.app-menu-header {
    padding: 10px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-pink);
    border-bottom: 1px solid var(--ctp-surface0);
    font-weight: bold;
}
.app-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-primary);
    transition: background 0.1s;
}
.app-menu-item:hover {
    background: var(--ctp-surface0);
    color: var(--accent-blue);
}
.app-menu-item .material-symbols-outlined {
    font-size: 18px;
    color: var(--accent-blue);
}
.app-menu-category {
    padding: 6px 16px 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-top: 4px;
}
.app-menu-separator {
    height: 1px;
    background: var(--ctp-surface1);
    margin: 4px 8px;
}

/* ─── Companion ─── */

#companion {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding: 0 6px;
    overflow: visible;
}

.companion-bubble {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background: var(--ctp-mantle);
    border: 1px solid var(--ctp-surface1);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 11px;
    color: var(--ctp-text);
    width: 350px;
    max-width: 540px;
    white-space: normal;
    text-align: center;
    line-height: 1.4;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
    z-index: 10001;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px) scale(0.95);
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.companion-bubble.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.companion-bubble.streaming > span:first-child::after {
    content: '▍';
    margin-left: 2px;
    color: var(--accent-blue);
    animation: companion-cursor 0.7s steps(1) infinite;
}
@keyframes companion-cursor { 50% { opacity: 0; } }
.companion-bubble.has-actions {
    pointer-events: auto;
}
.companion-bubble-actions {
    display: none;
    gap: 6px;
    justify-content: center;
    margin-top: 7px;
}
.companion-bubble.has-actions .companion-bubble-actions {
    display: flex;
}
.companion-btn {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    padding: 3px 9px;
    border-radius: 4px;
    border: 1px solid var(--ctp-surface1);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.companion-btn-yes {
    background: #89b4fa;
    color: #11111b !important;
    border-color: #89b4fa;
}
.companion-btn-yes:hover { background: #5b8cd4; border-color: #5b8cd4; }
.companion-btn-no {
    background: var(--ctp-surface0);
    color: var(--ctp-subtext1);
}
.companion-btn-no:hover { background: var(--ctp-surface1); color: var(--ctp-text); }
.companion-bubble::after {
    content: '';
    position: absolute;
    bottom: -5px;
    right: 12px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--ctp-mantle);
}

/* Cat sprite */
.companion-sprite {
    position: relative;
    width: 42px;
    height: 38px;
    cursor: pointer;
    overflow: visible;
    flex-shrink: 0;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}
.companion-sprite:hover { transform: scale(1.08); }
.companion-sprite:active { transform: scale(0.93); }

/* Ears */
.companion-ear {
    position: absolute;
    top: -9px;
    width: 12px;
    height: 12px;
    background: var(--ctp-subtext1);
    z-index: 2;
    shape-rendering: crispEdges;
}
.companion-ear::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 8px;
    height: 8px;
    background: var(--accent-pink);
    opacity: 0.7;
}
.companion-ear.left  { left: 3px;  clip-path: polygon(0 100%, 50% 0, 100% 100%); }
.companion-ear.right { right: 3px; clip-path: polygon(0 100%, 50% 0, 100% 100%); }
.companion-ear.left::before  { clip-path: polygon(0 100%, 50% 0, 100% 100%); }
.companion-ear.right::before { clip-path: polygon(0 100%, 50% 0, 100% 100%); }

/* Face */
.companion-face {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 36px;
    height: 30px;
    background: var(--ctp-subtext1);
    border-radius: 6px;
    overflow: visible;
    shape-rendering: crispEdges;
}

/* Eyes */
.companion-eye {
    position: absolute;
    top: 9px;
    width: 7px;
    height: 7px;
    background: var(--ctp-crust);
    border-radius: 2px;
    transform-origin: center center;
    transition: width 0.1s, height 0.1s, top 0.1s, border-radius 0.1s, background 0.1s;
}
.companion-eye.left  { left: 7px;  }
.companion-eye.right { right: 7px; }
.companion-eye::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: 3px;
    height: 3px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 1px;
}

/* Blush */
.companion-blush {
    position: absolute;
    top: 17px;
    width: 9px;
    height: 5px;
    background: var(--accent-pink);
    opacity: 0.35;
    border-radius: 2px;
}
.companion-blush.left  { left: 2px;  }
.companion-blush.right { right: 2px; }

/* Nose */
.companion-nose {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 3px;
    background: var(--accent-pink);
    border-radius: 1px;
}

/* Mouth */
.companion-mouth {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 4px;
    border-bottom: 2px solid var(--ctp-crust);
    border-left: 2px solid var(--ctp-crust);
    border-right: 2px solid var(--ctp-crust);
    border-radius: 0 0 3px 3px;
    opacity: 0.6;
}

/* Tail */
.companion-tail {
    position: absolute;
    bottom: 7px;
    right: -3px;
    width: 7px;
    height: 16px;
    background: var(--ctp-subtext1);
    border-radius: 3px;
    transform-origin: 50% 100%;
    animation: companion-tail 2.8s ease-in-out infinite;
    shape-rendering: crispEdges;
}
@keyframes companion-tail {
    0%, 100% { transform: rotate(-12deg); }
    50%       { transform: rotate(14deg); }
}

/* ── State: idle — periodic blink ── */
.companion-sprite.state-idle .companion-eye {
    animation: companion-blink 5s ease-in-out infinite;
}
.companion-sprite.state-idle .companion-eye.right {
    animation-delay: 0.12s;
}
@keyframes companion-blink {
    0%, 86%, 100% { transform: scaleY(1); }
    90%, 96%      { transform: scaleY(0.1); }
}

/* ── State: happy — ^_^ eyes, little bounce ── */
.companion-sprite.state-happy .companion-eye {
    animation: none;
    height: 3px;
    top: 10px;
    background: transparent;
    border-top: 2.5px solid var(--ctp-crust);
    border-radius: 1px 1px 0 0;
    transform: scaleY(1) !important;
}
.companion-sprite.state-happy .companion-eye::after { display: none; }
.companion-sprite.state-happy .companion-face {
    animation: companion-happy-bounce 0.3s ease-in-out 3;
}
@keyframes companion-happy-bounce {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-3px); }
}

/* ── State: surprised — O_O eyes, open mouth ── */
.companion-sprite.state-surprised .companion-eye {
    animation: none;
    width: 9px;
    height: 9px;
    top: 7px;
    border-radius: 2px;
    transform: scaleY(1) !important;
}
.companion-sprite.state-surprised .companion-eye.left  { left: 5px;  }
.companion-sprite.state-surprised .companion-eye.right { right: 5px; }
.companion-sprite.state-surprised .companion-eye::after {
    width: 4px;
    height: 4px;
    top: 1px;
    left: 1px;
}
.companion-sprite.state-surprised .companion-mouth {
    top: 22px;
    width: 7px;
    height: 6px;
    border: 2px solid var(--ctp-crust);
    border-radius: 2px;
    opacity: 0.7;
}

/* ── State: music — bopping, blocky eyes ── */
.companion-sprite.state-music {
    animation: companion-bop 0.48s ease-in-out infinite alternate;
}
.companion-sprite.state-music .companion-eye {
    animation: none;
    border-radius: 1px;
    transform: scaleY(1) !important;
}
.companion-sprite.state-music .companion-tail {
    animation: companion-tail-fast 0.42s ease-in-out infinite alternate;
}
@keyframes companion-bop {
    from { transform: translateY(0); }
    to   { transform: translateY(-3px); }
}
@keyframes companion-tail-fast {
    from { transform: rotate(-20deg); }
    to   { transform: rotate(22deg); }
}

/* ── State: sleepy — half-closed eyes, Zzz ── */
.companion-sprite.state-sleepy .companion-eye {
    animation: none;
    height: 2px;
    top: 11px;
    border-radius: 1px;
    transform: scaleY(1) !important;
}
.companion-sprite.state-sleepy .companion-face::after {
    content: 'z';
    position: absolute;
    top: -2px;
    right: -9px;
    font-size: 9px;
    color: var(--accent-blue);
    font-family: 'Share Tech Mono', monospace;
    font-style: italic;
    animation: companion-zzz 2s ease-in-out infinite;
}
@keyframes companion-zzz {
    0%   { opacity: 0; transform: translate(0, 0) scale(0.8); }
    30%  { opacity: 1; }
    100% { opacity: 0; transform: translate(4px, -10px) scale(1.3); }
}
.companion-sprite.state-sleepy .companion-tail {
    animation: companion-tail 6s ease-in-out infinite;
}
.companion-sprite.state-sleepy .companion-mouth {
    border-bottom: 0;
    border-left: 0;
    border-right: 0;
    border-top: 2px solid var(--ctp-crust);
    width: 10px;
    height: 0;
    border-radius: 1px;
    top: 22px;
    opacity: 0.4;
}

/* Mobile — hide companion on very small screens */
@media (max-width: 480px) {
    #companion { display: none; }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .workspace-label {
        display: none;
    }
    .workspace-btn {
        padding: 4px 8px;
    }
    #panel-center {
        display: none;
    }
    #system-tray {
        display: none;
    }
    .taskbar-entry {
        max-width: 120px;
    }
}
