/* ========================================
   Business Sustainability Management Platform
   Custom Styles
   ======================================== */

/* Sidebar */
#sidebar {
    flex: 0 0 250px;
    width: 250px;
    min-width: 250px;
    max-width: 250px;
    height: 100vh;
    position: sticky;
    top: 0;
    align-self: flex-start;
    overflow-y: auto;
    transition: flex-basis 0.3s ease, width 0.3s ease, min-width 0.3s ease, max-width 0.3s ease;
    display: flex;
    flex-direction: column;
}

#sidebar.collapsed {
    flex: 0 0 0;
    width: 0;
    min-width: 0;
    max-width: 0;
    overflow: hidden;
}

#main-content {
    min-width: 0;
    min-height: 100vh;
    background-color: #f8f9fa;
    transition: margin-left 0.3s ease;
}

#sidebar .nav-link {
    padding: 10px 15px;
    margin: 2px 0;
    transition: background-color 0.2s;
}

#sidebar .nav-link:hover {
    background-color: rgba(25, 135, 84, 0.2);
    border-radius: 6px;
}

/* Cards */
.card {
    border-radius: 12px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.08) !important;
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
    border-bottom: 1px solid #f0f0f0;
}

/* Login page */
.login-wrapper {
    background: linear-gradient(135deg, #e8f5e9 0%, #e3f2fd 100%);
}

.login-card {
    border-radius: 16px !important;
}

/* Tables */
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6c757d;
}

.table td {
    vertical-align: middle;
}

/* Badges */
.badge {
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        z-index: 1050;
        width: 0;
        overflow: hidden;
    }

    #sidebar.show {
        width: 250px;
    }

    #main-content {
        margin-left: 0 !important;
    }
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Utility */
.cursor-pointer {
    cursor: pointer;
}

/* ----------------------------------------
   Sticky table headers — Safari-safe.
   Safari (incl. macOS 14 / iOS 16) does not honour position:sticky on
   <thead> or <tr>; the rule must live on <th> cells. Apply this class to
   the <table> element and the header cells will stick to the top of the
   nearest scrollable ancestor in every browser.
   ---------------------------------------- */
.sticky-table-head thead th {
    position: -webkit-sticky;   /* iOS Safari ≤ 12 fallback */
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8f9fa;        /* matches Bootstrap .table-light */
}

/* ----------------------------------------
   AI ESG analysis (markdown-rendered) box
   ---------------------------------------- */
.ai-content {
    font-size: 0.92rem;
    line-height: 1.65;
    color: #333;
}
.ai-content > *:first-child { margin-top: 0; }
.ai-content > *:last-child  { margin-bottom: 0; }
.ai-content p { margin: 0 0 0.6rem; }
.ai-content h1,
.ai-content h2,
.ai-content h3,
.ai-content h4 {
    color: #0f3460;
    font-weight: 700;
    margin: 0.85rem 0 0.4rem;
    line-height: 1.3;
}
.ai-content h1 { font-size: 1.05rem; }
.ai-content h2 { font-size: 1rem; }
.ai-content h3 { font-size: 0.95rem; }
.ai-content h4 { font-size: 0.92rem; }
.ai-content ul,
.ai-content ol {
    margin: 0.4rem 0 0.6rem 1.25rem;
    padding: 0;
}
.ai-content li { margin-bottom: 0.2rem; }
.ai-content strong { color: #0f3460; }
.ai-content em     { color: #555; }
.ai-content code {
    background: #eef2f8;
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
    font-size: 0.86em;
    color: #c0392b;
}
.ai-content blockquote {
    border-left: 3px solid #c8d8f8;
    margin: 0.5rem 0;
    padding: 0.15rem 0.75rem;
    color: #555;
    font-style: italic;
}
.ai-content hr {
    border: 0;
    border-top: 1px dashed #d0d7e2;
    margin: 0.8rem 0;
}
.ai-content table {
    border-collapse: collapse;
    margin: 0.6rem 0;
    width: 100%;
    font-size: 0.88rem;
}
.ai-content th,
.ai-content td {
    border: 1px solid #d6dde8;
    padding: 0.35rem 0.6rem;
    text-align: left;
    vertical-align: top;
}
.ai-content th {
    background: #eef2f8;
    color: #0f3460;
    font-weight: 700;
}
.ai-content tbody tr:nth-child(even) {
    background: #f7f9fc;
}
.ai-content pre {
    background: #f4f6fa;
    border: 1px solid #e1e6ef;
    border-radius: 5px;
    padding: 0.6rem 0.8rem;
    margin: 0.6rem 0;
    overflow-x: auto;
    font-size: 0.85em;
    line-height: 1.5;
}
.ai-content pre code {
    background: transparent;
    padding: 0;
    color: #2c3e50;
    font-size: inherit;
}
.ai-content a {
    color: #0f3460;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-word;
}
.ai-content a:hover {
    color: #1a508b;
}
.ai-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 0.4rem 0;
}
