:root {

    --primary-color: #ff406d;
    --primary-hover: #ff8e53;
    --primary-light: #fff0f3;
    --success-color: #42b72a;
    --success-hover: #36a420;
    --danger-color: #f02849;
    --danger-hover: #d9233f;
    --warning-color: #f7b928;
    --light-border: #e4e6eb;
    --light-bg: #f0f2f5;
    --border-radius: 12px;
    --transition: all 0.3s ease;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 5px 15px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 15px 30px rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    font-family: 'Nunito', sans-serif;
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
}



/* --- Legacy/Component Styles (Forms, Tables, Alerts) --- */

/* Generic Card (for legacy support) */
.card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    /* Added subtle border */
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.card-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label,
.form-group label {
    /* Combined selector */
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.form-control,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--light-border);
    border-radius: 12px;
    font-size: 15px;
    transition: var(--transition);
    font-family: inherit;
    background-color: #f8fafc;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    /* Updated to use variable */
    box-shadow: 0 0 0 3px rgba(255, 64, 109, 0.1);
    /* Updated to use primary color RGB */
    background-color: white;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #f8fafc;
    border-radius: 12px;
}

th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: #555;
    /* Updated color */
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--light-border);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--light-border);
    color: var(--text-primary);
    vertical-align: middle;
}

tr:hover {
    background: #f8fafc;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success,
.badge-active {
    /* Added badge-active alias */
    background: #F0FFF4;
    color: #48BB78;
}

.badge-danger,
.badge-inactive {
    /* Added badge-inactive alias */
    background: #FFF5F5;
    color: #F56565;
}

.badge-warning {
    background: #FFFAF0;
    color: #ED8936;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary-color);
}

.badge-reply {
    background: #e3f2fd;
    color: #007bff;
}

.badge-dm {
    background: #e8f5e9;
    color: #28a745;
}

.badge-both {
    background: #fff3e0;
    color: #fd7e14;
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.alert-success {
    background: #F0FFF4;
    color: #2F855A;
    border-left: 4px solid #48BB78;
}

.alert-danger,
.alert-error {
    /* Added alert-error alias */
    background: #FFF5F5;
    color: #C53030;
    border-left: 4px solid #F56565;
}

.alert-warning {
    background: #FFFAF0;
    color: #C05621;
    border-left: 4px solid #ED8936;
}

.alert-info {
    background: #EBF8FF;
    color: #2C5282;
    border-left: 4px solid #4299E1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(43, 54, 116, 0.4);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s;
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f0f0f0;
    color: var(--danger-color);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --- Automation Rules Page Styles (Consolidated) --- */

/* Opening DM Logic Styles */
.dm-config-card {
    transition: all 0.3s ease;
    padding: 0;
    /* No border or shadow by default */
    background: transparent;
}

.dm-config-card.active {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.dm-config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.dm-config-title {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 15px;
}

.dm-message-preview {
    background: #f8f9fa;
    /* Light background for the preview area */
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
}

.dm-message-preview textarea.form-control {
    border: 1px solid #dee2e6;
    background: #fff;
    margin-bottom: 12px !important;
    /* Force margin */
    min-height: 80px;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
}

.dm-message-preview textarea.form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

#dm_button_text {
    display: block !important;
    width: 100% !important;
    padding: 12px;
    border: 1px dashed #ced4da;
    border-radius: 8px;
    text-align: center;
    color: #007bff;
    background: #fff;
    font-weight: 600;
    transition: all 0.2s;
    cursor: text;
    margin-top: 10px;
}

.dm-button-input:hover {
    background: #f8f9fa;
    border-color: #007bff;
}

.dm-button-input:focus {
    border-style: solid;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
    outline: none;
    background: #fff;
}

.dm-helper-text {
    font-size: 12px;
    color: #888;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.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: #dee2e6;
    transition: .3s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.toggle-slider {
    background-color: #007bff;
}

input:checked+.toggle-slider:before {
    transform: translateX(20px);
}

/* Toggle Switch for Table (Slightly different from above) */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #4CAF50;
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* Post Grid Styles */
#posts_grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 140px);
    gap: 15px;
    justify-content: start;
    /* Align items to start, don't stretch */
}

.post-item-wrapper {
    position: relative;
    padding-top: 100%;
}

.post-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.post-item.selected {
    border-color: #007bff;
}

.post-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-item .checkmark {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #007bff;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}

.post-item.selected .checkmark {
    opacity: 1;
}

.post-item .caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 10px;
    padding: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Utility Buttons */
.btn-modern {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary-gradient {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
}

.btn-primary-gradient:hover {
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    transform: translateY(-1px);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Hidden Class */
.hidden {
    display: none !important;
}

/* Responsive */