/* Core App Frame */
.crm-app-wrapper {
    margin: 20px 20px 0 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
.crm-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.crm-header-bar h2 { margin: 0; font-size: 20px; color: #23282d; }

.crm-app-container {
    display: grid;
    grid-template-columns: 340px 1fr 380px;
    gap: 15px;
    height: calc(100vh - 140px);
}

/* Glassmorphism Panel Cards */
.crm-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.crm-card h3 { 
    margin-top: 0; 
    margin-bottom: 15px; 
    font-size: 16px; 
    border-bottom: 1px solid #edf2f7; 
    padding-bottom: 10px;
    color: #4a5568;
}
.crm-card h3 .dashicons { vertical-align: text-bottom; margin-right: 5px; }

/* Custom Form Element Controls */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; color: #4a5568; font-size: 13px; }
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}
.form-control:focus { border-color: #3182ce; box-shadow: 0 0 0 3px rgba(66,153,225,0.5); outline: none; }
.crm-checkbox-group label { display: block; font-weight: normal; margin-bottom: 4px; font-size: 13px; }

/* Button Matrices */
.btn-primary-crm { background: #3182ce; color: #fff; border: none; padding: 10px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.btn-primary-crm:disabled { background: #cbd5e0; cursor: not-allowed; }
.crm-btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.btn-action { background: #edf2f7; border: 1px solid #cbd5e0; padding: 12px; border-radius: 6px; cursor: pointer; font-weight: 500; transition: background 0.2s; }
.btn-action:hover { background: #e2e8f0; }
.btn-success-crm { background: #38a169; color: white; border: none; padding: 12px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn-danger-crm { background: #e53e3e; color: white; border: none; padding: 12px; border-radius: 6px; cursor: pointer; font-weight: 600; }

/* Custom Action Center Tabs */
.crm-tabs-nav { display: flex; border-bottom: 2px solid #edf2f7; margin-bottom: 15px; }
.tab-btn { background: none; border: none; padding: 10px 15px; cursor: pointer; font-weight: 600; color: #718096; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab-btn.active { color: #3182ce; border-bottom-color: #3182ce; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* WhatsApp Style Layout Structure */
.crm-pane-timeline { background: #f7fafc; padding: 15px; }
.crm-timeline-body { flex: 1; overflow-y: auto; padding: 10px; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 10px; }
.crm-timeline-footer { height: 50px; }
.crm-timeline-footer .input-group { display: flex; gap: 5px; }
.btn-send { background: #38a169; color: white; border: none; border-radius: 6px; width: 45px; cursor: pointer; }

/* Chat Bubbles Dynamic Render */
.chat-bubble { max-width: 85%; padding: 8px 12px; border-radius: 8px; margin-bottom: 8px; font-size: 13px; line-height: 1.4; }
.chat-bubble.left { background: #edf2f7; align-self: flex-start; border-top-left-radius: 0; }
.chat-bubble.right { background: #e2f7cb; align-self: flex-end; margin-left: auto; border-top-right-radius: 0; }
.system-log-bubble { background: #fffaf0; border: 1px solid #feebc8; color: #dd6b20; text-align: center; width: 90%; margin: 8px auto; border-radius: 4px; font-size: 11px; padding: 4px; }

/* Metrics Grid Configuration */
.crm-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 20px;
}
.metric-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    border-left: 5px solid #ccc;
}
.metric-card h3 { margin: 0; font-size: 14px; color: #64748b; text-transform: uppercase; }
.metric-card .count-value { font-size: 28px; font-weight: 700; margin-top: 10px; color: #1e293b; }

.card-blue { border-left-color: #3b82f6; }
.card-orange { border-left-color: #f97316; }
.card-green { border-left-color: #10b981; }

/* Admin Modal Layout Window */
.crm-custom-modal {
    position: fixed;
    z-index: 99999;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
}
.modal-content-frame {
    background: #fff;
    padding: 25px;
    border-radius: 10px;
    width: 450px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}
.form-group-admin { margin-bottom: 12px; }
.form-group-admin label { display: block; font-weight: 600; font-size: 12px; margin-bottom: 4px; color: #334155;}
.form-control-admin { width: 100%; padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 4px; }

/* Custom Importer & Duty Panel Box CSS */
.crm-upload-box {
    border: 2px dashed #cbd5e1;
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}
.import-row {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
}
.attendance-card {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 15px;
}
.attendance-card h4 { margin-top: 0; color: #334155; }
/* Smart stage filtering and reminder alert polish */
.agent-stage-card.active {
    outline: 2px solid #3b82f6;
    transform: translateY(-1px);
}
.agent-stage-card small {
    color: #64748b;
    display: block;
    margin-top: 6px;
}
.admin-dialer-container .crm-card {
    min-height: 420px;
}
#br-crm-alert-popup .button {
    border-radius: 6px;
}


/* Frontend shortcode + mobile app dashboard */
.br-crm-frontend-app {
    max-width: 1280px;
    margin: 0 auto;
    padding: 10px;
    background: #f1f5f9;
    min-height: 100vh;
}
.br-crm-login-required {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 22px;
    margin: 20px auto;
    max-width: 520px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(15,23,42,.08);
}
.br-crm-direct-call,
.br-crm-call-now-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 6px !important;
    border-radius: 10px !important;
    font-weight: 700 !important;
    text-decoration: none !important;
}
.br-crm-call-now-btn {
    width: 100%;
    padding: 12px 10px;
    background: #16a34a;
    color: #fff !important;
    margin-top: 10px !important;
    box-sizing: border-box;
}
.br-crm-call-now-btn[aria-disabled="true"] {
    background: #94a3b8;
    pointer-events: none;
}

@media (max-width: 782px) {
    body .br-crm-frontend-app,
    body .crm-app-wrapper.br-crm-mobile-ready {
        margin: 0 !important;
        padding: 8px !important;
        width: 100% !important;
        box-sizing: border-box;
        font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }
    .br-crm-mobile-ready .crm-header-bar {
        position: sticky;
        top: 0;
        z-index: 1000;
        display: block !important;
        border-radius: 0 0 18px 18px !important;
        padding: 14px !important;
        margin: -8px -8px 12px -8px !important;
        box-shadow: 0 12px 24px rgba(15,23,42,.18);
    }
    .br-crm-mobile-ready .crm-header-bar h2 {
        font-size: 17px !important;
        margin-bottom: 12px !important;
    }
    .br-crm-mobile-ready .crm-top-nav-links {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        gap: 7px !important;
    }
    .br-crm-mobile-ready .crm-nav-btn {
        width: 100%;
        min-height: 44px;
        padding: 8px 4px !important;
        border-radius: 12px !important;
        font-size: 11px !important;
        line-height: 1.15;
    }
    .br-crm-mobile-ready .crm-metrics-grid,
    .br-crm-mobile-ready .crm-app-container,
    .br-crm-mobile-ready .crm-btn-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        height: auto !important;
    }
    .br-crm-mobile-ready .metric-card,
    .br-crm-mobile-ready .crm-card {
        border-radius: 18px !important;
        padding: 14px !important;
        box-shadow: 0 8px 20px rgba(15,23,42,.07) !important;
        overflow: visible !important;
    }
    .br-crm-mobile-ready .metric-card .count-value {
        font-size: 25px !important;
    }
    .br-crm-mobile-ready table.wp-list-table,
    .br-crm-mobile-ready table.wp-list-table thead,
    .br-crm-mobile-ready table.wp-list-table tbody,
    .br-crm-mobile-ready table.wp-list-table tr,
    .br-crm-mobile-ready table.wp-list-table th,
    .br-crm-mobile-ready table.wp-list-table td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box;
    }
    .br-crm-mobile-ready table.wp-list-table thead {
        display: none !important;
    }
    .br-crm-mobile-ready table.wp-list-table tr {
        background: #fff !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 16px !important;
        margin-bottom: 10px !important;
        padding: 10px !important;
        box-shadow: 0 6px 16px rgba(15,23,42,.06) !important;
    }
    .br-crm-mobile-ready table.wp-list-table td {
        border: none !important;
        padding: 6px 4px !important;
        font-size: 13px !important;
    }
    .br-crm-mobile-ready table.wp-list-table td:last-child {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .br-crm-mobile-ready .button,
    .br-crm-mobile-ready button,
    .br-crm-mobile-ready input,
    .br-crm-mobile-ready select,
    .br-crm-mobile-ready textarea {
        min-height: 44px;
        font-size: 15px !important;
        border-radius: 12px !important;
    }
    .br-crm-mobile-ready .crm-tabs-nav {
        overflow-x: auto;
        gap: 8px;
        border-bottom: none !important;
        padding-bottom: 4px;
    }
    .br-crm-mobile-ready .tab-btn {
        flex: 0 0 auto;
        background: #e2e8f0 !important;
        border-radius: 999px !important;
        border: none !important;
        margin: 0 !important;
        padding: 10px 13px !important;
    }
    .br-crm-mobile-ready .tab-btn.active {
        background: #2563eb !important;
        color: #fff !important;
    }
    .br-crm-mobile-ready .crm-timeline-body {
        height: 52vh !important;
        max-height: 520px;
        min-height: 320px;
        border-radius: 16px !important;
    }
    .br-crm-mobile-ready .chat-bubble {
        max-width: 92% !important;
        font-size: 13px !important;
    }
    #br-crm-alert-popup {
        right: 10px !important;
        left: 10px !important;
        bottom: 10px !important;
        width: auto !important;
        border-radius: 18px !important;
    }
}
