/* Chat Maker Specific Styles */
:root {
    --bubble-other-bg: #ffffff;
    --bubble-other-text: #000000;
    --bubble-me-bg: #85e249;
    --bubble-me-text: #000000;
    --bubble-font-size: 0.95rem;
    --system-text-color: #ffffff;
    --chat-bg-color: #7494C0;
}


/* Editor panels */
.settings-panel {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.avatar-preview {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #000;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.2);
    transition: border-color 0.2s;
}
.avatar-preview:hover {
    border-color: #10B981;
}
.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.script-item {
    display: flex;
    gap: 8px;
    padding: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    align-items: flex-start;
}
.script-item.script-me {
    border-left: 4px solid #10B981;
}
.script-item.script-other {
    border-left: 4px solid #3B82F6;
}
.sortable-ghost {
    opacity: 0.4;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px dashed #10B981;
}
.drag-handle:hover svg {
    color: #fff;
}

.script-textarea {
    flex-grow: 1;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 8px;
    border-radius: 4px;
    resize: vertical;
    min-height: 40px;
    font-size: 0.85rem;
    transition: background-color 0.3s, color 0.3s;
}
.script-item.script-me .script-textarea {
    background-color: var(--bubble-me-bg);
    color: var(--bubble-me-text);
}
.script-item.script-other .script-textarea {
    background-color: var(--bubble-other-bg);
    color: var(--bubble-other-text);
}
.script-textarea:focus {
    outline: none;
    border-color: #10B981;
}

/* ====== Custom Toggle Switch ====== */
.toggle-switch-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 8px;
    cursor: pointer;
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.2);
    transition: .3s;
    border-radius: 24px;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.toggle-switch input:checked + .toggle-slider {
    background-color: #10B981;
}
.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}


/* ====== Smartphone Preview Frame ====== */
.smartphone-frame {
    width: 390px;
    height: 844px;
    background: var(--chat-bg-color); /* Defaults to #7494C0 */
    border-radius: 0px;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 30px 60px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* ====== Realistic Top Header ====== */
.android-status-bar {
    height: 30px;
    background: #a3a3a3;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
    z-index: 10;
}
.status-icons {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-header {
    height: 60px;
    background: #fff;
    color: #111;
    display: flex;
    align-items: center;
    padding: 0 15px;
    flex-shrink: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.chat-canvas {
    flex-grow: 1;
    padding: 20px 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
}
/* Hide scrollbar for clean recording/screenshot */
.chat-canvas::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

.chat-watermark {
    position: absolute;
    bottom: 110px; /* offset for the new footer */
    left: 0;
    width: 100%;
    text-align: center;
    color: rgba(255,255,255,0.2);
    font-weight: 900;
    font-size: 1rem;
    pointer-events: none;
    user-select: none;
    z-index: 0;
}

/* ====== Realistic Chat Footer ====== */
.chat-footer {
    flex-shrink: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    z-index: 20;
    position: relative;
}
.chat-input-area {
    display: flex;
    align-items: center;
    background: #fdfdfd; 
    padding: 8px 12px;
    gap: 12px;
    border-top: 1px solid rgba(0,0,0,0.05);
}
.chat-input-box {
    flex-grow: 1;
    background: #f0f0f0;
    border-radius: 20px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 10px;
}
.android-nav-bar {
    background: #000;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 40px;
}
.android-btn {
    background: #fff;
    opacity: 0.9;
}
.android-btn.triangle {
    width: 20px;
    height: 20px;
    clip-path: polygon(100% 0, 0 50%, 100% 100%);
}
.android-btn.circle {
    border-radius: 50%;
    width: 20px;
    height: 20px;
}
.android-btn.square {
    border-radius: 3px;
    width: 18px;
    height: 18px;
}

/* ====== Chat Bubbles ====== */
.msg-row {
    display: flex;
    width: 100%;
    align-items: flex-start;
    gap: 8px;
    z-index: 5;
    /* initial state for drop-in animation */
    opacity: 0;
    transform: translateY(20px) scale(0.9);
}

.msg-row.show-anim {
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #fff;
    overflow: hidden;
}
.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msg-content {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}
.msg-name {
    font-size: 0.75rem;
    color: var(--system-text-color);
    margin-bottom: 3px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.msg-bubble {
    position: relative;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: var(--bubble-font-size);
    line-height: 1.5;
    word-break: break-all;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Other (Left) */
.msg-other {
    justify-content: flex-start;
}
.msg-other .msg-bubble {
    background: var(--bubble-other-bg);
    color: var(--bubble-other-text);
    border-top-left-radius: 4px;
}
.msg-other .msg-bubble::before {
    content: '';
    position: absolute;
    top: 10px;
    left: -6px;
    border-style: solid;
    border-width: 6px 8px 6px 0;
    border-color: transparent var(--bubble-other-bg) transparent transparent;
}
.msg-other .msg-meta {
    align-self: flex-end;
    margin-left: 5px;
    font-size: 0.65rem;
    color: var(--system-text-color);
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
    margin-bottom: 2px;
}

/* Me (Right) */
.msg-me {
    justify-content: flex-end;
}
.msg-me .msg-avatar {
    display: none; /* Usually 'me' doesn't show avatar in LINE */
}
.msg-me .msg-name {
    display: none;
}
.msg-me .msg-bubble {
    background: var(--bubble-me-bg);
    color: var(--bubble-me-text);
    border-top-right-radius: 4px;
}
.msg-me .msg-bubble::before {
    content: '';
    position: absolute;
    top: 10px;
    right: -6px;
    border-style: solid;
    border-width: 6px 0 6px 8px;
    border-color: transparent transparent transparent var(--bubble-me-bg);
}
.msg-me .msg-content {
    align-items: flex-end;
}
.msg-me .msg-meta {
    align-self: flex-end;
    margin-right: 5px;
    font-size: 0.65rem;
    color: var(--system-text-color);
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
    margin-bottom: 2px;
    text-align: right;
    line-height: 1.2;
}

/* Stamp Image Rules (Force Constraint) */
.msg-stamp {
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    display: flex;
}
.msg-stamp img {
    display: block;
    max-width: 140px !important;
    max-height: 140px !important;
    width: auto !important;
    height: auto !important;
    border-radius: 8px;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.25));
    object-fit: contain;
}
.msg-me .msg-stamp::before, 
.msg-other .msg-stamp::before {
    display: none !important;
}
.msg-me .msg-meta {
    align-self: flex-end;
    margin-right: 5px;
    font-size: 0.65rem;
    color: var(--system-text-color);
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
    margin-bottom: 2px;
    text-align: right;
    line-height: 1.2;
}

/* Global utility */
.btn-remove-sm {
    background: transparent;
    border: none;
    color: var(--danger);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 5px;
    border-radius: 4px;
}
.btn-remove-sm:hover {
    background: rgba(239, 68, 68, 0.2);
}
