/* ===== CSS Variables & Theme ===== */
:root {
    --wa-green: #25D366;
    --wa-dark-green: #128C7E;
    --wa-teal: #075E54;
    --wa-light-green: #DCF8C6;
    --wa-bg: #ECE5DD;
    --wa-chat-bg: #E5DDD5;

    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f7f8fa;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --text-muted: #8696a0;
    --border-color: #e9edef;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-primary: #0b141a;
    --bg-secondary: #1f2c34;
    --bg-tertiary: #182229;
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --text-muted: #667781;
    --border-color: #2a3942;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --wa-bg: #0b141a;
    --wa-chat-bg: #0b141a;
    --wa-light-green: #005c4b;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

/* ===== AUTH SCREEN ===== */
.auth-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    padding: 20px;
}

.auth-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #075E54 0%, #128C7E 30%, #25D366 60%, #075E54 100%);
    background-size: 300% 300%;
    animation: authBgMove 8s ease infinite;
}

.auth-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

@keyframes authBgMove {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.auth-container {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
    animation: authSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.96);
    }

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

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111b21;
    margin-top: 12px;
    letter-spacing: -0.5px;
}

.auth-subtitle {
    color: #667781;
    font-size: 0.9rem;
    margin-top: 4px;
}

.auth-form h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: #111b21;
    text-align: center;
}

.input-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon svg {
    position: absolute;
    left: 14px;
    color: #8696a0;
    pointer-events: none;
}

.input-icon input {
    width: 100%;
    padding: 12px 14px 12px 44px;
    border: 2px solid #e9edef;
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #f7f8fa;
    color: #111b21;
    outline: none;
    transition: all 0.25s ease;
}

.input-icon input:focus {
    border-color: #25D366;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.1);
}

.auth-error {
    color: #e74c3c;
    font-size: 0.82rem;
    min-height: 20px;
    text-align: center;
    margin-bottom: 4px;
    font-weight: 500;
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 14px;
    font-size: 1rem;
    border-radius: 12px;
    position: relative;
}

.btn-loader {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 0.88rem;
    color: #667781;
}

.auth-link {
    border: none;
    background: none;
    color: #25D366;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88rem;
    margin-left: 4px;
    transition: color 0.2s;
}

.auth-link:hover {
    color: #128C7E;
    text-decoration: underline;
}

.auth-screen.hidden {
    display: none;
}

/* ===== USER BADGE ===== */
.user-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 14px;
    border-radius: 20px;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 500;
}

.btn-logout {
    background: rgba(255, 100, 100, 0.15) !important;
}

.btn-logout:hover {
    background: rgba(255, 100, 100, 0.35) !important;
}

/* ===== Header ===== */
.app-header {
    background: linear-gradient(135deg, var(--wa-teal), var(--wa-dark-green));
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left .logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
}

.header-left .logo h1 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.header-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.08);
}

/* ===== Main Layout ===== */
.app-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 68px);
}

/* ===== Panels ===== */
.editor-panel,
.right-panel {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.char-counter {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 4px 10px;
    border-radius: 20px;
}

/* ===== Formatting Toolbar ===== */
.formatting-toolbar {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    flex-wrap: wrap;
}

.format-group {
    display: flex;
    gap: 4px;
}

.fmt-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: var(--transition);
}

.fmt-btn:hover {
    background: var(--wa-green);
    color: #fff;
    border-color: var(--wa-green);
    transform: translateY(-1px);
}

.fmt-btn code {
    font-size: 10px;
    font-family: 'Courier New', monospace;
}

/* ===== Quick Replies ===== */
.quick-replies {
    padding: 10px 16px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-color);
}

.quick-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 20px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.quick-btn:hover {
    background: var(--wa-dark-green);
    color: #fff;
    border-color: var(--wa-dark-green);
    transform: translateY(-1px);
}

/* ===== Editor ===== */
.editor-wrapper {
    flex: 1;
    padding: 16px;
    display: flex;
    min-height: 0;
}

#messageEditor {
    width: 100%;
    min-height: 250px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
}

#messageEditor:focus {
    border-color: var(--wa-green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

#messageEditor::placeholder {
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* ===== Action Buttons ===== */
.editor-actions {
    padding: 12px 16px;
    display: flex;
    gap: 10px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--wa-green), var(--wa-dark-green));
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

.btn-accent {
    background: linear-gradient(135deg, #6C63FF, #5548D9);
    color: #fff;
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(108, 99, 255, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #FF6B6B, #EE5A5A);
    color: #fff;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

/* ===== Variable Inputs ===== */
.variable-inputs {
    padding: 16px;
    border-top: 2px solid var(--wa-green);
    background: var(--bg-tertiary);
    animation: slideDown 0.3s ease;
}

.variable-inputs h3 {
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.var-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.var-field {
    display: flex;
    align-items: center;
    gap: 10px;
}

.var-field label {
    min-width: 100px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--wa-dark-green);
}

.var-field input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
}

.var-field input:focus {
    border-color: var(--wa-green);
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.tab {
    flex: 1;
    padding: 14px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    position: relative;
}

.tab.active {
    color: var(--wa-dark-green);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    width: 80%;
    height: 3px;
    background: var(--wa-green);
    border-radius: 3px 3px 0 0;
}

.tab:hover:not(.active) {
    background: var(--bg-tertiary);
}

.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* ===== WhatsApp Preview ===== */
.wa-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.wa-chat-header {
    background: linear-gradient(135deg, var(--wa-teal), var(--wa-dark-green));
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.wa-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wa-contact-info {
    display: flex;
    flex-direction: column;
}

.wa-contact-name {
    color: #fff;
    font-weight: 500;
    font-size: 0.95rem;
}

.wa-status {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
}

.wa-chat-body {
    flex: 1;
    padding: 20px;
    background-color: var(--wa-chat-bg);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    overflow-y: auto;
    min-height: 350px;
}

.wa-message-bubble {
    background: var(--wa-light-green);
    padding: 10px 14px;
    border-radius: 8px 0 8px 8px;
    max-width: 85%;
    margin-left: auto;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    font-size: 0.92rem;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
    color: #111b21;
}

[data-theme="dark"] .wa-message-bubble {
    color: #e9edef;
}

.wa-message-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    width: 0;
    height: 0;
    border-left: 8px solid var(--wa-light-green);
    border-bottom: 8px solid transparent;
}

.wa-message-bubble .preview-placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.wa-message-bubble .wa-bold {
    font-weight: 700;
}

.wa-message-bubble .wa-italic {
    font-style: italic;
}

.wa-message-bubble .wa-strike {
    text-decoration: line-through;
}

.wa-message-bubble .wa-mono {
    font-family: 'Courier New', monospace;
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88em;
}

.wa-message-bubble .wa-quote {
    border-left: 4px solid var(--wa-dark-green);
    padding-left: 10px;
    margin: 4px 0;
    color: var(--text-secondary);
    display: block;
}

.wa-message-time {
    font-size: 0.7rem;
    color: rgba(0, 0, 0, 0.4);
    text-align: right;
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

/* ===== Templates ===== */
.templates-header {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
}

.search-box input {
    border: none;
    background: none;
    flex: 1;
    font-size: 0.88rem;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
}

.search-box svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.category-filter select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

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

.empty-templates {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
}

.empty-hint {
    font-size: 0.8rem;
    margin-top: 8px;
}

.template-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
    animation: fadeIn 0.3s ease;
}

.template-card:hover {
    border-color: var(--wa-green);
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.15);
    transform: translateY(-1px);
}

.template-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.template-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.template-card-category {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 12px;
    background: var(--wa-dark-green);
    color: #fff;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.template-card-preview {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
    max-height: 60px;
    overflow: hidden;
    margin-bottom: 10px;
    white-space: pre-wrap;
    word-break: break-word;
}

.template-card-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.template-card-actions .btn {
    padding: 6px 12px;
    font-size: 0.78rem;
}

/* ===== Modals ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-close:hover {
    background: var(--border-color);
    transform: rotate(90deg);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ===== Emoji Picker ===== */
.emoji-picker-modal {
    max-width: 400px;
    max-height: 500px;
}

.emoji-search {
    padding: 12px 16px;
}

.emoji-search input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
}

.emoji-search input:focus {
    border-color: var(--wa-green);
}

.emoji-categories {
    padding: 0 16px 8px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.emoji-cat-btn {
    padding: 6px 10px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
}

.emoji-cat-btn.active,
.emoji-cat-btn:hover {
    background: var(--wa-green);
    transform: scale(1.1);
}

.emoji-grid {
    padding: 0 16px 16px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    overflow-y: auto;
    max-height: 280px;
}

.emoji-item {
    width: 100%;
    aspect-ratio: 1;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.3rem;
    border-radius: 6px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-item:hover {
    background: var(--bg-tertiary);
    transform: scale(1.25);
}

/* ===== Special Characters ===== */
.special-chars-modal {
    max-width: 420px;
}

.special-chars-grid {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.special-char-item {
    aspect-ratio: 1;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    cursor: pointer;
    font-size: 1.2rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.special-char-item:hover {
    background: var(--wa-green);
    color: #fff;
    border-color: var(--wa-green);
    transform: scale(1.1);
}

/* ===== History ===== */
.history-modal {
    max-width: 500px;
    max-height: 70vh;
}

.history-list {
    overflow-y: auto;
    padding: 12px;
    flex: 1;
}

.history-item {
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.history-item:hover {
    border-color: var(--wa-green);
}

.history-item-text {
    font-size: 0.85rem;
    color: var(--text-primary);
    max-height: 40px;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 6px;
}

.history-item-time {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ===== Import/Export ===== */
.import-export-modal .ie-section {
    text-align: center;
}

.import-export-modal .ie-section h4 {
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.import-export-modal .ie-section p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.import-export-modal hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
}

/* ===== Form Groups ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--wa-green);
}

.template-preview-text {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 0.85rem;
    max-height: 100px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-secondary);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--wa-teal);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

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

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }

    to {
        opacity: 1;
        max-height: 300px;
    }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .app-main {
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 12px;
    }

    .app-header {
        padding: 12px 16px;
    }

    .header-left .logo h1 {
        font-size: 1rem;
    }

    .formatting-toolbar {
        padding: 8px 12px;
    }

    .fmt-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .quick-replies {
        padding: 8px 12px;
    }

    .quick-btn {
        padding: 5px 10px;
        font-size: 0.72rem;
    }

    .editor-wrapper {
        padding: 12px;
    }

    #messageEditor {
        min-height: 180px;
    }

    .editor-actions {
        padding: 10px 12px;
    }

    .btn {
        padding: 8px 14px;
        font-size: 0.82rem;
    }

    .emoji-grid {
        grid-template-columns: repeat(7, 1fr);
    }

    .special-chars-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .wa-chat-body {
        min-height: 250px;
    }

    .user-badge span {
        display: none;
    }

    .header-right {
        gap: 4px;
    }
}

@media (max-width: 480px) {
    .header-left .logo h1 {
        font-size: 0.9rem;
    }

    .header-left .logo svg {
        width: 22px;
        height: 22px;
    }

    .btn-icon {
        width: 34px;
        height: 34px;
    }

    .editor-actions {
        flex-direction: column;
    }

    .editor-actions .btn {
        justify-content: center;
    }

    .emoji-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .special-chars-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .auth-container {
        padding: 28px 20px;
    }

    .auth-logo h1 {
        font-size: 1.25rem;
    }

    .auth-logo svg {
        width: 44px;
        height: 44px;
    }

    .user-badge {
        display: none;
    }
}