:root {
    --primary-color: #006837;
    --primary-light: #008542;
    --primary-dark: #004d2b;
    --secondary-color: #00a651;
    --accent-color: #3399ff;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --error-color: #f44336;
    --background-light: #ffffff;
    --background-dark: #1f2937;
    --text-light: #1f2937;
    --text-dark: #f3f4f6;
    --border-light: #e5e7eb;
    --border-dark: #374151;
    --whatsapp-color: #25D366;
    --viber-color: #7360F2;
    --telegram-color: #0088cc;
    --sms-color: #3b82f6;
    --shadow-light: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-medium: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-dark: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --header-height: 70px;
    --border-radius: 8px;
    --transition-speed: 0.3s;
    --transition-timing: cubic-bezier(0.4, 0, 0.2, 1);
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.18);
}

[data-theme="dark"] {
    --primary-color: #008542;
    --primary-light: #00a651;
    --primary-dark: #006837;
    --secondary-color: #66BB6A;
    --background-light: #1f2937;
    --background-dark: #111827;
    --text-light: #f3f4f6;
    --text-dark: #e5e7eb;
    --border-light: #374151;
    --border-dark: #4b5563;
    --shadow-light: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --shadow-dark: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    --glass-bg: rgba(31, 41, 55, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Cairo', sans-serif;
}

body {
    background: linear-gradient(135deg, var(--background-light) 0%, #f0f9f0 100%);
    color: var(--text-light);
    transition: all var(--transition-speed) var(--transition-timing);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: var(--header-height);
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, var(--background-light) 0%, #1a2634 100%);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    flex: 1;
    position: relative;
    z-index: 1;
}

header {
    background: linear-gradient(to right, var(--primary-dark), var(--primary-color));
    padding: 0.5rem 0;
    box-shadow: var(--shadow-light);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    height: var(--header-height);
    transition: all var(--transition-speed) var(--transition-timing);
}

header:hover { box-shadow: var(--shadow-medium); }

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
}

.header-content > div {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-title {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform var(--transition-speed) var(--transition-timing);
}

.header-title:hover { transform: scale(1.05); }

.logo {
    display: flex;
    align-items: center;
    transition: transform var(--transition-speed) var(--transition-timing);
}

.logo:hover { transform: scale(1.05); }
.logo img { height: 50px; width: auto; }

.menu-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
    transition: transform var(--transition-speed) var(--transition-timing);
    border-radius: 50%;
}

.menu-toggle:hover {
    transform: rotate(90deg);
    background-color: rgba(255, 255, 255, 0.1);
}

.side-menu {
    position: fixed;
    right: -100%;
    top: 0;
    width: 300px;
    height: 100vh;
    background-color: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-medium);
    transition: right var(--transition-speed) var(--transition-timing);
    z-index: 999;
    overflow-y: auto;
    padding: calc(var(--header-height) + 1rem) 1rem 1rem 1rem;
    border-left: 1px solid var(--glass-border);
}

.side-menu.active { right: 0; }

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.menu-items { list-style: none; }
.menu-item { margin-bottom: 1rem; }

.menu-link {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    color: var(--text-light);
    text-decoration: none;
    transition: all var(--transition-speed) var(--transition-timing);
    border-radius: var(--border-radius);
}

.menu-link:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateX(-5px);
}

.menu-link i { margin-left: 0.75rem; width: 20px; text-align: center; }

.submenu {
    list-style: none;
    margin-right: 2rem;
    margin-top: 0.5rem;
    display: none;
}

.submenu.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

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

.menu-close {
    background: var(--primary-color);
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) var(--transition-timing);
    padding: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.menu-close:hover {
    background-color: var(--primary-light);
    transform: scale(1.1) rotate(90deg);
}

/* Main Section Tabs */
.main-section-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(5px);
    border-radius: var(--border-radius);
    padding: 0.5rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--glass-border);
}

.main-section-tab {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 700;
    font-size: 15px;
    color: var(--text-light);
    background: transparent;
    transition: all var(--transition-speed) var(--transition-timing);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.main-section-tab:hover {
    background-color: rgba(0, 104, 55, 0.08);
}

.main-section-tab.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    box-shadow: var(--shadow-light);
}

.main-section { display: none; animation: fadeIn 0.3s ease-out; }
.main-section.active { display: block; }

/* Platform Tabs */
.tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.75rem;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--border-light);
    padding: inherit;
}

.tabs::-webkit-scrollbar { height: 4px; }
.tabs::-webkit-scrollbar-track { background: var(--border-light); border-radius: 2px; }
.tabs::-webkit-scrollbar-thumb { background-color: var(--primary-color); border-radius: 2px; }

.tab {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    color: var(--text-light);
    background: transparent;
    transition: all var(--transition-speed) var(--transition-timing);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab:hover {
    background-color: rgba(0, 104, 55, 0.05);
    transform: translateY(-2px);
}

.tab.active {
    background: var(--background-light);
    box-shadow: var(--shadow-light);
    transform: translateY(-2px);
}

.tab.active[data-platform="whatsapp"] { color: var(--whatsapp-color); }
.tab.active[data-platform="viber"] { color: var(--viber-color); }
.tab.active[data-platform="telegram"] { color: var(--telegram-color); }
.tab.active[data-platform="sms"] { color: var(--sms-color); }

/* Main Content Box */
.main-content {
    background-color: var(--glass-bg);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--glass-border);
    transition: transform var(--transition-speed) var(--transition-timing), box-shadow var(--transition-speed) var(--transition-timing);
    animation: fadeIn 0.5s ease-out;
}

.main-content:hover { box-shadow: var(--shadow-medium); }

.form-group { margin-bottom: 20px; }

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary-color);
}

textarea, input[type="text"], input[type="email"], input[type="number"], select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    font-size: 16px;
    background: var(--background-light);
    color: var(--text-light);
    transition: all var(--transition-speed) var(--transition-timing);
    margin-top: 5px;
    font-family: 'Cairo', sans-serif;
}

textarea { resize: vertical; min-height: 100px; }

textarea:focus, input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 104, 55, 0.2);
}

.form-select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    font-size: 16px;
    background: var(--background-light);
    color: var(--text-light);
    cursor: pointer;
}

/* Country Code Selector */
.country-code-button {
    background-color: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: all var(--transition-speed) var(--transition-timing);
    color: var(--text-light);
    font-size: 14px;
    font-weight: 600;
    max-width: 120px;
}

.country-code-button:hover { background-color: var(--border-light); border-color: var(--primary-light); }
.country-code-button i { font-size: 12px; transition: transform var(--transition-speed) var(--transition-timing); }
.country-code-button.active i { transform: rotate(180deg); }

.country-code-selector {
    position: absolute;
    background-color: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    margin-top: 2px;
    max-height: 200px;
    width: 180px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.country-code-selector.active { display: block; animation: fadeIn 0.2s ease-out; }

.country-code-item {
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-light);
    font-size: 14px;
    transition: background-color var(--transition-speed) var(--transition-timing);
}

.country-code-item:hover { background-color: var(--border-light); color: var(--primary-color); }

/* File Upload Buttons */
.file-upload-buttons { display: flex; gap: 10px; margin-bottom: 10px; }

/* Message Tabs */
.message-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    overflow-x: auto;
    padding-bottom: 5px;
    -webkit-overflow-scrolling: touch;
}

.message-tab {
    padding: 8px 15px;
    background: var(--background-light);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: all var(--transition-speed) var(--transition-timing);
    color: var(--text-light);
}

.message-tab:hover { transform: translateY(-2px); background-color: var(--border-light); }

.message-tab.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    box-shadow: var(--shadow-light);
}

.add-message-button {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: var(--border-radius);
    cursor: pointer;
    margin-bottom: 15px;
    font-weight: 600;
    transition: all var(--transition-speed) var(--transition-timing);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-light);
}

.add-message-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.message-container {
    margin-bottom: 20px;
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    background: var(--background-light);
    padding: 15px;
    position: relative;
    display: none;
    animation: fadeIn 0.3s ease-out;
    box-shadow: var(--shadow-light);
}

.message-container.active { display: block; }

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}

.message-actions { display: flex; gap: 5px; }

.remove-message {
    color: var(--text-light);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.7;
    transition: opacity var(--transition-speed);
    padding: 4px;
    border-radius: 4px;
}

.remove-message:hover { opacity: 1; background-color: rgba(239, 68, 68, 0.1); color: var(--error-color); }

.message-counter {
    margin-top: 10px;
    padding: 8px;
    background-color: var(--background-light);
    border-radius: var(--border-radius);
    text-align: center;
    font-size: 14px;
    color: var(--text-light);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-light);
}

.safe-mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding: 10px;
    background: var(--background-light);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-light);
    font-size: 14px;
    animation: fadeIn 0.3s ease-out;
}

.timer-display {
    background: var(--background-light);
    padding: 10px;
    border-radius: var(--border-radius);
    text-align: center;
    margin: 10px 0 20px;
    display: none;
    animation: fadeIn 0.3s ease-out;
    border: 1px solid var(--warning-color);
    color: var(--warning-color);
    font-weight: bold;
}

.button-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    align-items: stretch;
}

button {
    padding: 12px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-speed) var(--transition-timing);
    color: white;
    font-size: 14px;
    box-shadow: var(--shadow-light);
    font-family: 'Cairo', sans-serif;
    white-space: nowrap;
}

button:hover { opacity: 0.9; transform: translateY(-2px); box-shadow: var(--shadow-medium); }
button:active { transform: translateY(0); }

.button-grid button {
    flex: 1 1 auto;
    min-width: 120px;
    max-width: none;
    padding: 12px 16px;
}

.primary-button { background: linear-gradient(135deg, var(--primary-color), var(--primary-light)); }
.success-button { background: linear-gradient(135deg, var(--success-color), #66bb6a); }
.danger-button { background: linear-gradient(135deg, var(--error-color), #e57373); margin-top: 0; }
.warning-button { background: linear-gradient(135deg, var(--warning-color), #ffb74d); }
.info-button { background: linear-gradient(135deg, var(--success-color), #66bb6a); }

/* Message Links Grid */
.message-links {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 20px;
}

.links-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    flex-wrap: wrap;
    grid-column: 1 / -1;
}

.links-batch-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.links-batch-actions button {
    padding: 6px 12px;
    font-size: 12px;
}

.links-count {
    margin-right: auto;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
}

.link-item-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    border-radius: var(--border-radius);
    transition: background-color var(--transition-speed);
}

.link-item-wrapper:hover {
    background-color: rgba(0, 104, 55, 0.03);
}

.link-item-wrapper .link-check {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.link-item-wrapper .message-link {
    flex: 1;
    border-radius: var(--border-radius);
    transition: all var(--transition-speed) var(--transition-timing);
}

.link-item-wrapper .message-link.link-sent {
    opacity: 0.6;
    position: relative;
}

.link-item-wrapper .message-link.link-sent::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 4px;
    left: 4px;
    background: white;
    color: var(--success-color);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.link-delete-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-light);
    opacity: 0.4;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    flex-shrink: 0;
    font-size: 12px;
}

.link-delete-btn:hover {
    opacity: 1;
    background: rgba(244, 67, 54, 0.1);
    color: var(--error-color);
    transform: none;
    box-shadow: none;
}

.message-link {
    padding: 12px;
    border-radius: var(--border-radius);
    color: white;
    text-decoration: none;
    text-align: center;
    transition: all var(--transition-speed) var(--transition-timing);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    box-shadow: var(--shadow-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-medium); }
.message-link[data-platform="whatsapp"] { background: var(--whatsapp-color); }
.message-link[data-platform="viber"] { background: var(--viber-color); }
.message-link[data-platform="telegram"] { background: var(--telegram-color); }
.message-link[data-platform="sms"] { background: var(--sms-color); }

/* Templates List */
.templates-list {
    margin-top: 20px;
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    animation: fadeIn 0.3s ease-out;
}

.template-item {
    background: var(--background-light);
    padding: 15px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed) var(--transition-timing);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-light);
}

.template-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-medium); border-color: var(--primary-color); }

/* Modal */
.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;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background: var(--background-light);
    padding: 20px;
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-medium);
    animation: slideUp 0.3s ease-out;
}

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

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    transition: all var(--transition-speed) var(--transition-timing);
}

.modal-close:hover { color: var(--error-color); transform: rotate(90deg); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stat-item {
    background: var(--background-light);
    padding: 15px;
    border-radius: var(--border-radius);
    text-align: center;
    border: 1px solid var(--border-light);
    transition: all var(--transition-speed) var(--transition-timing);
}

.stat-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-light); border-color: var(--primary-light); }

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    background: var(--success-color);
    color: white;
    box-shadow: var(--shadow-medium);
    z-index: 1000;
    opacity: 0;
    animation: slideInRight 0.3s ease-out forwards;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 300px;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.toast.hide { animation: slideOutRight 0.3s ease-in forwards; }
.toast.warning { background: var(--warning-color); }
.toast.error { background: var(--error-color); }

.save-wide-button {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
}

/* AI Tabs */
.ai-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-light);
}

.ai-tab {
    padding: 10px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-light);
    background: var(--background-light);
    transition: all var(--transition-speed) var(--transition-timing);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.ai-tab:hover {
    border-color: var(--primary-color);
    background-color: rgba(0, 104, 55, 0.05);
    transform: translateY(-1px);
}

.ai-tab.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-light);
}

/* AI Panels */
.ai-panel {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.ai-panel.active { display: block; }

.ai-panel-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-panel-desc {
    color: var(--text-light);
    opacity: 0.8;
    font-size: 0.9rem;
    margin-bottom: 20px;
    line-height: 1.6;
}

.ai-generate-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 10px;
}

.ai-loading {
    text-align: center;
    padding: 20px;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 1rem;
}

.ai-loading i { margin-left: 8px; }

/* AI Results */
.ai-results {
    margin-top: 20px;
}

.ai-batch-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    gap: 10px;
    flex-wrap: wrap;
}

.ai-select-all-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-light);
    cursor: pointer;
}

.ai-select-all-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.ai-batch-actions {
    display: none;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.ai-batch-actions button {
    padding: 8px 14px;
    font-size: 12px;
}

.ai-result-item {
    background: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 10px;
    position: relative;
    transition: all var(--transition-speed) var(--transition-timing);
}

.ai-result-item:hover {
    box-shadow: var(--shadow-light);
    border-color: var(--primary-light);
}

.ai-result-item.ai-result-added {
    border-color: var(--success-color);
    background: rgba(76, 175, 80, 0.03);
}

.ai-result-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.ai-result-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.ai-result-badge {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.ai-result-added-badge {
    display: none;
    align-items: center;
    gap: 4px;
    background: var(--success-color);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-right: auto;
}

.ai-result-item .result-text {
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 10px;
    white-space: pre-wrap;
    direction: rtl;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: border-color var(--transition-speed), background-color var(--transition-speed);
    outline: none;
    min-height: 40px;
}

.ai-result-item .result-text:focus {
    border-color: var(--primary-color);
    background-color: rgba(0, 104, 55, 0.02);
    box-shadow: 0 0 0 2px rgba(0, 104, 55, 0.1);
}

.ai-result-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ai-result-actions button {
    padding: 6px 12px;
    font-size: 12px;
    min-width: auto;
    flex: none;
}

/* API Key Status */
.api-key-status {
    margin-top: 15px;
    padding: 12px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 600;
}

.api-key-status.success {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.api-key-status.error {
    background: rgba(244, 67, 54, 0.1);
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

/* Responsive */
@media (max-width: 768px) {
    :root { --header-height: 60px; }
    .header-title { font-size: 1.2rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .message-links { grid-template-columns: 1fr; }
    .templates-list { grid-template-columns: 1fr; }
    .side-menu { width: 85%; max-width: 300px; }
    button { font-size: 12px; padding: 10px; }

    .button-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        overflow-x: visible;
    }

    .button-grid button {
        min-width: 0;
        max-width: none;
        font-size: 11px;
        padding: 10px 8px;
        white-space: nowrap;
    }

    .main-section-tabs {
        flex-direction: row;
        gap: 4px;
        padding: 4px;
    }

    .main-section-tab {
        font-size: 12px;
        padding: 10px 8px;
    }

    .ai-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch;
    }

    .ai-tab {
        flex: 0 0 auto;
        font-size: 11px;
        padding: 8px 12px;
    }

    .ai-batch-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .ai-batch-actions {
        width: 100%;
    }

    .ai-batch-actions button {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .header-title { font-size: 1rem; }
    .stat-value { font-size: 20px; }
}

.hidden { display: none; }

/* Messaging Sub-tabs */
.msg-subtabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    padding: 6px;
    background: var(--glass-bg);
    backdrop-filter: blur(5px);
    border-radius: var(--border-radius);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-light);
}

.msg-subtab {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-light);
    background: transparent;
    transition: all var(--transition-speed) var(--transition-timing);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    box-shadow: none;
}

.msg-subtab:hover {
    background-color: rgba(0, 104, 55, 0.08);
    transform: none;
    box-shadow: none;
}

.msg-subtab.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    box-shadow: var(--shadow-light);
}

.msg-panel {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.msg-panel.active {
    display: block;
}

@media (max-width: 768px) {
    .msg-subtabs {
        gap: 4px;
        padding: 4px;
    }

    .msg-subtab {
        font-size: 11px;
        padding: 8px 6px;
        gap: 4px;
    }

    .msg-subtab i {
        font-size: 10px;
    }
}

/* Message Search */
.message-search-wrapper {
    position: relative;
    margin-bottom: 15px;
}

.message-search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    transition: all var(--transition-speed) var(--transition-timing);
}

.message-search-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 104, 55, 0.2);
}

.message-search-box i {
    color: var(--primary-color);
    opacity: 0.7;
}

.message-search-box input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: var(--text-light);
    padding: 4px 0;
    margin-top: 0;
}

.message-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--background-light);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
    margin-top: 4px;
}

.search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background-color var(--transition-speed);
}

.search-result-item:last-child { border-bottom: none; }

.search-result-item:hover {
    background-color: rgba(0, 104, 55, 0.05);
}

.search-no-result {
    padding: 15px;
    text-align: center;
    color: var(--text-light);
    opacity: 0.7;
}

/* Message Label Input */
.message-label-input {
    border: 1px solid var(--border-light);
    border-radius: 4px;
    background: var(--background-light);
    color: var(--text-light);
    font-family: 'Cairo', sans-serif;
    transition: border-color var(--transition-speed);
}

.message-label-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 104, 55, 0.15);
}

