/* Dog Park AI — Styles */

:root {
    --green-dark: #1a3a16;
    --green-mid: #2d5a27;
    --green-light: #4a8c3f;
    --green-pale: #e8f5e3;
    --white: #ffffff;
    --gray-50: #f8f9fa;
    --gray-100: #f0f1f3;
    --gray-200: #e2e4e7;
    --gray-300: #c8ccd0;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --blue-light: #eff6ff;
    --blue-mid: #3b82f6;
    --red: #dc2626;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    height: 100dvh;
    overflow: hidden;
}

.hidden { display: none !important; }

/* --- Auth Gate --- */
.auth-gate {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100dvh;
    background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 50%, var(--green-light) 100%);
}

.auth-card {
    background: var(--white);
    border-radius: 20px;
    padding: 48px 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.auth-logo { font-size: 64px; margin-bottom: 16px; }
.auth-logo-img { width: 160px; height: auto; margin-bottom: 16px; }
.header-logo-img { height: 32px; width: auto; }
.auth-card h1 { font-size: 28px; color: var(--green-dark); margin-bottom: 4px; }
.auth-subtitle { color: var(--gray-500); margin-bottom: 32px; font-size: 14px; }
.auth-hint { color: var(--gray-500); font-size: 13px; margin-top: 12px; }

.auth-error {
    background: #fef2f2;
    color: var(--red);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-top: 16px;
    font-size: 14px;
}

.btn-primary {
    background: var(--green-mid);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
}
.btn-primary:hover { background: var(--green-light); }
.btn-primary:active { transform: scale(0.98); }

/* --- Main App Layout --- */
.app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

/* --- Header --- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--green-dark);
    color: white;
    flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { font-size: 24px; }
.header-title { font-size: 18px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 8px; }
.user-name { font-size: 13px; opacity: 0.8; margin-right: 8px; }

.btn-icon {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.btn-icon:hover { background: rgba(255,255,255,0.2); }

/* --- Status Bar --- */
.status-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 20px;
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
    overflow-x: auto;
    font-size: 13px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.sb-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-300);
}
.sb-dot.online { background: #22c55e; }
.sb-dot.offline { background: var(--red); }

.sb-label { color: var(--gray-500); font-size: 12px; }
.sb-value { font-weight: 600; color: var(--gray-700); }

.sb-divider { width: 1px; height: 20px; background: var(--gray-300); margin: 0 4px; }
.sb-clickable { cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.sb-clickable:hover { background: var(--gray-200); }
.sb-link { text-decoration: underline; text-decoration-style: dotted; }
.sb-green { color: #16a34a; }
.sb-yellow { color: #ca8a04; }
.sb-blue { color: #2563eb; }
.sb-gray { color: #6b7280; }
.status-action { margin-left: auto; }

.btn-unlock {
    background: var(--white);
    border: 2px solid var(--green-mid);
    color: var(--green-mid);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-unlock { text-decoration: none; }
.btn-unlock:hover { background: var(--green-mid); color: white; }

/* --- Chat Container --- */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

/* --- Welcome --- */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
}
.welcome-message h2 { color: var(--green-dark); margin-bottom: 8px; }
.welcome-message p { color: var(--gray-500); margin-bottom: 24px; }

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

.suggestion {
    background: var(--white);
    border: 1px solid var(--gray-200);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s;
}
.suggestion:hover {
    border-color: var(--green-light);
    background: var(--green-pale);
    color: var(--green-dark);
}

/* --- Messages --- */
.message {
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.message.user .message-avatar { background: var(--blue-light); }
.message.assistant .message-avatar { background: var(--green-pale); }

.message-content {
    flex: 1;
    min-width: 0;
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.message-text {
    background: var(--white);
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    line-height: 1.5;
    font-size: 14px;
    overflow-wrap: break-word;
}

.message.user .message-text {
    background: var(--green-mid);
    color: white;
    border-color: var(--green-mid);
}

.message-text p { margin-bottom: 8px; }
.message-text p:last-child { margin-bottom: 0; }
.message-text ul, .message-text ol { margin: 8px 0; padding-left: 20px; }
.message-text li { margin-bottom: 4px; }
.message-text code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}
.message-text strong { font-weight: 600; }

/* Tool execution indicator */
.tool-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--blue-light);
    color: var(--blue-mid);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    margin-bottom: 8px;
}

.tool-indicator .spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--blue-mid);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}
.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--gray-300);
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* --- Input Area --- */
.input-area {
    padding: 12px 20px 20px;
    background: var(--gray-50);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 8px 12px;
    transition: border-color 0.2s;
}
.input-wrapper:focus-within { border-color: var(--green-light); }

#message-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    max-height: 120px;
    background: transparent;
}

.btn-send {
    background: var(--green-mid);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.btn-send:hover { background: var(--green-light); }
.btn-send:disabled { background: var(--gray-300); cursor: not-allowed; }

/* --- Conversations Panel --- */
.conversations-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.3);
    z-index: 99;
}

.conversations-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: var(--white);
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.btn-close {
    background: none;
    border: 1px solid var(--gray-200);
    color: var(--gray-700);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.btn-close:hover { background: var(--gray-100); }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
}
.panel-header h3 { font-size: 16px; }

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversation-item {
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-bottom: 4px;
    transition: background 0.2s;
}
.conversation-item:hover { background: var(--gray-100); }
.conversation-item.active { background: var(--green-pale); }

.conversation-item .conv-preview {
    font-size: 13px;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conversation-item .conv-time {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* --- Admin Panel --- */
.admin-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 480px;
    max-width: 95vw;
    max-height: 85vh;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.admin-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.admin-section { margin-bottom: 24px; }
.admin-section h4 { font-size: 14px; color: var(--gray-500); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }

.invite-form { display: flex; flex-direction: column; gap: 8px; }

.input-field {
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
.input-field:focus { border-color: var(--green-light); }

.btn-sm { padding: 10px 20px; font-size: 14px; }

.invite-result {
    margin-top: 12px;
    padding: 12px;
    background: var(--green-pale);
    border-radius: var(--radius-sm);
    font-size: 13px;
    word-break: break-all;
}

.users-list { display: flex; flex-direction: column; gap: 8px; }

.user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
}

.user-info { flex: 1; }
.user-info .user-card-name { font-weight: 600; font-size: 14px; }
.user-info .user-card-detail { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

.user-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.user-badge.admin { background: #fef3c7; color: #92400e; }
.user-badge.member { background: var(--green-pale); color: var(--green-dark); }

.btn-danger {
    background: none;
    border: 1px solid #fecaca;
    color: var(--red);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
}
.btn-danger:hover { background: #fef2f2; }

/* --- Responsive --- */
@media (max-width: 600px) {
    .chat-container { max-width: 100%; }
    .auth-card { padding: 32px 24px; }
    .conversations-panel { width: 100%; }
    .suggestions { flex-direction: column; }
    .suggestion { text-align: center; }
}

@media (pointer: coarse) {
    .btn-primary { padding: 16px 32px; min-height: 48px; }
    .suggestion { padding: 12px 16px; min-height: 44px; }
    .btn-icon { width: 44px; height: 44px; }
}
