/* assets/css/style.css */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* ── Header ───────────────────────────────────────────────── */
.header {
    background: #fff;
    /*padding: 16px 24px;*/
    /*padding: 8px 12px;*/
    padding: 4px 6px;
    border-radius: 10px;
    margin-bottom: 28px;
    box-shadow: 0 10px 30px rgba(0,0,0,.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.header h1 { color: #667eea; font-size: 26px; }
.header h1 a { color: inherit; text-decoration: none; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-block;
/*    padding: 9px 18px;*/
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background .2s, transform .15s, box-shadow .2s;
    white-space: nowrap;
}

.btn-primary   { background: #667eea; color: #fff; }
.btn-secondary { background: #e2e8f0; color: #4a5568; }
.btn-danger    { background: #f56565; color: #fff; }

.btn-primary:hover   { background: #5a67d8; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(102,126,234,.4); }
.btn-secondary:hover { background: #cbd5e0; }
.btn-danger:hover    { background: #e53e3e; }

.btn-full { width: 100%; text-align: center; padding: 12px; font-size: 16px; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert { padding: 14px 18px; border-radius: 6px; margin-bottom: 20px; }
.alert-success { background: #c6f6d5; color: #22543d; border: 1px solid #9ae6b4; }
.alert-error   { background: #fed7d7; color: #742a2a; border: 1px solid #fc8181; }

/* ── Character grid ───────────────────────────────────────── */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 20px;
}

.character-card {
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
    transition: transform .25s, box-shadow .25s;
}
.character-card:hover { transform: translateY(-4px); box-shadow: 0 16px 36px rgba(0,0,0,.18); }

.character-image {
    width: 100%; height: 275px;
    overflow: hidden;
    background: #f7fafc;
    display: flex; align-items: center; justify-content: center;
}
.character-image img { width: 100%; height: 100%; object-fit: cover; }
.character-image .no-image {
    background: linear-gradient(135deg, #667eea, #764ba2);
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 52px; font-weight: 700;
}

.character-info { padding: 18px; }
.character-info h3 { margin-bottom: 6px; color: #2d3748; font-size: 19px; }
.character-info .personality { color: #718096; font-size: 15px; font-style: italic; margin-bottom: 12px; }

.character-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.character-actions .btn { flex: 1; text-align: center; }

/* ── Forms ────────────────────────────────────────────────── */
.form-container {
    background: #fff;
    border-radius: 14px;
    padding: 32px;
    max-width: 640px;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(0,0,0,.1);
}

.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #4a5568;
    font-weight: 600;
    font-size: 14px;
}
.form-group label small { font-weight: 400; color: #718096; }
.form-group .required { color: #e53e3e; }

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="file"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 15px;
    transition: border-color .2s;
    background: #fff;
    color: #2d3748;
}
.form-group input:focus,
.form-group textarea:focus { outline: none; border-color: #667eea; }

.form-group textarea { resize: vertical; line-height: 1.5; }
.form-group small { display: block; margin-top: 5px; color: #718096; font-size: 12px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.current-image { margin-bottom: 10px; }
.current-image img { max-width: 180px; border-radius: 6px; border: 2px solid #e2e8f0; }
.current-image p   { font-size: 12px; color: #718096; margin-top: 6px; }

.gallery-container {
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,.1);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.profile-container {
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,.1);
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ── Chat page ────────────────────────────────────────────── */
.chat-container {
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,.1);
    height: calc(100vh - 130px);
    display: flex;
    flex-direction: column;
}

.chat-header {
    background: #f7fafc;
/*    padding: 16px 20px;*/
    padding: 8px 10px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 14px;
}

.chat-header-image {
    width: 48px; height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: #667eea;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 18px;
    flex-shrink: 0;
}
.chat-header-image img { width: 100%; height: 100%; object-fit: cover; }
.chat-header-info h2  { color: #2d3748; font-size: 18px; }
.chat-header-info p   { color: #718096; font-size: 13px; margin-top: 2px; }

/* Scrollable messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
/*    padding: 20px;*/
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Individual message bubbles */
.message { display: flex; }
.message.user      { justify-content: flex-end; }
.message.assistant { justify-content: flex-start; }
.message.system    { justify-content: center; }

.message-bubble {
    max-width: 100%;
    padding: 11px 16px;
    border-radius: 18px;
    background: #f0f4ff;
    color: #2d3748;
    line-height: 1.55;
    word-break: break-word;
}
.message.user .message-bubble {
    background: #ffffff;
    color: #000;
    border-bottom-right-radius: 4px;
    border: 3px solid #667eea;
}
.message.assistant .message-bubble {
    background: #ffffff;
    border-bottom-left-radius: 4px;
    color: #000;
    font-size: 22px;
    border: 3px solid gray;
}
.message.system .message-bubble {
    background: #fff3cd;
    color: #856404;
    font-size: 22px;
    border-radius: 8px;
    max-width: 90%;
    text-align: center;
}
.message-content {
    width: 100%;
}


/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 10px 16px;
    background: #f0f4ff;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-left: 20px;
}
.typing-indicator span {
    width: 8px; height: 8px;
    background: #a0aec0;
    border-radius: 50%;
    animation: bounce 1s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-8px); }
}

/* Chat input area */
.chat-input-container {
    padding: 14px 20px;
    border-top: 1px solid #e2e8f0;
    background: #f7fafc;
}
.chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.chat-form textarea {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    resize: none;
    line-height: 1.4;
    max-height: 160px;
    overflow-y: auto;
    transition: border-color .2s;
    font-family: inherit;
}
.chat-form textarea:focus { outline: none; border-color: #667eea; }
.chat-form button {
    padding: 10px 22px;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
    align-self: flex-end;
}
.chat-form button:hover    { background: #5a67d8; }
.chat-form button:disabled { background: #cbd5e0; cursor: not-allowed; }

/* ── Message Feedback ────────────────────────────────────── */
.message {
    position: relative;
    transition: background-color .2s;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.message.user {
    align-items: flex-end;
}
.message.system {
    align-items: center;
}
.message-feedback {
    display: flex;
    gap: 8px;
    opacity: 1;
    transition: opacity .2s;
    margin-top: 6px;
    width: fit-content;
}
.message.user .message-feedback,
.message.assistant .message-feedback {
    margin-left: 0;
    margin-right: 0;
}
.feedback-btn {
    background: transparent;
/*
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    padding: 4px 8px;
*/
    cursor: pointer;
    font-size: 16px;
    transition: all .2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.feedback-btn:hover {
    border-color: #a0aec0;
    background: #f7fafc;
}
.feedback-btn.active {
    border-color: #667eea;
    background: #e6f0ff;
}
.feedback-btn.thumbs-up.active {
    border-color: #22c55e;
    background: #dcfce7;
}
.feedback-btn.thumbs-down.active {
    border-color: #ef4444;
    background: #fee2e2;
}

.copy-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1050;
    padding: 10px 14px;
    background: rgba(17, 24, 39, 0.95);
    color: #fff;
    border-radius: 999px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.25);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .25s ease, transform .25s ease;
    pointer-events: none;
    font-size: 14px;
}
.copy-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,.1);
    color: #4a5568;
}
.empty-state h3 { font-size: 22px; margin-bottom: 10px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
    .character-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .message-content { max-width: 88%; }
    .chat-container { height: calc(100vh - 110px); }
    .header { flex-direction: column; align-items: flex-start; }
}
