/**
 * Digital Studio — Common Styles (DRY)
 * Общие стили для всех страниц
 */

/* ============================================
   CSS Variables (Theme)
   ============================================ */
:root {
    /* Telegram WebApp fallbacks */
    --tg-theme-bg-color: #fff;
    --tg-theme-text-color: #000;
    --tg-theme-hint-color: #999;
    --tg-theme-link-color: #2481cc;
    --tg-theme-button-color: #2481cc;
    --tg-theme-button-text-color: #fff;
    --tg-theme-secondary-bg-color: #f4f4f5;
    
    /* Custom palette */
    --sky: #60a5fa;
    --sky-light: #dbeafe;
    --lilac: #a78bfa;
    --lilac-light: #ede9fe;
    --gray: #64748b;
    --gray-light: #f1f5f9;
    --pink: #f472b6;
    --pink-light: #fce7f3;
    --purple: #a78bfa;
    --yellow: #fbbf24;
    --yellow-light: #fef3c7;
    --red: #f87171;
    --green: #34d399;
    --white: #ffffff;
    --black: #1e293b;
    
    /* Computed */
    --card: rgba(255, 255, 255, 0.97);
    --border: rgba(167, 139, 250, 0.25);
    --shadow: rgba(96, 165, 250, 0.12);
}

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

html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
}

a {
    color: var(--tg-theme-link-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ============================================
   Common Components
   ============================================ */

/* Empty state */
.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--tg-theme-hint-color);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.7;
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--tg-theme-hint-color);
}

/* Cards */
.card {
    background: var(--card);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px var(--shadow);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--lilac) 0%, var(--pink) 100%);
    color: white;
}

.btn-secondary {
    background: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-text-color);
}

.btn-danger {
    background: var(--red);
    color: white;
}

.btn-success {
    background: var(--green);
    color: white;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--tg-theme-bg-color);
    border-radius: 16px;
    padding: 20px;
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--lilac);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

/* Forms */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--tg-theme-hint-color);
    margin-bottom: 4px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--lilac);
}

/* File items */
.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
}

.file-icon {
    font-size: 20px;
}

.file-name {
    flex: 1;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 12px;
    color: var(--tg-theme-hint-color);
}

/* Stars rating */
.stars {
    display: flex;
    gap: 4px;
}

.star {
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.15s;
}

.star:hover {
    transform: scale(1.2);
}

/* Status colors */
.status-new { color: #3b82f6; }
.status-accepted { color: #22c55e; }
.status-in_progress { color: #f59e0b; }
.status-completed { color: #10b981; }
.status-rejected { color: #ef4444; }

/* ============================================
   Utilities
   ============================================ */
.text-center { text-align: center; }
.text-muted { color: var(--tg-theme-hint-color); }
.text-small { font-size: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.animate-fade { animation: fadeIn 0.3s ease; }
.animate-slide { animation: slideUp 0.3s ease; }

/* Inline custom emoji (msg 12180): DRY shared style across all WebApps.
   Used by EmojiPicker.createInlineEmoji — animated emoji render canvas/video,
   static render <img>. Span wrapper for relative positioning. */
.inline-emoji {
    display: inline-block;
    width: 28px;
    height: 28px;
    vertical-align: middle;
    margin: 0 1px;
    position: relative;
    overflow: hidden;
    user-select: none;
    line-height: 0;
}
.inline-emoji img,
.inline-emoji canvas,
.inline-emoji video,
.inline-emoji svg,
.inline-emoji-media {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}
.inline-emoji svg.inline-emoji-media {
    z-index: 2;
}
.inline-emoji-static {
    z-index: 1;
}

/* Smooth re-render для animated emoji в picker (Pattern 43: убрать миг при scroll) */
.ep-anim-wrap {
    animation: ep-fadein 0.18s ease-out;
}
@keyframes ep-fadein {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

/* Reply quote (msg 12429, 02.05.2026): цитата над сообщением-ответом — стиль как в Telegram.
   Click → scroll к оригиналу. Цветная полоска слева в цвет акцента, имя жирно, текст preview обрезается. */
.reply-quote {
    display: block;
    border-left: 3px solid var(--tg-theme-button-color, #2481cc);
    padding: 4px 8px;
    margin-bottom: 6px;
    background: rgba(36, 129, 204, 0.08);
    border-radius: 0 6px 6px 0;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    overflow: hidden;
    max-width: 100%;
    transition: background 0.15s;
}
.reply-quote:hover, .reply-quote:active {
    background: rgba(36, 129, 204, 0.18);
}
.reply-quote .reply-author {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--tg-theme-button-color, #2481cc);
    line-height: 1.3;
}
.reply-quote .reply-text {
    display: block;
    font-size: 13px;
    color: var(--tg-theme-text-color, #000);
    opacity: 0.7;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}
/* Message highlight — пульс при scroll-к-цитате */
.message-highlighted {
    animation: msg-highlight 1.4s ease-out;
}
@keyframes msg-highlight {
    0% { box-shadow: 0 0 0 0 rgba(36, 129, 204, 0.6); }
    20% { box-shadow: 0 0 0 8px rgba(36, 129, 204, 0.35); }
    100% { box-shadow: 0 0 0 0 rgba(36, 129, 204, 0); }
}

/* Reply preview над input — когда админ нажал «Ответить» на сообщение */
.reply-preview {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--tg-theme-bg-color, #fff);
    border-top: 1px solid rgba(0,0,0,0.08);
    border-left: 3px solid var(--tg-theme-button-color, #2481cc);
    margin: 0;
}
.reply-preview.show {
    display: flex;
}
.reply-preview-body {
    flex: 1;
    overflow: hidden;
}
.reply-preview-body .reply-author {
    font-size: 12px;
    font-weight: 600;
    color: var(--tg-theme-button-color, #2481cc);
    line-height: 1.3;
}
.reply-preview-body .reply-text {
    font-size: 13px;
    opacity: 0.7;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.reply-preview-cancel {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--tg-theme-hint-color, #888);
    padding: 4px 8px;
    flex-shrink: 0;
}
.reply-preview-cancel:hover {
    color: #d33;
}
