@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --bg-main: #090d16;
    --bg-card: rgba(17, 24, 39, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.15);
    --secondary: #a855f7;
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #111827;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Glassmorphism utility */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Navigation Layout */
header {
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 6px;
    display: inline-block;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.user-badge span {
    color: var(--secondary);
    font-weight: 600;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.875rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

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

.btn-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

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

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 8px;
}

/* Grid & Layout containers */
main {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.dashboard-title {
    margin-bottom: 2rem;
    font-size: 2rem;
    font-weight: 700;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card:nth-child(2) .stat-icon {
    background: rgba(168, 85, 247, 0.15);
    color: var(--secondary);
}

.stat-card:nth-child(3) .stat-icon {
    background: var(--success-light);
    color: var(--success);
}

.stat-info h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.stat-info p {
    font-size: 1.75rem;
    font-weight: 700;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin-top: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.015);
}

/* Badge tags */
.badge {
    padding: 0.35rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.badge-pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-submitted {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-expired {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Inputs & Form styling */
.form-group {
    margin-bottom: 1.5rem;
}

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

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
}

select.form-control option {
    background-color: #111827 !important;
    color: #f3f4f6 !important;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Autocomplete search container */
.autocomplete-container {
    position: relative;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #111827;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow);
    margin-top: 0.5rem;
}

.autocomplete-item {
    padding: 0.875rem 1.25rem;
    cursor: pointer;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition);
    color: #f3f4f6 !important;
    background-color: #111827 !important;
    text-align: left;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item strong {
    color: #ffffff !important;
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.autocomplete-item .item-sub {
    font-size: 0.75rem;
    color: #9ca3af !important;
    display: block;
}

.autocomplete-item:hover {
    background-color: #1f2937 !important;
    color: #ffffff !important;
}

.autocomplete-item:hover strong {
    color: var(--primary) !important;
}

/* Saving indicator on public inputs */
.save-status-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.save-status {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.save-status.saving {
    animation: pulse 1.5s infinite;
    color: var(--warning);
}

.save-status.saved {
    color: var(--success);
}

.save-status.error {
    color: var(--danger);
}

/* Modal styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 600px;
    padding: 2rem;
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-main);
}

/* Portal specific styles */
.portal-header-bg {
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.1), transparent 40%),
                radial-gradient(circle at bottom left, rgba(168, 85, 247, 0.1), transparent 40%);
}

.portal-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.copy-input-group {
    display: flex;
    gap: 0.5rem;
}

.copy-input-group input {
    flex: 1;
    font-family: monospace;
    font-size: 0.8rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    main {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    td, th {
        padding: 0.75rem;
    }
}

/* Tooltip wrapper */
.specs-tooltip-container {
    float: left;
    margin-right: 0.6rem;
    margin-top: 0.15rem;
    position: relative;
    display: inline-block;
    cursor: help;
}

.specs-icon {
    color: var(--primary);
    opacity: 0.75;
    transition: var(--transition);
    display: block;
}

.specs-tooltip-container:hover .specs-icon {
    opacity: 1;
    color: var(--secondary);
    transform: scale(1.1);
}

/* Tooltip text - aligned to the right of the icon */
.specs-tooltip-content {
    visibility: hidden;
    width: 230px;
    background-color: #1f2937;
    color: #ffffff;
    text-align: left;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.85rem;
    position: absolute;
    z-index: 999999 !important;
    top: 50%;
    left: 125%; /* Align to the right of the icon */
    transform: translateY(-50%) translateX(8px);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: var(--shadow);
    font-size: 0.8rem;
    line-height: 1.45;
    pointer-events: none; /* Prevent mouse capture */
}

/* Tooltip arrow - pointing left */
.specs-tooltip-content::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%; /* At the left side of the tooltip */
    margin-top: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent #1f2937 transparent transparent;
}

/* Show the tooltip on hover */
.specs-tooltip-container:hover .specs-tooltip-content {
    visibility: visible;
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* Elevate stacking context of the hovered table row cell containing the tooltip relative to its sibling cells */
table tbody tr:hover td:first-child {
    position: relative;
    z-index: 9999;
}
table tbody tr:hover td:not(:first-child) {
    position: relative;
    z-index: 1;
}

/* Supplier Portal filter tabs */
.filter-tabs-container {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-tab {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.filter-tab:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.filter-tab.active {
    color: #ffffff;
    box-shadow: var(--shadow);
}

/* Status-specific tab actives */
.filter-tab#filter-tab-pending.active {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

.filter-tab#filter-tab-unfinished.active {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
}

.filter-tab#filter-tab-done.active {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.15);
}

.filter-tab#filter-tab-all.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
}

.tab-badge {
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    font-weight: 700;
}

/* Accordion border updates based on status */
.rfq-accordion.border-pending {
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
}
.rfq-accordion.border-pending:hover {
    border-color: #ef4444 !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.12);
}

.rfq-accordion.border-unfinished {
    border: 1px solid rgba(245, 158, 11, 0.3) !important;
}
.rfq-accordion.border-unfinished:hover {
    border-color: #f59e0b !important;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.12);
}

.rfq-accordion.border-done {
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
}
.rfq-accordion.border-done:hover {
    border-color: #10b981 !important;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.12);
}

/* Responsive mobile-friendly overrides for Supplier Portal */
@media (max-width: 768px) {
    .portal-wrapper {
        padding: 1.5rem 0.75rem;
    }
    .supplier-header {
        padding: 1.25rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .supplier-header h1 {
        font-size: 1.4rem;
    }
    .supplier-header p {
        font-size: 0.9rem;
    }
    .supplier-header .user-badge {
        padding: 0.5rem 1rem;
        display: inline-block;
    }
    
    .filter-tabs-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        width: 100%;
        margin-bottom: 1.25rem;
    }
    .filter-tab {
        width: 100%;
        justify-content: center;
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    .filter-tab#filter-tab-all {
        grid-column: span 2;
    }

    .rfq-accordion-header {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .rfq-accordion-header h3 {
        font-size: 1rem;
        line-height: 1.4;
    }
    .rfq-accordion-header div {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .rfq-accordion-content {
        padding: 1rem;
    }

    /* Convert Table to Card List on mobile */
    .rfq-accordion-content table, 
    .rfq-accordion-content thead, 
    .rfq-accordion-content tbody, 
    .rfq-accordion-content th, 
    .rfq-accordion-content td, 
    .rfq-accordion-content tr { 
        display: block; 
    }
    .rfq-accordion-content thead {
        display: none; /* Hide header columns */
    }
    .rfq-accordion-content tr {
        padding: 1rem 0;
        border-bottom: 1px solid var(--border-color);
        position: relative;
    }
    .rfq-accordion-content tr:last-child {
        border-bottom: none;
    }
    .rfq-accordion-content td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0 !important;
        border: none !important;
        text-align: left !important;
        font-size: 0.9rem;
    }
    /* Description cell occupies full width */
    .rfq-accordion-content td:first-child {
        display: block;
        font-size: 0.95rem;
        font-weight: 600;
        padding-bottom: 0.75rem !important;
        border-bottom: 1px dashed var(--border-color) !important;
        margin-bottom: 0.5rem;
    }
    
    /* Specs icon left float alignment adjustment for mobile card view */
    .rfq-accordion-content td:first-child .specs-tooltip-container {
        float: none !important;
        display: inline-block !important;
        vertical-align: middle;
        margin-right: 6px;
    }

    /* Pseudo-label additions for table values */
    .rfq-accordion-content td:nth-child(2)::before { content: "QTY Requested:"; color: var(--text-muted); font-size: 0.8rem; }
    .rfq-accordion-content td:nth-child(3)::before { content: "UOM:"; color: var(--text-muted); font-size: 0.8rem; }
    .rfq-accordion-content td:nth-child(4)::before { content: "Last Quoted:"; color: var(--text-muted); font-size: 0.8rem; }
    .rfq-accordion-content td:nth-child(5)::before { content: "Your SKU:"; color: var(--text-muted); font-size: 0.8rem; }
    .rfq-accordion-content td:nth-child(6)::before { content: "Your Price:"; color: var(--text-muted); font-size: 0.8rem; }
    .rfq-accordion-content td:nth-child(7)::before { content: "Status:"; color: var(--text-muted); font-size: 0.8rem; }

    /* Expand input boxes to fill space nicely on mobile */
    .portal-input {
        max-width: 150px;
        text-align: right;
    }
    .portal-input-sku {
        max-width: 150px;
        text-align: right;
    }
    
    /* Avoid hover stacking conflicts on mobile card list */
    table tbody tr:hover td:first-child {
        position: static;
        z-index: auto;
    }
    table tbody tr:hover td:not(:first-child) {
        position: static;
        z-index: auto;
    }
}

