/* Reset & base — Instagram style (light) */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #fafafa;
  color: #262626;
  min-height: 100vh;
  line-height: 1.4;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.page-header {
  text-align: center;
  margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.5rem; margin: 0 0 0.25rem 0; color: #262626; }
.page-header p { margin: 0; color: #8e8e8e; font-size: 0.9rem; }

.layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid #efefef;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.panel h2 { margin: 0 0 1rem 0; font-size: 1.1rem; color: #262626; }
.form-panel .form-section { margin-bottom: 1.5rem; }
.form-panel .form-section:last-child { margin-bottom: 0; }
.form-panel h3 { margin: 0 0 0.75rem 0; font-size: 0.95rem; color: #8e8e8e; }
.form-panel label {
  display: block;
  margin-bottom: 0.75rem;
}
.form-panel label span {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  color: #8e8e8e;
}
.form-panel input[type="text"],
.form-panel input[type="datetime-local"],
.form-panel textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #dbdbdb;
  border-radius: 8px;
  background: #fafafa;
  color: #262626;
  font-size: 0.95rem;
}
.form-panel input[type="text"]:focus,
.form-panel input[type="datetime-local"]:focus,
.form-panel textarea:focus {
  outline: none;
  border-color: #a8a8a8;
}
.form-panel input[type="file"] {
  width: 100%;
  font-size: 0.85rem;
  color: #8e8e8e;
}
.form-panel textarea { resize: vertical; min-height: 60px; }

.form-hint { font-size: 0.85rem; color: #8e8e8e; margin: 0 0 0.75rem 0; }
.message-actions { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.btn {
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  background: #efefef;
  color: #262626;
}
.btn-add { background: #0095f6; color: #fff; }
.btn-add:hover { background: #1877f2; }
.btn-small {
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  min-width: 28px;
}
.message-list { display: flex; flex-direction: column; gap: 0.5rem; }
.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem;
  background: #fafafa;
  border-radius: 8px;
  border: 1px solid #efefef;
}
.msg-row .msg-badge {
  flex-shrink: 0;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}
.msg-row.msg-contact .msg-badge { background: #efefef; color: #262626; }
.msg-row.msg-mine .msg-badge { background: #0095f6; color: #fff; }
.msg-row .msg-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.msg-row .msg-datetime-wrap { margin: 0; }
.msg-row .msg-datetime {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid #dbdbdb;
  border-radius: 6px;
  background: #fff;
  color: #262626;
  font-size: 0.8rem;
  cursor: pointer;
}
.msg-row .msg-datetime::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
}
.msg-row .msg-text-wrap { margin: 0; }
.msg-row textarea { margin: 0; min-height: 44px; }
.msg-row .msg-actions { margin: 0; display: flex; gap: 2px; flex-shrink: 0; }
.msg-row .msg-actions .btn { padding: 0.25rem; }

.form-section-export .message-actions { margin-bottom: 0; }
.btn-upload { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.btn-upload input[hidden] { position: absolute; width: 0; height: 0; opacity: 0; }

/* Instagram Direct frame */
.preview-panel h2 { margin-bottom: 0.75rem; color: #262626; }
.ig-frame {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #efefef;
  max-width: 380px;
  margin: 0 auto;
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
}

.ig-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #efefef;
}
.ig-back {
  width: 24px;
  height: 24px;
  border: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23262626'%3E%3Cpath d='M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z'/%3E%3C/svg%3E") center/20px no-repeat;
  cursor: pointer;
  flex-shrink: 0;
}
.ig-avatar-wrap {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: #efefef;
  flex-shrink: 0;
}
.ig-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ig-avatar-wrap:not(.has-img) .ig-avatar { display: none; }
.ig-avatar-wrap:not(.has-img)::after {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #e1306c 0%, #fd1d1d 50%, #f77737 100%);
}
.ig-title { flex: 1; min-width: 0; }
.ig-name { display: block; font-weight: 600; font-size: 1rem; color: #262626; }
.ig-status { font-size: 0.8rem; color: #8e8e8e; }
.ig-video, .ig-info {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.ig-video {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23262626'%3E%3Cpath d='M18 10.5V15c0 1.5-1.23 2.73-2.73 2.73H4.73C3.23 17.73 2 16.5 2 15v-4.5c0-1.5 1.23-2.73 2.73-2.73h10.54C16.77 7.77 18 9 18 10.5zM22 6v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h16c1.1 0 2 .9 2 2zm-7 4.5l5 2.5-5 2.5v-5z'/%3E%3C/svg%3E") center/20px no-repeat;
}
.ig-info {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23262626'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'/%3E%3C/svg%3E") center/20px no-repeat;
}

.ig-chat {
  padding: 16px;
  min-height: 200px;
  background: #fafafa;
}

.ig-date {
  text-align: center;
  font-size: 0.75rem;
  color: #8e8e8e;
  margin: 16px 0;
  font-weight: 400;
}
.ig-bubbles > .ig-date:first-child { margin-top: 0; }

.ig-bubbles { display: flex; flex-direction: column; gap: 8px; }
.ig-msg { display: flex; gap: 8px; align-items: flex-end; }
.ig-msg.ig-incoming { flex-direction: row; justify-content: flex-start; }
.ig-msg.ig-outgoing { flex-direction: row-reverse; justify-content: flex-start; }
.ig-msg.hidden { display: none; }

.ig-msg-avatar-wrap {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #efefef;
}
.ig-msg-avatar { width: 100%; height: 100%; object-fit: cover; }
.ig-msg-avatar-wrap:not(.has-img) .ig-msg-avatar { display: none; }
.ig-msg-avatar-wrap:not(.has-img)::after {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #e1306c 0%, #fd1d1d 50%, #f77737 100%);
}

.ig-msg-content { max-width: 75%; min-width: 0; }
.ig-msg-sender { font-size: 0.75rem; color: #0095f6; margin-bottom: 2px; display: block; font-weight: 600; }
.ig-bubble {
  padding: 10px 14px;
  border-radius: 22px;
  position: relative;
  display: inline-block;
  max-width: 100%;
  font-size: 0.95rem;
}
.ig-bubble-in {
  background: #efefef;
  border-bottom-left-radius: 4px;
  color: #262626;
}
.ig-bubble-out {
  background: #0095f6;
  border-bottom-right-radius: 4px;
  color: #fff;
}
.ig-bubble-text { word-wrap: break-word; white-space: pre-wrap; }
.ig-bubble-text:empty::before { content: ' '; }
.ig-time {
  font-size: 0.7rem;
  color: #8e8e8e;
  float: right;
  margin-left: 8px;
  margin-top: 2px;
}
.ig-bubble-out .ig-time { color: rgba(255,255,255,0.85); }
