/* The Guy - App Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #000;
    color: #39ff14;
    font-family: 'JetBrains Mono', 'Courier New', Courier, monospace;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1000;
}

/* Header */
.header {
    padding: 10px 15px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.logo {
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 2px;
    white-space: pre;
    cursor: pointer;
    transition: opacity 0.2s;
    color: var(--green);
    text-decoration: none;
}

.logo:hover {
    opacity: 0.7;
}

.header-controls {
    display: flex;
    gap: 10px;
}

.btn {
    background: transparent;
    color: #39ff14;
    border: 1px solid #444;
    padding: 5px 12px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: #222;
}

.btn:active {
    background: #333;
}

/* Thread dropdown */
.thread-select {
    background: #000;
    color: #39ff14;
    border: 1px solid #444;
    padding: 5px 10px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    max-width: 150px;
}

.thread-select option {
    background: #000;
}

/* Chat area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 90%;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.user {
    color: #888;
}

.message.user::before {
    content: "> ";
    color: #555;
}

.message.assistant {
    color: #39ff14;
}

.message.assistant::before {
    content: "The Guy: ";
    color: #666;
}

.message strong {
    font-weight: bold;
    color: #39ff14;
}

.message em {
    font-style: italic;
}

.message code {
    background: #222;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 13px;
}

.message.thinking {
    color: #555;
    animation: blink 1s infinite;
}

.message.thinking::before {
    content: "The Guy: ";
    color: #444;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.5; }
}

.message-image {
    max-width: 200px;
    max-height: 150px;
    margin-top: 5px;
    border: 1px solid #333;
}

.empty-state {
    color: #444;
    text-align: center;
    margin-top: 40px;
}

/* Input area */
.input-container {
    padding: 15px;
    border-top: 1px solid #333;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

.input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.image-preview {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    background: #111;
    border: 1px solid #333;
}

.image-preview.active {
    display: flex;
}

.preview-item {
    position: relative;
    display: inline-block;
}

.preview-item img {
    max-height: 50px;
    max-width: 70px;
    border: 1px solid #333;
}

.preview-item .remove-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    background: #ff4444;
    color: #000;
    border: none;
    border-radius: 50%;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.preview-item .remove-btn:hover {
    background: #ff6666;
}

#message-input {
    background: transparent;
    border: 1px solid #444;
    color: #39ff14;
    padding: 10px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    min-height: 40px;
    max-height: 120px;
}

#message-input:focus {
    outline: none;
    border-color: #666;
}

#message-input::placeholder {
    color: #444;
}

.input-buttons {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: transparent;
    border: 1px solid #444;
    color: #39ff14;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.icon-btn:hover {
    background: #222;
}

.icon-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Improve touch responsiveness on mobile */
.btn, .icon-btn, .auth-btn, .upgrade-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

#image-input {
    display: none;
}

/* Delete thread modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #111;
    border: 1px solid #444;
    padding: 20px;
    max-width: 300px;
    text-align: center;
}

.modal-buttons {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Auth modal */
.auth-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.auth-modal.active {
    display: flex;
}

.auth-content {
    background: #111;
    border: 1px solid #444;
    padding: 25px;
    width: 90%;
    max-width: 350px;
}

.auth-content h2 {
    margin-bottom: 20px;
    font-size: 16px;
    text-align: center;
}

.auth-input {
    width: 100%;
    background: #000;
    border: 1px solid #444;
    color: #39ff14;
    padding: 10px;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 10px;
}

.auth-input:focus {
    outline: none;
    border-color: #39ff14;
}

.auth-btn {
    width: 100%;
    background: #39ff14;
    color: #000;
    border: none;
    padding: 10px;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 10px;
}

.auth-btn:hover {
    background: #00cc00;
}

.auth-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-switch {
    text-align: center;
    font-size: 12px;
    color: #666;
}

.auth-switch a {
    color: #39ff14;
    cursor: pointer;
}

.auth-error {
    color: #ff4444;
    font-size: 12px;
    margin-bottom: 10px;
    display: none;
}

.auth-error.active {
    display: block;
}

.auth-close {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #666;
    font-size: 20px;
    cursor: pointer;
}

.auth-close:hover {
    color: #39ff14;
}

/* Usage stats */
.usage-stats {
    font-size: 10px;
    color: #666;
    display: flex;
    gap: 10px;
    align-items: center;
}

.usage-bar {
    width: 60px;
    height: 6px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
}

.usage-fill {
    height: 100%;
    background: #39ff14;
    transition: width 0.3s;
}

.usage-fill.warning {
    background: #ffaa00;
}

.usage-fill.danger {
    background: #ff4444;
}

.tier-badge {
    font-size: 9px;
    padding: 2px 6px;
    border: 1px solid;
    border-radius: 3px;
    text-transform: uppercase;
}

.tier-badge.free_trial {
    border-color: #666;
    color: #666;
}

.tier-badge.basic {
    border-color: #39ff14;
    color: #39ff14;
}

.tier-badge.premium {
    border-color: #ffaa00;
    color: #ffaa00;
}

/* User controls */
.user-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-email {
    font-size: 10px;
    color: #666;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Upgrade header button */
.upgrade-header-btn {
    background: #ffaa00;
    color: #000;
    border-color: #ffaa00;
}

.upgrade-header-btn:hover {
    background: #cc8800;
}

/* Limit reached overlay */
.limit-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.95);
    align-items: center;
    justify-content: center;
    z-index: 150;
    flex-direction: column;
    gap: 20px;
    text-align: center;
    padding: 20px;
}

.limit-overlay.active {
    display: flex;
}

.limit-overlay h2 {
    color: #ff4444;
}

.limit-overlay p {
    color: #888;
    max-width: 300px;
}

.limit-overlay .upgrade-btn {
    background: #39ff14;
    color: #000;
    border: none;
    padding: 12px 30px;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    body {
        height: 100dvh;
        height: -webkit-fill-available;
    }

    .logo {
        display: none;
    }

    .logo-mobile {
        display: block !important;
        font-size: 14px;
        font-weight: bold;
        letter-spacing: 2px;
        cursor: pointer;
        color: var(--green);
        text-decoration: none;
    }

    .logo-mobile:hover {
        opacity: 0.7;
    }

    .header {
        padding: 8px 10px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-controls {
        flex-wrap: wrap;
        gap: 6px;
    }

    .chat-container {
        padding: 10px;
        min-height: 0;
    }

    .input-container {
        padding: 10px;
    }

    .thread-select {
        max-width: 100px;
    }

    .usage-stats {
        display: none;
    }

    .user-email {
        display: none;
    }

    .btn {
        padding: 5px 8px;
        font-size: 11px;
    }
}

.logo-mobile {
    display: none;
}

/* Orientation modal */
.orientation-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.95);
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.orientation-modal.active {
    display: flex;
}

.orientation-content {
    background: #111;
    border: 1px solid #39ff14;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    text-align: left;
}

.orientation-content h2 {
    font-size: 14px;
    letter-spacing: 2px;
    margin-bottom: 20px;
    color: #39ff14;
}

.orientation-content ul {
    list-style: none;
    padding: 0;
    margin: 0 0 25px 0;
}

.orientation-content li {
    font-size: 13px;
    line-height: 1.7;
    color: rgba(57, 255, 20, 0.85);
    margin-bottom: 12px;
    padding-left: 15px;
    position: relative;
}

.orientation-content li::before {
    content: "-";
    position: absolute;
    left: 0;
    color: #39ff14;
}

.orientation-btn {
    width: 100%;
    background: #39ff14;
    color: #000;
    border: none;
    padding: 12px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-transform: lowercase;
}

.orientation-btn:hover {
    background: #00cc00;
}

/* Offline banner */
.offline-banner {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ff4444;
    color: #000;
    text-align: center;
    padding: 8px;
    font-size: 12px;
    font-weight: bold;
    z-index: 400;
}

.offline-banner.active {
    display: block;
}

body.offline .header {
    margin-top: 32px;
}

/* Consent Banner */
.consent-banner {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #111;
    border-top: 1px solid #39ff14;
    padding: 15px 20px;
    z-index: 500;
    font-size: 12px;
}

.consent-banner.active {
    display: block;
}

.consent-content {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.consent-text {
    flex: 1;
    color: rgba(57,255,20,0.85);
    line-height: 1.6;
}

.consent-text a {
    color: #39ff14;
}

.consent-buttons {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.consent-btn {
    background: #39ff14;
    color: #000;
    border: none;
    padding: 8px 20px;
    font-family: inherit;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}

.consent-btn.secondary {
    background: transparent;
    color: #39ff14;
    border: 1px solid #39ff14;
}

/* Mobile consent banner */
@media (max-width: 600px) {
    .consent-banner {
        padding: 12px 15px;
    }

    .consent-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .consent-text {
        font-size: 11px;
        line-height: 1.5;
        text-align: center;
    }

    .consent-buttons {
        justify-content: center;
        width: 100%;
    }

    .consent-btn {
        flex: 1;
        padding: 10px 15px;
    }

    /* Hide consent banner when orientation modal is active */
    .orientation-modal.active ~ .consent-banner.active,
    body:has(.orientation-modal.active) .consent-banner {
        display: none;
    }
}

/* Settings Modal */
.settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 600;
    align-items: center;
    justify-content: center;
}

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

.settings-content {
    background: #000;
    border: 1px solid #39ff14;
    padding: 25px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

.settings-header h2 {
    font-size: 14px;
}

.settings-close {
    cursor: pointer;
    font-size: 18px;
}

.settings-section {
    margin-bottom: 20px;
}

.settings-section h3 {
    font-size: 12px;
    margin-bottom: 10px;
    color: #39ff14;
}

.settings-section p {
    font-size: 11px;
    color: rgba(57,255,20,0.7);
    margin-bottom: 10px;
    line-height: 1.6;
}

.settings-btn {
    background: transparent;
    color: #39ff14;
    border: 1px solid #444;
    padding: 8px 15px;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    margin-right: 10px;
    margin-bottom: 8px;
}

.settings-btn:hover {
    background: #222;
}

.settings-btn.danger {
    border-color: #ff6b6b;
    color: #ff6b6b;
}

.settings-btn.danger:hover {
    background: rgba(255,107,107,0.1);
}

.settings-links {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #333;
}

.settings-links a {
    color: rgba(57,255,20,0.6);
    font-size: 11px;
    margin-right: 15px;
    text-decoration: none;
}

.settings-links a:hover {
    color: #39ff14;
}
