/* MISA AMIS aiMarketing Modern CSS System */
:root {
    --primary-red: #4f46e5; /* Indigo primary for premium look */
    --primary-orange: #ff6000;
    --primary-blue: #0284c7;
    --bg-gray: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --success-green: #10b981;
    --danger-red: #ef4444;
    --sidebar-width: 260px;
    --header-height: 64px;
    --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-gray);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    font-size: 14px;
}

/* Sidebar Layout */
.sidebar {
    width: var(--sidebar-width);
    background-color: #ffffff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
}

.brand-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid #f1f5f9;
}

.badge-unlimited {
    background-color: rgba(245, 158, 11, 0.12);
    color: #d97706;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.nav-menu {
    flex: 1;
    overflow-y: auto;
    padding: 20px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #475569;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background-color: #f1f5f9;
    color: #0f172a;
}

.nav-item.active {
    background-color: #4f46e5;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.25);
}

.nav-item.active svg {
    stroke: #ffffff;
}

.nav-item svg {
    stroke: #64748b;
    transition: stroke 0.2s;
}

.nav-item:hover svg {
    stroke: #0f172a;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid #f1f5f9;
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
}

/* Main Container */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* Top App Header */
.top-header {
    height: var(--header-height);
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.user-role-badge {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
}
.role-admin { background-color: #ef4444; }
.role-manager { background-color: #3b82f6; }
.role-staff { background-color: #10b981; }

.header-icons {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Content Area */
.content-body {
    padding: 32px;
    box-sizing: border-box;
    max-width: 100%;
}

.dynamic-view-section {
    max-width: 100%;
    box-sizing: border-box;
}

/* Breadcrumb & Campaign Header */
.campaign-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.campaign-title-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-btn {
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    background: #f1f5f9;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}
.back-btn:hover {
    background: #e2e8f0;
}

.campaign-name {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
}

.campaign-status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.dot-green {
    width: 8px;
    height: 8px;
    background-color: var(--success-green);
    border-radius: 50%;
    display: inline-block;
}

.tag-good {
    background-color: #dcfce7;
    color: #15803d;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 12px;
}

.campaign-actions {
    display: flex;
    gap: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

/* Tabs Bar */
.tabs-nav {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--card-bg);
    padding: 0 24px;
    margin-bottom: 24px;
    border-radius: 8px;
    overflow-x: auto;
}

.tab-item {
    padding: 16px 20px;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.tab-item:hover {
    color: var(--text-primary);
}

.tab-item.active {
    color: var(--primary-red);
    font-weight: 700;
    border-bottom-color: var(--primary-red);
}

/* Red Outlined Container from Mockup Image */
.metrics-section-container {
    border: 1px solid var(--border-color);
    border-top: 4px solid var(--primary-red);
    border-radius: 8px;
    background-color: var(--card-bg);
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.metrics-block {
    margin-bottom: 24px;
}

.metrics-block:last-child {
    margin-bottom: 0;
    padding-top: 24px;
    border-top: 1px solid #f1f5f9;
}

.block-title {
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 20px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    text-align: center;
}

.metric-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.metric-card:not(:last-child)::after {
    content: "";
    position: absolute;
    right: 0;
    top: 15%;
    height: 70%;
    width: 1px;
    background-color: #f1f5f9;
}

.metric-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.metric-value-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.metric-value {
    font-size: 28px;
    font-weight: 800;
    color: #0f172a;
}

.change-tag {
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 2px;
}

.change-tag.up {
    color: var(--success-green);
    background-color: #ecfdf5;
    padding: 1px 6px;
    border-radius: 4px;
}

.metric-subcount {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Bottom Grid Layout */
.bottom-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 32px;
}

.card-box {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.expand-link {
    color: var(--primary-blue);
    font-size: 12px;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

/* Email Banner Mockup Preview */
.banner-preview-box {
    background: linear-gradient(135deg, #4f46e5, #1e1b4b);
    border-radius: 10px;
    padding: 32px;
    color: white;
    text-align: center;
}

.banner-preview-box h3 {
    font-size: 24px;
    font-weight: 800;
    color: #fef08a;
    margin-bottom: 8px;
}

.banner-preview-box p {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 20px;
}

.banner-cta-btn {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    color: white;
    padding: 12px 28px;
    font-weight: 700;
    border-radius: 24px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.4);
    transition: all 0.2s;
}

.banner-cta-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(239, 68, 68, 0.5);
}

/* Device Donut Chart Box */
.chart-container-box {
    display: flex;
    align-items: center;
    justify-content: space-around;
    min-height: 200px;
    gap: 16px;
}

.chart-canvas-wrapper {
    position: relative;
    width: 150px;
    height: 150px;
}

.chart-center-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    pointer-events: none;
    line-height: 1.3;
}

.chart-center-label strong {
    display: block;
    font-size: 18px;
    color: #0f172a;
    font-weight: 800;
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-color.desktop { background-color: #f59e0b; }
.legend-color.mobile { background-color: #10b981; }
.legend-color.other { background-color: #3b82f6; }

/* Modal Dialog Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-dialog {
    background-color: white;
    border-radius: 16px;
    width: 580px;
    max-width: 90%;
    padding: 32px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
}

.modal-close {
    cursor: pointer;
    font-size: 24px;
    color: var(--text-secondary);
    transition: color 0.2s;
}
.modal-close:hover {
    color: #0f172a;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #334155;
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Custom Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
}
th {
    font-weight: 600;
    color: #475569;
    padding: 12px;
}
td {
    padding: 12px;
    color: #334155;
}

.progress-bar-outer {
    background-color: #f1f5f9 !important;
}

.progress-bar-inner {
    background: linear-gradient(to right, #4f46e5, #818cf8) !important;
}

/* System Workflow Diagram */
.system-workflow-container {
    display: flex;
    flex-direction: column;
    padding: 10px 0;
}

.workflow-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s ease-in-out;
}

.workflow-item:hover {
    background-color: #f8fafc;
    transform: translateX(4px);
}

.workflow-node-icon {
    font-size: 20px;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.1);
}

.workflow-node-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.workflow-node-text strong {
    font-size: 13px;
    color: #1e293b;
}

.workflow-node-text span {
    font-size: 11px;
    color: #64748b;
}

.workflow-line-connector {
    width: 2px;
    height: 16px;
    background: #cbd5e1;
    margin-left: 31px;
}

/* Toast Notification System */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 400px;
    width: calc(100% - 40px);
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 12px;
    background: #ffffff;
    color: var(--text-primary);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
    font-size: 13px;
    font-weight: 500;
    border-left: 4px solid var(--primary-red);
    transform: translateX(120%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    opacity: 0;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.toast-body {
    flex: 1;
    line-height: 1.4;
}

.toast-title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 2px;
}

.toast-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.toast-success { border-left-color: #10b981; }
.toast-success .toast-icon { color: #10b981; }

.toast-error { border-left-color: #ef4444; }
.toast-error .toast-icon { color: #ef4444; }

.toast-warning { border-left-color: #f59e0b; }
.toast-warning .toast-icon { color: #f59e0b; }

.toast-info { border-left-color: #3b82f6; }
.toast-info .toast-icon { color: #3b82f6; }

/* Top Header sub-containers */
.top-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.logout-link {
    font-size: 13px;
    font-weight: 600;
    color: #ef4444;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid #fee2e2;
    border-radius: 8px;
    background: #fff5f5;
    transition: all 0.2s ease;
}

.logout-link:hover {
    background: #fee2e2;
    color: #dc2626;
    transform: translateY(-1px);
}

.mobile-toggle-btn {
    display: none;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    color: var(--text-primary);
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.mobile-toggle-btn:hover {
    background-color: #e2e8f0;
}

/* Sidebar Overlay Backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* Modal Enhancements */
.modal-dialog {
    animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
    0% { opacity: 0; transform: scale(0.95) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Responsive Table Wrapper */
.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #ffffff;
    -webkit-overflow-scrolling: touch;
}

/* Sleek Action Buttons */
.btn-action-edit {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: #e0e7ff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-action-edit:hover {
    background-color: #c7d2fe;
    color: #3730a3;
    transform: translateY(-1px);
}

.btn-action-delete {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-action-delete:hover {
    background-color: #fca5a5;
    color: #b91c1c;
    transform: translateY(-1px);
}

/* Responsive Grid Helper Classes */
.responsive-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.responsive-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

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

.responsive-grid-split {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 24px;
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 0px;
    }
    
    .sidebar {
        left: -260px;
        width: 260px;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .main-wrapper {
        margin-left: 0;
        width: 100%;
    }
    
    .top-header {
        padding: 0 20px;
    }
    
    .mobile-toggle-btn {
        display: inline-flex !important;
    }

    .header-brand-mobile {
        display: inline-flex !important;
    }
    
    .content-body {
        padding: 20px !important;
    }

    .responsive-grid-split > *,
    .responsive-grid-2 > *,
    .responsive-grid-3 > *,
    .responsive-grid-4 > * {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .responsive-grid-split {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .responsive-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Auto-responsive data tables vs info tables */
    .table-responsive-wrapper table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    .info-table,
    #view-smtp table,
    #view-settings table {
        display: table !important;
        width: 100% !important;
        white-space: normal !important;
        word-break: break-word !important;
    }

    .info-table td, .info-table th,
    #view-smtp td, #view-smtp th,
    #view-settings td, #view-settings th {
        white-space: normal !important;
        word-break: break-word !important;
    }

    #view-guide > div {
        flex-direction: column !important;
    }
    
    #view-guide > div > div:first-child {
        width: 100% !important;
    }
}

@media (max-width: 768px) {
    .metrics-grid,
    .responsive-grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    
    .responsive-grid-2,
    .responsive-grid-3 {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .modal-dialog {
        width: 92% !important;
        margin: 20px auto;
        padding: 20px !important;
        max-height: 85vh;
    }
    
    .top-header {
        height: auto;
        padding: 10px 16px;
    }
    
    .user-greeting {
        font-size: 12px;
    }

    .logout-text {
        display: none;
    }
    
    .campaign-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }
    
    .campaign-header .btn-primary, 
    .campaign-header button {
        width: 100%;
        justify-content: center;
    }
    
    .card-box {
        padding: 16px !important;
    }
}

@media (max-width: 480px) {
    .metrics-grid,
    .responsive-grid-4 {
        grid-template-columns: 1fr !important;
    }

    .content-body {
        padding: 12px !important;
    }
}

