/* Dark Theme Styles */
:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    /* --accent-primary: #00d4aa; */
    --accent-primary: #0c91cf;
    --accent-secondary: #ff6b6b;
    --accent-warning: #ffa726;
    --accent-info: #42a5f5;
    --border-color: #404040;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.dark-theme {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* Sidebar Styles */
.sidebar {
    background-color: var(--bg-secondary);
    min-height: 100vh;
    height: 100vh;
    box-shadow: var(--shadow);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    overflow-y: auto;
}

.sidebar .nav-link {
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin: 0.25rem 0;
    transition: all 0.3s ease;
}

.sidebar .nav-link:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar .nav-link.active {
    background-color: var(--accent-primary);
    color: var(--bg-primary);
    font-weight: 600;
}

.sidebar .nav-link i {
    margin-right: 0.5rem;
    width: 20px;
}

/* Header Styles */
.border-bottom {
    border-color: var(--border-color) !important;
}

.form-control-dark {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.form-control-dark:focus {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 212, 170, 0.25);
}

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

/* Card Styles */
.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.card-header {
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    border-radius: 1rem 1rem 0 0 !important;
}

.card-title {
    color: var(--text-primary);
}

.card-body {
    color: var(--text-primary);
}

/* Metric Cards */
.metric-card {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border: none;
    border-radius: 1rem;
    padding: 1.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-info));
}

.metric-card.primary::before {
    background: linear-gradient(90deg, var(--accent-primary), #00b894);
}

.metric-card.secondary::before {
    background: linear-gradient(90deg, var(--text-secondary), #6c757d);
}

.metric-card.success::before {
    background: linear-gradient(90deg, #00b894, #00cec9);
}

.metric-card.danger::before {
    background: linear-gradient(90deg, var(--accent-secondary), #e17055);
}

.metric-card.warning::before {
    background: linear-gradient(90deg, var(--accent-warning), #fdcb6e);
}

.metric-card .metric-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.metric-card .metric-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-card .metric-icon {
    font-size: 2.5rem;
    opacity: 0.7;
    margin-bottom: 1rem;
}

/* Chart Cards */
.chart-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    /* padding: 1.5rem; */
}

.chart-card .chart-header {
    display: flex;
    justify-content: between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-card .chart-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Table Styles */
.table-dark {
    --bs-table-bg: var(--bg-tertiary);
    --bs-table-striped-bg: var(--bg-secondary);
    --bs-table-hover-bg: var(--bg-primary);
    --bs-table-border-color: var(--border-color);
}

.table-dark th {
    border-color: var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
}

.table-dark td {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

/* Form Styles */
.form-control {
    background-color: #525151;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.form-control:focus {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 212, 170, 0.25);
}

.form-label {
    color: var(--text-primary);
    font-weight: 500;
}

.form-select {
    background-color: #525151;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.form-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 212, 170, 0.25);
}

/* Button Styles */
.btn-primary {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--bg-primary);
    font-weight: 600;
}

.btn-primary:hover {
    background-color: #00b894;
    border-color: #00b894;
    color: var(--bg-primary);
}

.btn-success {
    background-color: #00b894;
    border-color: #00b894;
}

.btn-danger {
    background-color: var(--accent-secondary);
    border-color: var(--accent-secondary);
}

.btn-warning {
    background-color: var(--accent-warning);
    border-color: var(--accent-warning);
    color: var(--bg-primary);
}

.btn-info {
    background-color: var(--accent-info);
    border-color: var(--accent-info);
}

/* Modal Styles */
.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
}

.modal-footer {
    border-top: 1px solid var(--border-color);
}

.modal-title {
    color: var(--text-primary);
}

/* Confirmation Modal Styles */
#confirmModal .modal-content {
    border-radius: 1.5rem;
    border: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease-out;
}

#confirmModal .modal-body {
    padding: 2rem 2rem 1rem;
}

#confirmModal .modal-footer {
    padding: 1rem 2rem 2rem;
}

#confirmModal .btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

#confirmModal .btn-close:hover {
    opacity: 1;
}

#confirmModal .btn-danger {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    border: none;
    padding: 0.75rem 2rem;
    font-weight: 600;
    border-radius: 0.75rem;
    transition: all 0.3s ease;
}

#confirmModal .btn-danger:hover {
    background: linear-gradient(135deg, #ee5a52, #e74c3c);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
}

#confirmModal .btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.75rem 2rem;
    font-weight: 500;
    border-radius: 0.75rem;
    transition: all 0.3s ease;
}

#confirmModal .btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    transform: translateY(-2px);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Modal backdrop animation */
.modal-backdrop {
    animation: backdropFadeIn 0.3s ease-out;
}

@keyframes backdropFadeIn {
    from { opacity: 0; }
    to { opacity: 0.5; }
}

/* Dropdown Styles */
.dropdown-menu {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
    z-index: 1050 !important;
}

.dropdown-item {
    color: var(--text-secondary);
}

.dropdown-item:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Segment card dropdown specific fixes */
.segment-card .dropdown {
    position: relative;
    z-index: 1051;
}

.segment-card .dropdown-menu {
    z-index: 1052 !important;
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    min-width: 160px;
}

/* Badge Styles */
.badge {
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
}

.badge.bg-primary {
    background-color: var(--accent-primary) !important;
    color: var(--bg-primary);
}

.badge.bg-success {
    background-color: #00b894 !important;
}

.badge.bg-danger {
    background-color: var(--accent-secondary) !important;
}

.badge.bg-warning {
    background-color: var(--accent-warning) !important;
    color: var(--bg-primary);
}

/* Progress Bar Styles */
.progress {
    background-color: var(--bg-tertiary);
    border-radius: 0.5rem;
}

.progress-bar {
    background-color: var(--accent-primary);
}

/* Alert Styles */
.alert {
    border-radius: 0.75rem;
    border: none;
}

.alert-success {
    background-color: rgba(0, 184, 148, 0.1);
    color: #00b894;
    border-left: 4px solid #00b894;
}

.alert-danger {
    background-color: rgba(255, 107, 107, 0.1);
    color: var(--accent-secondary);
    border-left: 4px solid var(--accent-secondary);
}

.alert-warning {
    background-color: rgba(255, 167, 38, 0.1);
    color: var(--accent-warning);
    border-left: 4px solid var(--accent-warning);
}

.alert-info {
    background-color: rgba(66, 165, 245, 0.1);
    color: var(--accent-info);
    border-left: 4px solid var(--accent-info);
}

/* Loading Spinner */
.spinner-border-primary {
    color: var(--accent-primary);
}

/* Main content adjustment for fixed sidebar */
main {
    margin-left: 16.666667%; /* col-lg-2 equivalent */
}

/* Responsive Design */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 250px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
    }

    .sidebar.show {
        left: 0;
    }

    main {
        margin-left: 0;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

/* Utility Classes */
.text-primary-custom {
    color: var(--accent-primary) !important;
}

.bg-primary-custom {
    background-color: var(--accent-primary) !important;
}

.border-primary-custom {
    border-color: var(--accent-primary) !important;
}

.shadow-custom {
    box-shadow: var(--shadow) !important;
}

.rounded-custom {
    border-radius: 1rem !important;
}

/* Users Page Specific Styles */
.table-responsive {
    border-radius: 0.5rem;
    background: var(--bg-tertiary);
}

.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
}

.form-text {
    color: var(--text-secondary);
}

.form-check-input:checked {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.form-check-label {
    color: var(--text-primary);
}

#userViewContent .table td {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

#userViewContent .table td:first-child {
    color: var(--text-primary);
    font-weight: 500;
}

/* Campaigns Page Specific Styles */
.template-block {
    background-color: #ffffff;
    border: 2px dashed #dee2e6 !important;
    transition: border-color 0.2s ease;
}

.template-block:hover {
    border-color: var(--accent-primary) !important;
}

.block-preview {
    min-height: 50px;
}

#templateBuilder {
    min-height: 400px;
    background-color: #f8f9fa;
}

#templatePreviewContent {
    min-height: 200px;
}

/* Segments Page Specific Styles */
.segment-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    z-index: 1;
}

.segment-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.segment-card .card-header {
    position: relative;
    z-index: 3;
}

.criteria-preview .badge {
    font-size: 0.75rem;
}

.criterion-item {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color) !important;
}

.criterion-item:hover {
    border-color: var(--accent-primary) !important;
}

/* Statistics Page Specific Styles */
.chart-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    /* padding: 1.5rem; */
}

.chart-card .chart-header {
    display: flex;
    justify-content: between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-card .chart-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.metric-card {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border: none;
    border-radius: 1rem;
    padding: 1.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-info));
}

.metric-card.primary::before {
    background: linear-gradient(90deg, var(--accent-primary), #00b894);
}

.metric-card.success::before {
    background: linear-gradient(90deg, #00b894, #00cec9);
}

.metric-card.warning::before {
    background: linear-gradient(90deg, var(--accent-warning), #fdcb6e);
}

.metric-card.danger::before {
    background: linear-gradient(90deg, var(--accent-secondary), #e17055);
}

.metric-card .metric-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.metric-card .metric-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-card .metric-icon {
    font-size: 2.5rem;
    opacity: 0.7;
    margin-bottom: 1rem;
}

.progress {
    background-color: var(--bg-tertiary);
    border-radius: 0.5rem;
    height: 8px;
}

.progress-bar {
    border-radius: 0.5rem;
}

.border {
    border-color: var(--border-color) !important;
}

/* Main Layout Specific Styles */
.logo-img {
    height: 40px;
}

/* Utils Debug Styles */
.trace-debug {
    position: absolute;
    width: 100%;
    margin: 0 auto;
    z-index: 999999;
    top: 0;
    left: 0;
    background: #333;
    color: white;
}

.trace-debug h5 {
    color: orange;
}

.trace-debug hr {
    border: 0;
    height: 1px;
    background: #888;
    background-image: linear-gradient(to right, #333, #888, #333);
}

.trace-debug .trace-content {
    padding: 10px;
}

.trace-debug .trace-footer {
    text-align: right;
    color: #888;
    font-size: 0.875rem;
}

.text-muted {
    color: var(--text-secondary) !important;
}

/* Email Preview Styles */
.email-preview-container {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    max-height: 600px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.email-client-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    padding: 8px 16px;
}

.email-client-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.email-client-buttons {
    display: flex;
    gap: 8px;
}

.email-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.email-btn-close {
    background: #ff5f57;
}

.email-btn-minimize {
    background: #ffbd2e;
}

.email-btn-maximize {
    background: #28ca42;
}

.email-client-title {
    font-size: 14px;
    font-weight: 500;
    color: #495057;
    display: flex;
    align-items: center;
}

.email-content {
    background: #ffffff;
    color: #333333;
}

.email-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #e9ecef;
}

.email-from {
    display: flex;
    align-items: center;
    gap: 12px;
}

.email-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.email-from-info {
    flex: 1;
}

.email-from-name {
    font-weight: 600;
    font-size: 16px;
    color: #212529;
    margin-bottom: 2px;
}

.email-from-email {
    font-size: 14px;
    color: #6c757d;
}

.email-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.email-date {
    font-size: 14px;
    color: #6c757d;
}

.email-actions {
    display: flex;
    gap: 4px;
}

.email-actions .btn {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 6px;
}

.email-subject {
    padding: 16px 24px 5px 16px;
    font-size: 18px;
    font-weight: 600;
    color: #212529;
    /* border-bottom: 1px solid #e9ecef; */
    background: #f8f9fa;
}

.email-preheader {
    padding: 0px 0px 24px 16px;
    font-size: 13px;
    color: #6c757d;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-style: italic;
    line-height: 1.4;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-body {
    /* padding: 24px; */
    line-height: 1.6;
    font-size: 14px;
    color: #333333;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
}

.email-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
}

.email-body p {
    margin-bottom: 16px;
}

.email-body h1, .email-body h2, .email-body h3 {
    color: #212529;
    margin-top: 24px;
    margin-bottom: 16px;
}

.email-body a {
    color: #0c91cf;
    text-decoration: none;
}

.email-body a:hover {
    text-decoration: underline;
}

.email-footer {
    padding: 20px 24px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.email-signature {
    display: flex;
    align-items: center;
    gap: 16px;
}

.signature-line {
    width: 2px;
    height: 40px;
    background: linear-gradient(135deg, #0c91cf, #00d4aa);
    border-radius: 1px;
}

.signature-text {
    flex: 1;
}

.signature-text .fw-bold {
    font-weight: 600;
    color: #212529;
    margin-bottom: 2px;
}

.signature-text .text-muted {
    font-size: 14px;
    color: #6c757d;
}

/* Responsive email preview */
@media (max-width: 768px) {
    .email-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .email-meta {
        align-items: flex-start;
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
    }

    .email-actions {
        order: -1;
    }
}