/* ========================================
   SITE.CSS - Main CSS File
   Allied Pricing Report Application
   
   Contains:
   - CSS Variables & Reset
   - Layout Structure (Sidebar, Top Nav, Content)
   - Navigation Styles
   - Common Page Styles
   - Form Validation
   - Blazor Framework Styles
   ======================================== */

/* ========================================
   CSS VARIABLES
   ======================================== */
:root {
    /* Layout */
    --sidebar-w: 282px;
    
    /* Colors */
    --bg: #FFFFFF;
    --border: #E0E0E0;
    --accent: #D3DBFF;
    --text: #000000;
    --muted: #F7F7F7;
    --success: #64D93A;
    --active: #4D76FF;
    
    /* Form Colors */
    --valid-color: #26b050;
    --invalid-color: #dc3545;
    --error-color: red;
}

/* ========================================
   GLOBAL RESET & BASE STYLES
   ======================================== */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    background: var(--bg);
    color: var(--text);
}

code {
    color: #c02d76;
}

/* ========================================
   LAYOUT STRUCTURE
   ======================================== */
.page-wrapper {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* ========================================
   SIDEBAR NAVIGATION
   ======================================== */
.sidebar {
    height: 100vh;
    max-height: 100vh;
    flex-shrink: 0;
    overflow: auto;
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    max-width: var(--sidebar-w);
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 24px 8px;
    min-height: 0;
}

.sidebar .title {
    font-weight: 600;
    font-size: 20px;
    line-height: 150%;
    letter-spacing: -0.01em;
    margin: 1px 0 8px 16px;
}

.sidebar .subtitle {
    font-weight: 400;
    font-size: 12px;
    line-height: 150%;
    letter-spacing: -0.01em;
    margin: 8px 0 24px 16px;
    color: #666;
}

.sidebar .section-label {
    margin: 16px 16px 6px 16px;
    font-size: 14px;
    font-weight: 600;
    line-height: 150%;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar .section-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 16px 8px 16px;
}

/* Menu Items */
.menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 0 4px 0;
}

.menu .children {
    margin-left: 0px;
    padding-top: 2px;
}

.menu-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    border-radius: 0px;
    padding: 10px 16px;
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    width: 100%;
    transition: all 0.2s ease;
}

.menu-item.parent {
    padding: 10px 16px;
    font-weight: 500;
}

.menu-item.child {
    padding: 10px 16px;
    margin-left: 0px;
    font-size: 15px;
}

.menu-item .icon {
    width: 20px;
    height: 20px;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.menu-item .text {
    font-weight: 500;
    font-size: 14px;
    line-height: 150%;
    flex: 1;
}

.menu-item.active {
    background: var(--accent);
    font-weight: 600;
    position: relative;
    box-shadow: 0 1px 3px rgba(77, 118, 255, 0.1);
    border-radius: 0px;
}

.menu-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--active);
    border-radius: 0px;
}

.menu-item.active .icon {
    color: var(--active);
}

.menu-item.active .text {
    color: var(--active);
}

.menu-item:not(.active):hover {
    background: #f8f9ff;
    transform: translateX(2px);
}

.menu-item:not(.active):hover .icon {
    color: var(--active);
}

/* ========================================
   TOP NAVIGATION BAR
   ======================================== */
.top-navbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 14px 32px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.navbar-left {
    display: flex;
    align-items: center;
    height: 100%;
}

.page-title {
    font-weight: 700;
    font-size: 24px;
    line-height: 1.2;
    color: var(--text);
}

.breadcrumb {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 8px;
    font-size: 14px;
    color: #666;
    margin: 0;
    padding: 0;
}

.breadcrumb-item {
    color: #666;
}

.breadcrumb-item.current {
    color: var(--active);
    font-weight: 500;
}

.breadcrumb-separator {
    color: #ccc;
}

.navbar-right {
    display: flex;
    align-items: center;
    height: 100%;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.action-btn:hover {
    background: #f8f9ff;
}

.action-btn svg {
    width: 20px;
    height: 20px;
    color: #666;
}

.notification-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--active);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 20px;
    background: var(--active);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.submit-btn:hover {
    background: #3d5afe;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(77, 118, 255, 0.3);
}

/* ========================================
   MAIN CONTENT AREA
   ======================================== */
.main-content {
    flex: 1;
    overflow-y: auto;
    height: 100vh;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overscroll-behavior: contain;
}

.content {
    padding: 24px;
    min-height: 0;
    flex: 1;
    overflow: auto;
    width: 100%;
    max-width: 100%;
}

.content .tbd {
    color: #FF0004;
    font-weight: 700;
    font-size: 32px;
    line-height: 150%;
    text-align: center;
    margin-top: 120px;
}

/* ========================================
   COMMON PAGE STYLES
   ======================================== */
.page-header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 8px;
    padding: 4px 0;
    border-bottom: 1px solid #e9ecef;
}

.header-controls {
    display: flex;
    align-items: flex-end;
/*    gap: 12px;*/
/*    flex: 1;*/
    min-width: 0;
/*    align-items: center;*/
    gap: 16px;
    margin-left: auto;
}

.entity-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.entity-selector label {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #4b5563;
    white-space: nowrap;
}

.entity-selector .form-select {
    min-width: 220px;
}

.page-title {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 700;
    font-size: 22px;
    color: #1a202c;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.item-count {
    color: #718096;
    font-size: 14px;
    font-weight: 400;
}

.primary-btn {
    margin-left: auto;
    background: #3182ce;
    color: white;
    border: none;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.primary-btn:hover {
    background: #2c5aa0;
}

.primary-btn::before {
    content: "+";
    font-size: 16px;
    line-height: 1;
    font-weight: 500;
    margin-right: 6px;
}

/* Bottom Update Button */
.update-btn {
    position: fixed;
    right: 67px;
    bottom: 24px;
    height: 40px;
    padding: 0 16px;
    background: var(--success);
    border-radius: 8px;
    display: flex;
    align-items: center;
    font-weight: 700;
    font-size: 16px;
    color: #000;
}

.mq-container {
    padding: 0 2px 40px;
}

@media (max-width: 768px) {
    .page-header-row {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .header-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .entity-selector {
        width: 100%;
        flex-wrap: wrap;
    }

    .entity-selector .form-select {
        width: 100%;
        min-width: 0;
    }
}

/* ========================================
   FORM VALIDATION STYLES
   ======================================== */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--valid-color);
}

.invalid {
    outline: 1px solid var(--invalid-color);
}

.validation-message {
    color: var(--error-color);
    font-size: 0.75rem;
}

input.invalid,
select.invalid,
textarea.invalid {
    border-color: var(--invalid-color);
}

/* ========================================
   BLAZOR FRAMEWORK STYLES
   ======================================== */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #1b6ec2;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* ========================================
   LAYOUT COMPONENT STYLES
   ======================================== */

/* Dropdown Styles */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    z-index: 1000;
    padding: 8px 0;
}

/* Bootstrap defaults .dropdown-menu to display:none; our menu is conditionally rendered by Blazor */
.top-navbar .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background: none;
    text-align: left;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
}

.dropdown-divider {
    height: 1px;
    background-color: #e1e5e9;
    margin: 4px 0;
}

/* Menu Item Icon Styles */
.menu-item .icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

.menu-item.disabled {
    pointer-events: none;
    opacity: 0.4;
    cursor: not-allowed;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 900px) {
    :root {
        --sidebar-w: 220px;
    }
}

/* ========================================
   COMMON PAGE STYLES
   ======================================== */

/* Common Button Styles */
.btn-primary {
    background-color: #007bff;
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 1rem;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-primary:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

/* Common Form Styles */
.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    font-size: 1rem;
}

.form-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Card Styles */
.card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card-header {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e9ecef;
}

/* Table Styles */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.table th {
    font-weight: 600;
    background-color: #f8f9fa;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Loading Spinner */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Alert/Message Styles */
.alert {
    padding: 1rem;
    border-radius: 0.25rem;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Modal Styles */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 0.5rem;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
}

/* Utility Classes */
.mb-3 {
    margin-bottom: 1rem;
}

.mt-3 {
    margin-top: 1rem;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.d-flex {
    display: flex;
}

.justify-content-between {
    justify-content: space-between;
}

.align-items-center {
    align-items: center;
}
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #6b7280;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #4d76ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}
.empty {
    text-align: center;
    color: #7a7f87;
    padding: 20px;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 900px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }
}
