/***********************************************/
/* COFFEE Application - Custom CSS */
/* Institutional Corporate Design Colors */
/***********************************************/

/* Corporate Color Variables */
:root {
    --primary-blue: #003366;        /* Primary institutional blue */
    --primary-blue-light: #0066cc;  /* Lighter blue for interactions */
    --primary-blue-dark: #002244;   /* Darker blue for emphasis */
    --accent-blue: #4a90e2;         /* Accent blue */
    
    /* Transparent variations */
    --primary-blue-alpha-90: rgba(0, 51, 102, 0.9);   /* 90% opacity */
    --primary-blue-alpha-80: rgba(0, 51, 102, 0.8);   /* 80% opacity */
    --primary-blue-alpha-70: rgba(0, 51, 102, 0.7);   /* 70% opacity */
    --primary-blue-alpha-20: rgba(0, 51, 102, 0.2);   /* 20% opacity */
    --primary-blue-alpha-10: rgba(0, 51, 102, 0.1);   /* 10% opacity */
    
    /* Gradient variations */
    --primary-gradient: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%);
    --primary-gradient-soft: linear-gradient(135deg, var(--primary-blue-alpha-80) 0%, var(--primary-blue-light) 100%);
    --primary-gradient-subtle: linear-gradient(135deg, var(--primary-blue-alpha-70) 0%, rgba(74, 144, 226, 0.8) 100%);
    
    --light-gray: #f8f9fa;          /* Light gray backgrounds */
    --border-color: #dee2e6;        /* Border color */
    --text-primary: #2c3e50;        /* Primary text color */
    --text-muted: #6c757d;          /* Muted text color */
}

/* Base Layout */
body {
    padding-top: 56px; /* Navbar height */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--light-gray);
}

/* Disable transitions during page load */
.preload .sidebar,
.preload .content-container,
.preload .sidebar-logo,
.preload .sidebar-logo *,
.preload .dev-footer,
.preload .dev-footer * {
    transition: none !important;
}

.preload .content-container {
    opacity: 0;
}

/***********************************************/
/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1040;
    background-color: white !important;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.navbar .navbar-brand {
    color: var(--text-primary) !important;
    font-weight: 600;
}

.navbar .navbar-toggler {
    border-color: var(--border-color);
    color: var(--text-primary);
}

.navbar .navbar-toggler:focus {
    box-shadow: 0 0 0 0.25rem rgba(70, 144, 226, 0.15);
}

/* Center Brand Logo */
.navbar .navbar-brand {
    margin: 0 auto;
    display: flex;
    align-items: center;
}

@media (min-width: 992px) {
    .navbar .navbar-brand {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }
}

/***********************************************/
/* Sidebar */
.sidebar {
    width: 200px;
    background-color: white;
    overflow-y: auto;
    transition: width 0.3s ease-in-out;
    border-right: 2px solid var(--border-color);
    height: calc(100vh - 56px);
    position: fixed;
    top: 56px;
    left: 0;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
}

.sidebar.minimized {
    width: 80px;
}

/* Sidebar Logo */
.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 15px;
    margin-bottom: 20px;
    border-bottom: 1px solid #e9ecef;
    transition: all 0.3s ease-in-out;
}

.sidebar-logo .logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    transition: all 0.3s ease-in-out;
}

.sidebar-logo .logo-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-left: 10px;
    white-space: nowrap;
    transition: all 0.3s ease-in-out;
}

/* Minimized sidebar logo styles */
.sidebar.minimized .sidebar-logo {
    padding: 20px 5px;
    flex-direction: column;
    gap: 5px;
}

.sidebar.minimized .sidebar-logo .logo-img {
    width: 24px;
    height: 24px;
}

.sidebar.minimized .sidebar-logo .logo-text {
    font-size: 0.7rem;
    margin-left: 0;
    text-align: center;
    line-height: 1;
}

/* Sidebar Navigation */
.sidebar .nav {
    margin-top: 20px;
}

.sidebar .nav-item {
    margin-bottom: 10px;
}

.sidebar .nav-link {
    color: var(--text-primary);
    padding: 12px 15px;
    display: flex;
    align-items: center;
    font-size: 14px;
    border-radius: 6px;
    margin: 2px 8px;
    transition: all 0.3s ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: var(--primary-gradient-soft);
    color: white;
    transform: translateX(4px);
    box-shadow: 0 2px 8px var(--primary-blue-alpha-20);
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
}

.sidebar.minimized .nav-link span {
    display: none;
}

.sidebar.minimized .nav-link {
    justify-content: center;
}

/* Navigation section header styling */
.nav-section-header {
    color: var(--primary-blue-dark);
    padding: 12px 15px;
    display: flex;
    align-items: center;
    font-size: 13px;
    font-weight: 700;
    margin-top: 20px;
    margin-bottom: 8px;
    border-bottom: 2px solid var(--accent-blue);
    cursor: default;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-section-header i {
    width: 20px;
    text-align: center;
    color: var(--accent-blue);
}

.sidebar.minimized .nav-section-header span {
    display: none;
}

.sidebar.minimized .nav-section-header {
    justify-content: center;
    border-bottom: none;
    padding: 10px 5px;
}

/* Sidebar Toggle Button */
#sidebarCollapse {
    color: var(--text-primary);
    font-size: 1.25rem;
    border: none;
    background: none;
    transition: all 0.3s ease;
}

#sidebarCollapse:hover {
    color: var(--primary-blue);
    transform: scale(1.05);
}

/***********************************************/
/* Content Area */
.content-container {
    margin-left: 200px;
    padding: 20px;
    flex: 1;
    transition: margin-left 0.3s ease-in-out;
}

body.sidebar-minimized .content-container {
    margin-left: 80px;
    transition: margin-left 0.3s ease-in-out;
}

/***********************************************/
/* Developer Footer */
.dev-footer {
    position: fixed;
    bottom: 10px;
    left: 10px;
    width: 180px;
    z-index: 1000;
    background: rgba(248, 249, 250, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.75rem;
    color: #6c757d;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease-in-out;
}

.dev-footer:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dev-footer .dev-links {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
}

.dev-footer .github-link {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #333;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.dev-footer .github-link:hover {
    color: #0066cc;
}

.dev-footer .github-link .profile-logo {
    width: 16px;
    height: 16px;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.dev-footer .version {
    font-size: 0.7rem;
    color: #999;
    font-weight: normal;
}

/* Adjust for minimized sidebar */
body.sidebar-minimized .dev-footer {
    width: 60px;
    padding: 6px 8px;
}

body.sidebar-minimized .dev-footer .dev-links {
    justify-content: center;
}

body.sidebar-minimized .dev-footer .github-link {
    font-size: 0;
    justify-content: center;
}

body.sidebar-minimized .dev-footer .github-link .profile-logo {
    margin-right: 0;
}

body.sidebar-minimized .dev-footer .version {
    text-align: center;
    font-size: 0.65rem;
}

/***********************************************/
/* Auth Forms */
.login-card {
    border-radius: 12px;
    font-family: inherit;
    max-width: 400px;
    margin: 2rem auto;
}

.login-card .card-title {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1.5rem;
}

.login-card .form-control {
    border-radius: 8px;
    border: 1px solid #e1e5e9;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

.login-card .form-control:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.login-card .form-label {
    font-weight: 500;
    color: #495057;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.login-card .btn-primary,
.btn-primary {
    background: var(--primary-gradient);
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.login-card .btn-primary:hover,
.btn-primary:hover {
    background: var(--primary-gradient-soft);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--primary-blue-alpha-20);
}

.login-card .btn-primary::before,
.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.login-card .btn-primary:hover::before,
.btn-primary:hover::before {
    left: 100%;
}

.login-card .btn-primary:active,
.btn-primary:active {
    background: linear-gradient(135deg, var(--primary-blue-dark) 0%, var(--primary-blue) 100%);
    transform: translateY(0px);
}

/* Secondary buttons */
.btn-outline-primary {
    color: var(--primary-blue);
    border: 2px solid var(--primary-blue-alpha-70);
    background: transparent;
    transition: all 0.3s ease;
}

.btn-outline-primary:hover {
    background: var(--primary-gradient-subtle);
    border-color: transparent;
    color: white;
    box-shadow: 0 2px 8px var(--primary-blue-alpha-20);
}

.btn-success {
    background-color: #28a745;
    border-color: #28a745;
}

.btn-danger {
    background-color: #dc3545;
    border-color: #dc3545;
}

.login-card a,
a {
    color: var(--primary-blue);
    transition: color 0.3s ease;
    text-decoration: none;
}

.login-card a:hover,
a:hover {
    color: var(--primary-blue-light);
    text-decoration: underline;
}

/***********************************************/
/* Helpfulness Score Rating Component */
.nps-bar {
    flex-wrap: wrap;
}

.nps-segment {
    width: 30px;
    height: 30px;
    background-color: #f8f9fa;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    margin: 0 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #333;
}

.nps-segment:hover {
    background: var(--primary-blue-alpha-10);
    border-color: var(--primary-blue-alpha-70);
    transform: scale(1.05);
}

.nps-segment.nps-selected {
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px var(--primary-blue-alpha-20);
}

/***********************************************/
/* Loading Bar */
#topLoadingBar {
    position: fixed;
    top: 56px;
    left: 0;
    width: 100%;
    z-index: 1050;
}

#topLoadingBarProgress {
    background: var(--primary-gradient-soft);
    border-radius: 2px;
}

/***********************************************/
/* Feedback Page Styles */
.feedback-task-header {
    background: linear-gradient(135deg, var(--light-gray) 0%, #e9ecef 100%);
    border: 1px solid var(--border-color) !important;
    border-radius: 12px;
    color: var(--text-primary);
    border-left: 4px solid var(--primary-blue);
}

.feedback-task-header h3 {
    color: var(--text-primary);
    font-weight: 600;
}

.feedback-card {
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    background: white;
    position: relative;
    overflow: hidden;
}

.feedback-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-gradient-subtle);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.feedback-card:hover::before {
    opacity: 1;
}

.feedback-card:hover {
    box-shadow: 0 4px 12px var(--primary-blue-alpha-10);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.feedback-card .card-header {
    background: linear-gradient(135deg, var(--light-gray) 0%, #e9ecef 100%);
    border-bottom: 2px solid var(--border-color);
    border-radius: 12px 12px 0 0;
}

.feedback-card .card-header h5 {
    color: var(--primary-blue-dark);
    font-weight: 600;
}

.ai-response {
    /* use a clean, readable sans-serif rather than monospaced */
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.3;
    /* ensure the box looks like a text area even when it's a div */
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: .25rem;
    padding: .5rem .75rem;
    min-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap; /* preserve newlines for rendered markdown */
}

/* emphasize code spans within markdown for readability */
.ai-response code {
    font-family: 'Courier New', monospace;
    background-color: #f1f1f1;
    padding: 0 2px;
    border-radius: 3px;
}

/* reduce spacing around horizontal rules */
.ai-response hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: .6rem 0;
}

/* adjust headings generated by marked */
.ai-response h1, .ai-response h2 {
    margin-top: .6rem;
    margin-bottom: .3rem;
    font-weight: 600;
}

.ai-response h3 {
    margin-top: .5rem;
    margin-bottom: .25rem;
    font-weight: 600;
}


.ai-response p {
    margin-bottom: .4rem;
}


/* reduce spacing for lists */
.ai-response ul,
.ai-response ol {
    margin-top: 0.2rem;
    margin-bottom: 0.2rem;
    padding-left: 1rem;
}

.ai-response ul li,
.ai-response ol li {
    margin-bottom: 0.2rem;
}

.ai-response:disabled {
    background-color: #f8f9fa;
    color: #495057;
}

/* Helpfulness Score Rating improvements */
.nps-container {
    border-radius: 12px;
}

.nps-bar {
    gap: 4px;
    margin: 1rem 0;
}

.nps-segment {
    min-width: 32px;
    min-height: 32px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.nps-segment:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.nps-segment.nps-selected {
    transform: scale(1.1);
    box-shadow: 0 4px 12px var(--primary-blue-alpha-20);
    background: var(--primary-gradient);
}

/* User solution form improvements */
.user-solution-card {
    border-radius: 12px;
    min-height: 400px;
}

.user-solution-form .form-control {
    border-radius: 8px;
    font-size: 0.95rem;
    padding: 0.75rem;
}

.user-solution-form .btn {
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
}

.feedback-disclaimer {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    font-size: 0.85rem;
    line-height: 1.4;
}

/***********************************************/
/* Responsive Design */
@media (max-width: 1200px) {
    .feedback-card .card-header h5 {
        font-size: 1rem;
    }
    
    .ai-response {
        font-size: 0.85rem;
    }
}

@media (max-width: 992px) {
    /* Stack layout on tablets */
    .feedback-row {
        flex-direction: column;
    }
    
    .user-solution-section,
    .feedback-sections {
        max-width: 100%;
    }
    
    .nps-bar {
        justify-content: center;
        flex-wrap: wrap;
        gap: 6px;
    }
}

/* Offcanvas full height for all screen sizes */
.offcanvas {
    height: 100vh !important;
}

@media (max-width: 768px) {
    /* Mobile optimizations */
    body {
        padding-top: 50px; /* Reduce navbar padding on mobile */
    }
    
    .content-container {
        padding: 10px;
    }
    
    /* Feedback page mobile styles */
    .feedback-task-header {
        margin-bottom: 1rem;
        padding: 1rem;
    }
    
    .feedback-task-header h3 {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }
    
    .feedback-card {
        margin-bottom: 1rem;
    }
    
    .feedback-card .card-header {
        padding: 0.75rem;
    }
    
    .feedback-card .card-header h5 {
        font-size: 0.95rem;
        margin-bottom: 0;
    }
    
    .feedback-card .card-body {
        padding: 0.75rem;
    }
    
    .ai-response {
        min-height: 100px;
        font-size: 0.8rem;
    }
    
    /* User solution form mobile */
    .user-solution-card .card-body {
        padding: 1rem;
    }
    
    .user-solution-form .form-control {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }
    
    .user-solution-form .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Helpfulness Score mobile improvements */
    .nps-segment {
        min-width: 28px;
        min-height: 28px;
        font-size: 0.8rem;
        margin: 2px;
    }
    
    .nps-bar {
        gap: 2px;
        padding: 0 0.5rem;
    }
    
    /* Offcanvas improvements for mobile */
    .offcanvas {
        width: 90vw !important;
        max-width: 400px;
        height: 100vh !important;
    }
    
    .offcanvas-body {
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    /* Developer footer mobile adjustments */
    .dev-footer {
        left: 5px;
        bottom: 5px;
        font-size: 0.7rem;
        padding: 6px 10px;
        width: auto;
    }
    
    body.sidebar-minimized .dev-footer {
        width: auto;
        padding: 6px 10px;
    }
    
    body.sidebar-minimized .dev-footer .github-link {
        font-size: 0.7rem;
    }
}

/***********************************************/
/* Start Page / Feedback List Styles */

/* Optimize top spacing */
.container-fluid.py-2 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
}

/* Filter Section */
.filter-section {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px var(--primary-blue-alpha-10);
    border: 1px solid var(--border-color);
}

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

.filter-form .form-select-sm {
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.filter-form .form-select-sm:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 0.2rem var(--primary-blue-alpha-20);
}

/* Feedback Task Cards */
.feedback-task-card {
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.feedback-task-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-gradient-subtle);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.feedback-task-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px var(--primary-blue-alpha-10);
    border-color: var(--accent-blue);
}

.feedback-task-card:hover::before {
    opacity: 1;
}

.feedback-task-card .card-title {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.1rem;
    line-height: 1.3;
}

/* Compact metadata layout */
.feedback-task-card .task-meta-compact {
    font-size: 0.8rem;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.feedback-task-card .task-meta-compact .meta-item {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.feedback-task-card .task-meta-compact .meta-item i {
    font-size: 0.75rem;
    color: var(--primary-blue);
    opacity: 0.8;
}

.feedback-task-card .task-meta-compact .meta-separator {
    color: var(--border-color);
    font-weight: bold;
    padding: 0 0.1rem;
}

.feedback-task-card .card-text {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-muted);
}

/* Modern Button Styles for Start Page */
.feedback-task-card .btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.filter-section .btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 6px;
}

/* Empty State */
.empty-state {
    background: white;
    border-radius: 12px;
    border: 2px dashed var(--border-color);
    margin: 2rem 0;
}

.empty-state .empty-icon {
    opacity: 0.6;
}

/* Responsive Improvements */
@media (max-width: 1200px) {    
    .filter-section {
        padding: 1rem;
    }
}

@media (max-width: 992px) {    
    .filter-section {
        padding: 1rem;
    }
    
    .feedback-task-card .card-title {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {    
    .filter-section {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .filter-form .row.g-3 {
        --bs-gutter-x: 0.75rem;
        --bs-gutter-y: 0.75rem;
    }
    
    .feedback-task-card {
        margin-bottom: 1rem;
    }
    
    .feedback-task-card .card-body {
        padding: 1rem;
    }
    
    .feedback-task-card .btn-sm {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
    
    .feedback-task-card .task-meta-compact {
        font-size: 0.75rem;
        gap: 0.3rem;
    }
    
    .feedback-task-card .task-meta-compact .meta-item i {
        font-size: 0.7rem;
    }
}

.chart-wrap { height: 220px; }
#calls_line_chart { max-height: 100%; }

.metrics-chart-row .metrics-chart-col {
    flex: 0 0 100%;
    max-width: 100%;
}

@media (min-width: 1400px) {
    .metrics-chart-row .metrics-chart-col {
        flex: 0 0 33.3333%;
        max-width: 33.3333%;
    }
}
