/* --- CSS Variables (Green Theme) --- */
:root {
    --font-primary: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --color-primary: #10b981; /* Primary Green */
    --color-primary-dark: #059669;
    --color-primary-light: #d1fae5;
    --color-danger: #ef4444;
    --color-danger-dark: #b91c1c;
    --color-bg: #f8fafc; /* Light Gray Background */
    --color-card-bg: #ffffff;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-border: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius-sm: 6px;
    --border-radius-md: 10px;
    --transition-fast: all 0.2s ease-in-out;
}

/* --- Base & Reset --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-primary);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    margin-top: 70px; /* Space for fixed header */
}

h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    font-weight: 600;
}
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: var(--transition-fast);
}
a:hover { color: var(--color-primary-dark); }

/* --- Main Layout --- */
.container {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.card {
    background: var(--color-card-bg);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    margin-bottom: 2rem;
    overflow: hidden;
}

/* --- Header & Navigation --- */
.main-header {
    background: var(--color-card-bg);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    padding: 0 1.5rem;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.header-logo a {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.header-logo a:hover { color: var(--color-primary); }

.main-nav { display: flex; gap: 0.5rem; }
.main-nav a {
    color: var(--color-text-muted);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-fast);
}
.main-nav a i { margin-right: 6px; }
.main-nav a:hover,
.main-nav a.active {
    background-color: var(--color-primary-light);
    color: var(--color-primary-dark);
    text-decoration: none;
}

#mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-muted);
    cursor: pointer;
}

/* --- Footer --- */
.main-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-top: 2rem;
}

/* --- Global Form Styles --- */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: block;
    color: var(--color-text);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="url"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: var(--font-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    background: var(--color-bg);
    transition: var(--transition-fast);
    margin-bottom: 0; /* Change: remove default margin */
}

/* === বর্ডার কালার ফিক্স (আপনার অনুরোধ) === */
input:focus, select:focus {
    outline: none;
    border-color: var(--color-primary); /* ফোকাস করলে সবুজ বর্ডার হবে */
    box-shadow: 0 0 0 3px var(--color-primary-light); /* এবং একটি হালকা সবুজ আভা থাকবে */
}

/* === অ্যালাইনমেন্ট ফিক্স (আপনার অনুরোধ) === */
.form-group-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end; /* সব আইটেমকে (ইনপুট, বাটন) নিচে অ্যালাইন করে */
    margin-bottom: 2rem;
    border-bottom: 1px dashed var(--color-border);
    padding-bottom: 2rem;
}
.form-group-inline > div {
    flex: 1; /* প্রতিটি ইনপুট গ্রুপকে সমান জায়গা দেয় */
    min-width: 180px;
}
.form-group-inline > button {
    flex-shrink: 0; /* বাটন যেন সংকুচিত না হয় */
}

/* --- Button Styles --- */
.btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-primary);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    height: 47px; /* ইনপুট ফিল্ডের সাথে উচ্চতা মেলানোর জন্য */
}
.btn:hover:not(:disabled) {
    background: var(--color-primary-dark);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.btn:disabled {
    background: #a7f3d0;
    cursor: not-allowed;
    opacity: 0.7;
}
.btn-danger { background-color: var(--color-danger); }
.btn-danger:hover:not(:disabled) { background-color: var(--color-danger-dark); }
.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
    height: auto; /* ছোট বাটনের জন্য অটোহাইট */
}
.btn-full { width: 100%; }

/* --- Item List (for Companies/Customers) --- */
.item-list-container h3 {
    margin-top: 2rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.5rem;
}
.item-list {
    list-style: none;
    padding: 0;
}
.item-list li {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    margin-bottom: 1rem;
    background: #fafafa;
    transition: var(--transition-fast);
}
.item-list li:hover { box-shadow: var(--shadow-sm); }
.item-list .item-info {
    font-weight: 500;
    word-break: break-word;
}
.item-list .item-info span {
    color: var(--color-text-muted);
    font-weight: 400;
    margin-left: 0.5rem;
}
.item-list .item-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* --- Message & Loading Styles --- */
.message {
    padding: 1rem 1.2rem;
    border-radius: var(--border-radius-sm);
    margin-top: 1.5rem;
    font-weight: 500;
    text-align: center;
    border: 1px solid transparent;
}
.message.success {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    border-color: #a7f3d0;
}
.message.error {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}
.message.loading {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
/* CSS Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Home Page Hero --- */
.hero-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 3rem;
    padding: 3rem 0;
}
.hero-text h1 {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-text);
}
.hero-text .subtitle {
    font-size: 1.25rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}
.hero-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}
.hero-image img {
    width: 100%;
    max-width: 450px;
    height: auto;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
}

/* --- Upload Page Styles --- */
#upload-app .card { max-width: 600px; margin: 2rem auto; }
input[type="file"]#file-upload { display: none; }
.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 2rem;
    border: 2px dashed var(--color-border);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    background-color: var(--color-bg);
}
.file-upload-label:hover {
    border-color: var(--color-primary);
    background-color: var(--color-primary-light);
}
.file-upload-label i {
    font-size: 2.5rem;
    color: var(--color-primary);
}
.file-upload-label span { font-weight: 500; color: var(--color-text-muted); }
.file-upload-label span.file-name {
    color: var(--color-primary-dark);
    font-weight: 600;
}

/* --- Chat Page Styles --- */
.chat-container {
    max-width: 800px;
    margin: 2rem auto;
    background: var(--color-card-bg);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    overflow: hidden;
}
.chat-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    background: #fdfdfd;
}
.chat-controls .control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.chat-controls label {
    margin-bottom: 0;
    font-weight: 600;
    font-size: 0.9rem;
}
.chat-controls select,
.chat-controls input {
    margin-bottom: 0;
    padding: 0.5rem 0.8rem;
    height: 40px; /* ছোট ইনপুট হাইট */
}
.chat-controls select { flex: 1; }
.chat-controls input[type="number"] { width: 80px; }

.chat-window {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: var(--color-bg);
}
.message-item { margin-bottom: 1rem; }
.message-wrapper { display: flex; }
.message-wrapper.user { justify-content: flex-end; }
.message-wrapper.bot { justify-content: flex-start; }

.message-bubble {
    padding: 0.7rem 1.1rem;
    border-radius: 18px;
    max-width: 85%;
    line-height: 1.5;
    word-wrap: break-word;
}
.message-bubble.user {
    background: var(--color-primary);
    color: white;
    border-bottom-right-radius: 4px;
}
.message-bubble.bot {
    background: #e5e7eb;
    color: var(--color-text);
    border-bottom-left-radius: 4px;
}
/* Markdown formatting inside bubble */
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble ul, .message-bubble ol { margin: 10px 0 10px 20px; }
.message-bubble code {
    background: rgba(0,0,0,0.08);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
}
.message-bubble pre {
    background: #1f2937;
    color: #f9fafb;
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    overflow-x: auto;
    margin: 1rem 0;
}
.message-bubble pre code { background: none; padding: 0; }

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    background: #fdfdfd;
}
.chat-input-area input {
    flex: 1;
    margin-bottom: 0;
    height: 47px;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    body { margin-top: 60px; }
    .main-header { height: 60px; padding: 0 1rem; }
    
    .main-nav {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--color-card-bg);
        border-bottom: 1px solid var(--color-border);
        flex-direction: column;
        padding: 1rem;
        gap: 0;
        box-shadow: var(--shadow-md);
    }
    .main-nav.active { display: flex; }
    .main-nav a { padding: 0.8rem 1rem; }
    
    #mobile-menu-toggle { display: block; }
    
    .container { margin-top: 1rem; padding: 0 1rem; }
    .card { padding: 1.5rem; }
    h2 { font-size: 1.5rem; }

    .hero-section {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .hero-image { order: -1; }
    .hero-image img { margin: 0 auto; }
    .hero-actions { justify-content: center; }
    .hero-text h1 { font-size: 2.25rem; }

    .form-group-inline { flex-direction: column; align-items: stretch; }
    .form-group-inline > button { 
        height: 47px; /* মোবাইল ভিউতেও বাটন হাইট ঠিক রাখুন */
    }

    .item-list li { flex-direction: column; align-items: flex-start; }
    .item-list .item-actions { width: 100%; justify-content: flex-end; }
    
    .chat-container {
        height: calc(100vh - 60px); /* Full height on mobile */
        border: none;
        border-radius: 0;
        margin: -1rem; /* কন্টেইনারের প্যাডিং ওভাররাইড করে */
        width: 100vw;
    }
}
/* --- 
CSAT Modal Styles --- */
.csat-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.csat-modal {
    background: var(--color-card-bg);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    max-width: 450px;
    width: 90%;
    padding: 2rem;
    animation: slideUp 0.3s ease-out;
}

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

.csat-header {
    text-align: center;
    margin-bottom: 2rem;
}

.csat-header h3 {
    font-size: 1.5rem;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.csat-header p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.csat-body {
    margin-bottom: 2rem;
}

.star-rating {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.star {
    font-size: 3rem;
    color: #d1d5db;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.star:hover,
.star.selected {
    color: #fbbf24;
    transform: scale(1.1);
}

.star:active {
    transform: scale(0.95);
}

.rating-labels {
    display: flex;
    justify-content: space-between;
    padding: 0 1rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.csat-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.csat-actions .btn {
    flex: 1;
    max-width: 180px;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

/* --- End Conversation Button --- */
.btn-end-conversation {
    background: #ef4444;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    height: 40px;
}

.btn-end-conversation:hover:not(:disabled) {
    background: #dc2626;
}

.btn-end-conversation:disabled {
    background: #fca5a5;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Responsive adjustments for CSAT modal */
@media (max-width: 768px) {
    .csat-modal {
        width: 95%;
        padding: 1.5rem;
    }
    
    .star {
        font-size: 2.5rem;
    }
    
    .csat-actions {
        flex-direction: column;
    }
    
    .csat-actions .btn {
        max-width: 100%;
    }
}

/* --- Metrics Dashboard Styles --- */
#metrics-app .card h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.metrics-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    padding: 1.5rem;
    background: var(--color-bg);
    border-radius: var(--border-radius-sm);
    margin-top: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 180px;
}

.filter-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text);
    margin-bottom: 0;
}

.filter-group select,
.filter-group input[type="date"] {
    padding: 0.6rem 0.8rem;
    font-size: 0.95rem;
    height: auto;
}

.auto-refresh-toggle {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.auto-refresh-toggle label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
}

.auto-refresh-toggle input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.metric-card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
    display: flex;
    gap: 1rem;
}

.metric-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.metric-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.metric-icon i {
    font-size: 1.8rem;
}

.metric-content {
    flex: 1;
}

.metric-content h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.metric-description {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--color-border);
    border-radius: 10px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669);
    border-radius: 10px;
    transition: width 0.5s ease;
}

.star-rating-display {
    display: flex;
    gap: 0.25rem;
    margin: 0.5rem 0;
}

.star-rating-display .star {
    font-size: 1.5rem;
    color: #d1d5db;
}

.star-rating-display .star.filled {
    color: #fbbf24;
}

.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.chart-card {
    padding: 1.5rem;
}

.chart-card h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.chart-card canvas {
    max-height: 300px;
}

/* Responsive adjustments for metrics dashboard */
@media (max-width: 768px) {
    .metrics-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    .auto-refresh-toggle {
        margin-left: 0;
        justify-content: flex-start;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .metric-card {
        flex-direction: column;
        text-align: center;
    }
    
    .metric-icon {
        margin: 0 auto;
    }
    
    .charts-section {
        grid-template-columns: 1fr;
    }
    
    .chart-card canvas {
        max-height: 250px;
    }
}

@media (max-width: 480px) {
    .metric-value {
        font-size: 2rem;
    }
    
    .metric-icon {
        width: 50px;
        height: 50px;
    }
    
    .metric-icon i {
        font-size: 1.5rem;
    }
}
