/**
 * Axichem Forecast Frontend Styles - Enhanced & Responsive
 */

/* ===================================
   SMOOTH TRANSITIONS & ANIMATIONS
   =================================== */
* {
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

/* Container */
.axichem-forecast-container {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.07);
    animation: fadeIn 0.3s ease-in;
}

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

.axichem-forecast-container h2 {
    margin-top: 0;
    color: #23282d;
}

/* Controls */
.forecast-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e1e1e1;
}

/* Year Selector */
.year-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.year-selector label {
    font-weight: 600;
    color: #23282d;
    margin: 0;
    font-size: 14px;
}

.year-selector select,
.forecast-controls select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    color: #23282d;
    cursor: pointer;
    transition: all 0.2s ease;
}

.year-selector select:hover,
.forecast-controls select:hover {
    border-color: #0073aa;
}

.year-selector select:focus,
.forecast-controls select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

.forecast-controls .button {
    margin-left: auto;
}

/* Product Search Wrapper */
.product-search-wrapper {
    margin-bottom: 20px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #0073aa;
}

.search-box-container {
    margin-bottom: 15px;
}

.product-search-wrapper input {
    width: 100%;
    padding: 12px 12px 12px 15px;
    border: 2px solid #0073aa;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}

.product-search-wrapper input:focus {
    outline: none;
    border-color: #005a87;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.search-results {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    
    /* Hide scrollbar but keep functionality */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.search-results::-webkit-scrollbar {
    display: none;
}

/* Category Browser */
.category-browser {
    padding: 10px 0;
}

.browser-header {
    padding: 12px 15px;
    background: #0073aa;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.category-item {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-item:hover {
    background: #f0f8ff;
}

.category-name {
    font-weight: 500;
    color: #23282d;
}

.category-count {
    font-size: 12px;
    color: #666;
    background: #f0f0f0;
    padding: 3px 8px;
    border-radius: 10px;
}

.no-categories,
.no-products {
    padding: 30px;
    text-align: center;
    color: #999;
}

/* Product List Browser */
.product-list-browser {
    padding: 0;
}

.back-to-categories {
    background: #0073aa;
    color: #fff;
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 13px;
    border-radius: 3px;
    transition: background 0.2s;
}

.back-to-categories:hover {
    background: #005a87;
}

.search-result-item {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: #f0f8ff;
}

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

.search-error {
    padding: 15px;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    color: #856404;
    font-weight: 500;
    margin: 10px 0;
}

.result-name {
    font-weight: 600;
    color: #23282d;
    margin-bottom: 4px;
}

.result-details {
    display: flex;
    gap: 15px;
    align-items: center;
}

.result-sku {
    font-size: 12px;
    color: #666;
}

.result-price {
    font-size: 13px;
    color: #0073aa;
    font-weight: 600;
}

.loading-products,
.error-message {
    padding: 20px;
    text-align: center;
    color: #666;
}

/* Loading Indicator */
.loading-indicator {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* Forecast Table */
.axichem-forecast-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.axichem-forecast-table th,
.axichem-forecast-table td {
    padding: 12px 8px;
    text-align: center;
    border: 1px solid #ddd;
}

.axichem-forecast-table th {
    background: #0073aa;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
}

.axichem-forecast-table th:first-child,
.axichem-forecast-table td:first-child {
    text-align: left;
    padding-left: 15px;
}

.axichem-forecast-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.axichem-forecast-table input[type="number"] {
    width: 70px;
    padding: 6px;
    border: 2px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-weight: 500;
    transition: all 0.2s ease;
    /* Remove spinner arrows */
    -moz-appearance: textfield;
}

/* Remove spinner arrows for Chrome, Safari, Edge, Opera */
.axichem-forecast-table input[type="number"]::-webkit-outer-spin-button,
.axichem-forecast-table input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.axichem-forecast-table input[type="number"]:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,115,170,0.1);
    transform: scale(1.05);
}

.axichem-forecast-table input[type="number"]:hover:not(:focus) {
    border-color: #999;
    background: #fafafa;
}

/* Optimistic UI States */
.forecast-input.saving,
.consignment-input.saving {
    background: linear-gradient(90deg, #fff3cd 0%, #fff 50%, #fff3cd 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-color: #ffb900;
}

.forecast-input.success,
.consignment-input.success {
    background: #d4edda;
    border-color: #46b450;
    animation: successPulse 0.5s ease;
}

.forecast-input.error,
.consignment-input.error {
    background: #f8d7da;
    border-color: #dc3232;
    animation: errorShake 0.5s ease;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes successPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.product-name {
    font-weight: 600;
    color: #23282d;
}

.product-sku {
    color: #666;
    font-size: 12px;
}

.row-total {
    font-weight: bold;
    color: #0073aa;
}

.remove-product-btn {
    background: #dc3232;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.remove-product-btn:hover {
    background: #b52727;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
}

/* Consignment Table (3-row display) */
.axichem-consignment-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.axichem-consignment-table th,
.axichem-consignment-table td {
    padding: 10px 8px;
    text-align: center;
    border: 1px solid #ddd;
}

.axichem-consignment-table th {
    background: #0073aa;
    color: #fff;
    font-weight: 600;
    font-size: 12px;
}

.axichem-consignment-table th:first-child,
.axichem-consignment-table td:first-child,
.axichem-consignment-table td:nth-child(2),
.axichem-consignment-table td:nth-child(3) {
    text-align: left;
    padding-left: 12px;
}

/* Row Types */
.row-forecast {
    background: #f0f0f0 !important;
}

.row-consignment {
    background: #e7f3ff !important;
}

.row-total {
    background: #e8f5e8 !important;
    font-weight: bold;
}

.row-forecast input {
    background: #f0f0f0;
    cursor: not-allowed;
}

/* Remove spinner arrows from forecast row inputs */
.row-forecast input[type="number"] {
    -moz-appearance: textfield;
}

.row-forecast input[type="number"]::-webkit-outer-spin-button,
.row-forecast input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.row-consignment input {
    background: #fff;
}

/* Remove spinner arrows from consignment row inputs */
.row-consignment input[type="number"] {
    -moz-appearance: textfield;
}

.row-consignment input[type="number"]::-webkit-outer-spin-button,
.row-consignment input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Remove spinner arrows from consignment table inputs */
.axichem-consignment-table input[type="number"] {
    -moz-appearance: textfield;
}

.axichem-consignment-table input[type="number"]::-webkit-outer-spin-button,
.axichem-consignment-table input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.row-total td {
    font-weight: bold;
    color: #23282d;
}

.type-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.type-forecast { color: #666; }
.type-consignment { color: #0073aa; }
.type-total { color: #46b450; }

/* Legend */
.consignment-legend {
    display: flex;
    gap: 30px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-top: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.legend-color {
    width: 30px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid #ddd;
}

.forecast-color { background: #f0f0f0; }
.consignment-color { background: #e7f3ff; }
.total-color { background: #e8f5e8; }

/* Save Status */
.save-status {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 12px 20px;
    background: #46b450;
    color: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    display: none;
    z-index: 1000;
}

.save-status.saving {
    background: #ffb900;
}

.save-status.error {
    background: #dc3232;
}

/* Access Denied */
.axichem-access-denied {
    text-align: center;
    padding: 60px 30px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.access-denied-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.axichem-access-denied h2 {
    color: #23282d;
    margin-bottom: 15px;
}

.axichem-access-denied p {
    color: #666;
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 10px;
}

.contact-info {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 4px;
    display: inline-block;
}

/* ===================================
   TOAST NOTIFICATIONS (Replaces Alerts)
   =================================== */
.axichem-toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.axichem-toast {
    background: #fff;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s;
    border-left: 4px solid;
}

.axichem-toast.success {
    border-left-color: #46b450;
}

.axichem-toast.error {
    border-left-color: #dc3232;
}

.axichem-toast.info {
    border-left-color: #0073aa;
}

.axichem-toast.warning {
    border-left-color: #ffb900;
}

.axichem-toast-icon {
    font-size: 24px;
    line-height: 1;
}

.axichem-toast-message {
    flex: 1;
    font-size: 14px;
    color: #23282d;
}

.axichem-toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.axichem-toast-close:hover {
    color: #333;
}

@keyframes slideInRight {
    from { transform: translateX(400px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateX(20px); }
}

/* ===================================
   SKELETON LOADING STATES
   =================================== */
.skeleton-row {
    animation: skeletonPulse 1.5s ease-in-out infinite;
}

.skeleton-cell {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: 4px;
    height: 36px;
}

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

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */
@media (max-width: 1200px) {
    .axichem-forecast-table,
    .axichem-consignment-table {
        font-size: 12px;
    }
    
    .axichem-forecast-table input[type="number"] {
        width: 60px;
    }
}

@media (max-width: 768px) {
    .axichem-forecast-container {
        padding: 15px;
        border-radius: 8px;
    }
    
    .forecast-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 15px;
    }
    
    .year-selector {
        width: 100%;
        justify-content: center;
    }
    
    .year-selector label,
    .year-selector select {
        flex: 0 1 auto;
    }
    
    .forecast-controls .button {
        margin-left: 0;
        width: 100%;
    }
    
    /* Mobile Table Wrapper */
    .axichem-forecast-table,
    .axichem-consignment-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 11px;
    }
    
    .axichem-forecast-table thead,
    .axichem-consignment-table thead {
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    .axichem-forecast-table th:first-child,
    .axichem-consignment-table th:first-child,
    .axichem-forecast-table td:first-child,
    .axichem-consignment-table td:first-child {
        position: sticky;
        left: 0;
        background: #fff;
        z-index: 5;
        box-shadow: 2px 0 4px rgba(0,0,0,0.1);
    }
    
    .axichem-forecast-table th,
    .axichem-forecast-table td,
    .axichem-consignment-table th,
    .axichem-consignment-table td {
        padding: 8px 4px;
        white-space: nowrap;
    }
    
    .axichem-forecast-table input[type="number"] {
        width: 50px;
        font-size: 12px;
        padding: 4px;
    }
    
    .consignment-legend {
        flex-direction: column;
        gap: 10px;
    }
    
    .save-status {
        bottom: 15px;
        right: 15px;
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .axichem-toast-container {
        top: 60px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* ===================================
   MICRO-INTERACTIONS
   =================================== */
.remove-product-btn,
.button,
.search-result-item,
.category-item {
    position: relative;
    overflow: hidden;
}

.remove-product-btn::before,
.button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.remove-product-btn:hover::before,
.button:hover::before {
    width: 200px;
    height: 200px;
}

.product-search-wrapper {
    transition: all 0.3s ease;
}

.search-result-item,
.category-item {
    transition: all 0.2s ease;
}

.search-result-item:hover,
.category-item:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0,115,170,0.15);
}

/* ===================================
   IMPROVED LOADING INDICATOR
   =================================== */
.loading-indicator {
    text-align: center;
    padding: 60px 40px;
}

.loading-indicator::before {
    content: '';
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-indicator p {
    color: #666;
    font-size: 14px;
    margin: 0;
}

/* ===================================
   STICKY HEADER FOR TABLES
   =================================== */
.axichem-forecast-table thead,
.axichem-consignment-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ===================================
   SMOOTH SCROLL BEHAVIOR
   =================================== */
.search-results {
    scroll-behavior: smooth;
}

.axichem-forecast-container {
    scroll-behavior: smooth;
}

