/* PumpPetsAI - Modern Virtual Pet Styling */

/* CSS Custom Properties - Retro Color Palette */
:root {
    --ink: #000000;
    --paper: #F4F4F4;
    --gray: #D3D3D3;
    --dark: #8A8A8A;
    --border: #000000;
    --shadow: rgba(0, 0, 0, 0.3);
    --highlight: rgba(255, 255, 255, 0.5);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 12px;
    line-height: 1.4;
    background: var(--paper);
    color: var(--ink);
    overflow-x: hidden;
    
    /* Subtle 1-bit dither background */
    background-image: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 1px,
            rgba(0, 0, 0, 0.02) 1px,
            rgba(0, 0, 0, 0.02) 2px
        );
}

/* Typography */
h1, h2, h3 {
    font-family: 'Press Start 2P', 'ChicagoFLF', monospace;
    font-weight: normal;
    line-height: 1.2;
}

h1 { font-size: 10px; }
h2 { font-size: 9px; }
h3 { font-size: 8px; }

/* Top Bar */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 32px;
    background: var(--paper);
    border-bottom: 1px solid var(--ink);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 1000;
    box-shadow: 0 1px 0 var(--highlight) inset;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mac-logo {
    width: 20px;
    height: 20px;
    color: var(--ink);
}

.logo-text {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    color: var(--ink);
}

.top-bar-right {
    display: flex;
    gap: 4px;
}

.top-btn {
    width: 24px;
    height: 24px;
    background: var(--gray);
    border: 1px solid var(--ink);
    border-radius: 0;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 1px 1px 0 var(--highlight) inset, -1px -1px 0 var(--dark) inset;
}

.top-btn:hover {
    background: var(--paper);
}

.top-btn:active {
    box-shadow: -1px -1px 0 var(--highlight) inset, 1px 1px 0 var(--dark) inset;
    transform: translate(1px, 1px);
}

/* Main Layout - Centered Pet with Compact Chat */
.main-content {
    margin-top: 32px;
    padding: 24px;
    min-height: calc(100vh - 32px - 60px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 24px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.pet-container {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.chat-sidebar {
    flex: 0 0 320px;
    max-width: 320px;
}

@media (max-width: 959px) {
    .main-content {
        flex-direction: column;
        align-items: center;
        gap: 16px;
        padding: 16px;
    }
    
    .chat-sidebar {
        flex: 0 0 auto;
        width: 100%;
        max-width: 400px;
    }
}

/* Window Styling */
.window {
    background: var(--paper);
    border: 1px solid var(--ink);
    box-shadow: 1px 1px 0 var(--highlight) inset, -1px -1px 0 var(--dark) inset;
    display: flex;
    flex-direction: column;
    min-height: 400px;
    position: relative;
}

.window-titlebar {
    background: var(--paper);
    border-bottom: 1px solid var(--ink);
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    background-image: repeating-linear-gradient(
        90deg,
        var(--ink),
        var(--ink) 1px,
        transparent 1px,
        transparent 3px
    );
    position: relative;
}

.window-titlebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--paper);
    opacity: 0.85;
}

.window-controls {
    display: flex;
    gap: 4px;
    position: relative;
    z-index: 1;
}

.control-dot {
    width: 8px;
    height: 8px;
    background: var(--ink);
    border-radius: 0;
    display: block;
}

.window-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    color: var(--ink);
    position: relative;
    z-index: 1;
    text-shadow: 1px 1px 0 var(--paper);
}

.window-content {
    flex: 1;
    padding: 12px;
    background: var(--paper);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Tamagotchi Frame Styles */
.tamagotchi-frame {
    background: linear-gradient(145deg, #2c2c2c, #1a1a1a);
    border: 3px solid #000;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 
        0 8px 16px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
    position: relative;
    min-width: 400px;
}

.frame-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.frame-lights {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.light {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid #000;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.light.red { background: #ff4444; }
.light.yellow { background: #ffaa00; }
.light.green { background: #44ff44; }

.frame-screen {
    background: #000;
    border: 4px solid #333;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.5),
        0 2px 4px rgba(0, 0, 0, 0.3);
}

.screen-border {
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 4px;
    padding: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.frame-controls {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}

.control-button {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(145deg, #444, #222);
    border: 2px solid #000;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.1s ease;
}

.control-button:hover {
    background: linear-gradient(145deg, #555, #333);
    transform: translateY(-1px);
}

.control-button:active {
    background: linear-gradient(145deg, #333, #111);
    transform: translateY(1px);
    box-shadow: 
        0 1px 2px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.control-button.pressed {
    background: linear-gradient(145deg, #222, #000);
    transform: translateY(2px);
    box-shadow: 
        0 0 1px rgba(0, 0, 0, 0.5),
        inset 0 3px 6px rgba(0, 0, 0, 0.5);
    animation: buttonPress 0.3s ease;
}

@keyframes buttonPress {
    0% { transform: translateY(-1px); }
    50% { transform: translateY(2px); }
    100% { transform: translateY(0px); }
}

.frame-bottom {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pet-hud {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.pet-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* Game Window Styles */
.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    height: 100%;
}

#gameCanvas {
    border: 2px solid var(--ink);
    background: var(--paper);
    max-width: 100%;
    height: auto;
    aspect-ratio: 1;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.game-hud {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
}

.hud-label {
    color: var(--dark);
}

#speedSelect {
    background: var(--paper);
    border: 1px solid var(--ink);
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    padding: 2px 4px;
    cursor: pointer;
}

.game-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.game-btn {
    background: var(--gray);
    border: 1px solid var(--ink);
    padding: 6px 12px;
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    cursor: pointer;
    box-shadow: 1px 1px 0 var(--highlight) inset, -1px -1px 0 var(--dark) inset;
}

.game-btn:hover {
    background: var(--paper);
}

.game-btn:active {
    box-shadow: -1px -1px 0 var(--highlight) inset, 1px 1px 0 var(--dark) inset;
    transform: translate(1px, 1px);
}

.wrap-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    cursor: pointer;
}

.wrap-toggle input[type="checkbox"] {
    width: 12px;
    height: 12px;
    margin: 0;
    cursor: pointer;
}

.game-instructions {
    text-align: center;
    font-size: 10px;
    color: var(--dark);
    line-height: 1.3;
}

/* Pet Action Buttons */
.pet-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 12px 0;
    padding: 8px;
    background: var(--gray);
    border: 1px solid var(--ink);
    border-radius: 4px;
}

.pet-btn {
    background: var(--paper);
    border: 1px solid var(--ink);
    border-radius: 2px;
    padding: 6px 8px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 7px;
    color: var(--ink);
    cursor: pointer;
    transition: all 0.1s ease;
    text-align: center;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.pet-btn:hover {
    background: var(--gray);
    transform: translateY(-1px);
}

.pet-btn:active {
    transform: translateY(1px);
    background: var(--dark);
    color: var(--paper);
}

.pet-btn:focus-visible {
    outline: 1px solid var(--ink);
    outline-offset: 2px;
}

/* Chat Window Styles - Compact */
.chat-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 8px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    border: 2px solid var(--ink);
    background: var(--paper);
    box-shadow: -1px -1px 0 var(--highlight) inset, 1px 1px 0 var(--dark) inset;
    min-height: 150px;
    max-height: 200px;
    font-family: 'Inter', monospace;
    font-size: 10px;
    line-height: 1.3;
}

.chat-message {
    margin-bottom: 12px;
    padding: 8px;
    border-radius: 0;
}

.chat-message.user {
    background: var(--gray);
    border: 1px solid var(--dark);
    margin-left: 20px;
    box-shadow: 1px 1px 0 var(--highlight) inset;
}

.chat-message.assistant {
    background: var(--paper);
    border: 1px solid var(--ink);
    margin-right: 20px;
    box-shadow: 1px 1px 0 var(--highlight) inset, -1px -1px 0 var(--dark) inset;
}

.chat-message.system {
    background: var(--dark);
    color: var(--paper);
    border: 1px solid var(--ink);
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    text-align: center;
}

.message-timestamp {
    font-size: 9px;
    color: var(--dark);
    margin-bottom: 4px;
}

.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

#chatInput {
    flex: 1;
    padding: 6px;
    border: 2px solid var(--ink);
    background: var(--paper);
    font-family: 'Inter', monospace;
    font-size: 10px;
    box-shadow: -1px -1px 0 var(--highlight) inset, 1px 1px 0 var(--dark) inset;
}

#chatInput:focus {
    outline: 1px solid var(--ink);
    outline-offset: 1px;
}

.chat-btn {
    background: var(--gray);
    border: 1px solid var(--ink);
    padding: 6px 8px;
    font-family: 'Press Start 2P', monospace;
    font-size: 6px;
    cursor: pointer;
    box-shadow: 1px 1px 0 var(--highlight) inset, -1px -1px 0 var(--dark) inset;
    white-space: nowrap;
}

.chat-btn:hover {
    background: var(--paper);
}

.chat-btn:active {
    box-shadow: -1px -1px 0 var(--highlight) inset, 1px 1px 0 var(--dark) inset;
    transform: translate(1px, 1px);
}

.chat-btn:disabled {
    background: var(--dark);
    color: var(--gray);
    cursor: not-allowed;
    box-shadow: none;
}

.system-badges {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.badge {
    background: var(--ink);
    color: var(--paper);
    padding: 2px 6px;
    font-family: 'Press Start 2P', monospace;
    font-size: 6px;
    border: 1px solid var(--ink);
}

.api-note {
    text-align: center;
    font-size: 9px;
    color: var(--dark);
    font-style: italic;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: var(--paper);
    border: 2px solid var(--ink);
    box-shadow: 2px 2px 0 var(--highlight) inset, -2px -2px 0 var(--dark) inset;
    min-width: 300px;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    background: var(--gray);
    border-bottom: 1px solid var(--ink);
    padding: 8px 12px;
    background-image: repeating-linear-gradient(
        90deg,
        var(--ink),
        var(--ink) 1px,
        transparent 1px,
        transparent 3px
    );
    position: relative;
}

.modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gray);
    opacity: 0.85;
}

.modal-header h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    position: relative;
    z-index: 1;
    text-shadow: 1px 1px 0 var(--paper);
}

.modal-body {
    padding: 16px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}

.modal-btn {
    background: var(--gray);
    border: 1px solid var(--ink);
    padding: 8px 16px;
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    cursor: pointer;
    box-shadow: 1px 1px 0 var(--highlight) inset, -1px -1px 0 var(--dark) inset;
}

.modal-btn.primary {
    background: var(--ink);
    color: var(--paper);
}

.modal-btn:hover {
    background: var(--paper);
}

.modal-btn.primary:hover {
    background: var(--dark);
}

.modal-btn:active {
    box-shadow: -1px -1px 0 var(--highlight) inset, 1px 1px 0 var(--dark) inset;
    transform: translate(1px, 1px);
}

.about-content {
    text-align: center;
    line-height: 1.5;
}

.about-logo {
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
}

.about-logo svg {
    width: 48px;
    height: 48px;
    color: var(--ink);
}

.about-content ul {
    text-align: left;
    margin: 8px 0;
    padding-left: 20px;
}

.disclaimer {
    margin-top: 16px;
    font-size: 9px;
    color: var(--dark);
    font-style: italic;
}

/* Footer */
.footer {
    background: var(--paper);
    border-top: 1px solid var(--ink);
    padding: 12px;
    margin-top: auto;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    max-width: 1400px;
    margin: 0 auto;
}

.footer-icons {
    display: flex;
    gap: 6px;
}

.footer-icon {
    font-size: 12px;
    cursor: help;
}

.footer-text {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 9px;
    color: var(--dark);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 16px;
}

::-webkit-scrollbar-track {
    background: var(--gray);
    border: 1px solid var(--ink);
}

::-webkit-scrollbar-thumb {
    background: var(--paper);
    border: 1px solid var(--ink);
    box-shadow: 1px 1px 0 var(--highlight) inset, -1px -1px 0 var(--dark) inset;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray);
}

::-webkit-scrollbar-corner {
    background: var(--gray);
}

/* Focus and Accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 1px solid var(--ink);
    outline-offset: 1px;
}

/* Animations */
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.cursor-blink {
    animation: blink 1s infinite;
}

.typing-indicator {
    animation: blink 1.5s infinite;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .cursor-blink,
    .typing-indicator {
        animation: none;
    }
    
    .top-btn:active,
    .game-btn:active,
    .chat-btn:active,
    .modal-btn:active {
        transform: none;
    }
}

/* Theme Toggle */
body.dark-theme {
    --paper: #2A2A2A;
    --ink: #FFFFFF;
    --gray: #404040;
    --dark: #606060;
}

/* Draggable Windows */
.window.dragging {
    opacity: 0.8;
    z-index: 1001;
}

.window-titlebar {
    cursor: move;
    user-select: none;
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    .top-bar {
        height: 28px;
        padding: 0 8px;
    }
    
    .logo-text {
        font-size: 7px;
    }
    
    .main-content {
        margin-top: 28px;
        padding: 8px;
        min-height: calc(100vh - 28px - 50px);
    }
    
    .window-content {
        padding: 8px;
    }
    
    .game-hud {
        gap: 8px;
    }
    
    .game-controls {
        gap: 6px;
    }
    
    .input-row {
        flex-direction: column;
        gap: 6px;
    }
    
    .chat-btn {
        padding: 6px 10px;
    }
    
    .modal-content {
        margin: 20px;
        min-width: auto;
        max-width: none;
    }
}

/* Logo Popup */
.mac-logo {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.mac-logo:hover {
    transform: scale(1.1);
}

.logo-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.logo-popup-content {
    background: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    max-width: 300px;
    animation: popupAppear 0.3s ease;
}

.logo-popup-image {
    width: 128px;
    height: 128px;
    image-rendering: pixelated;
    margin-bottom: 1rem;
}

.logo-popup-text h3 {
    font-family: 'Press Start 2P', 'ChicagoFLF', monospace;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--ink);
}

.logo-popup-text p {
    font-size: 0.9rem;
    color: var(--ink);
    opacity: 0.8;
}

@keyframes popupAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
