/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

/* Tabs */
.tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    overflow-x: auto;
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab-button:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: white;
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s;
}

.tab-content.active {
    display: block;
}

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

/* Grid Layout */
.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 20px;
}

.card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.card.full-width {
    grid-column: 1 / -1;
}

.card h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

.card h3 {
    color: #495057;
    margin: 20px 0 10px;
    font-size: 1.1em;
}

/* Forms */
form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

input[type="text"],
input[type="number"],
input[type="email"],
select,
textarea {
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.95em;
    transition: all 0.3s;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.checkbox-group {
    display: flex;
    gap: 20px;
    padding: 10px 0;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Supply Rates / Recommendation Items */
.supply-rate-row {
    display: grid;
    grid-template-columns: 120px 1fr 80px;
    gap: 10px;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 10px;
}

.recommendation-item {
    display: grid;
    grid-template-columns: 2fr 2fr 80px 2fr 80px;
    gap: 10px;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 10px;
}

.recommendation-item select {
    max-width: 100%;
}

#supply-rates-container,
#recommendation-items-container,
#modify-items-container {
    margin: 10px 0;
}

/* Buttons */
button {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

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

.btn-success:hover {
    background: #218838;
}

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

.btn-danger:hover {
    background: #c82333;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85em;
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}

.btn-small:hover {
    background: #e9ecef;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Search Controls */
.search-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-controls input,
.search-controls select {
    flex: 1;
    min-width: 150px;
}

.search-controls button {
    white-space: nowrap;
}

/* Results Container */
.results-container {
    margin-top: 20px;
    max-height: 600px;
    overflow-y: auto;
}

.result-item {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 6px;
    transition: all 0.3s;
}

.result-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.result-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.result-item-title {
    font-weight: 600;
    color: #495057;
    font-size: 1.1em;
}

.result-item-body {
    color: #6c757d;
    line-height: 1.6;
}

.result-item-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
}

.status-DRAFT {
    background: #6c757d;
    color: white;
}

.status-PENDING {
    background: #ffc107;
    color: #333;
}

/* ACCEPTED status is no longer used - recommendations go directly to FULFILLED */
.status-ACCEPTED {
    background: #ffc107;
    color: #333;
}

.status-REJECTED {
    background: #dc3545;
    color: white;
}

.status-FULFILLED {
    background: #28a745;
    color: white;
}

.status-CANCELLED {
    background: #6c757d;
    color: white;
}

/* Treatment Type Badges */
.treatment-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

.treatment-NIMCORE {
    background: #007bff;
    color: white;
}

.treatment-WEIGHTWISE {
    background: #28a745;
    color: white;
}

.treatment-HAIRWISE {
    background: #6f42c1;
    color: white;
}

/* Code Block / Response Display */
.code-block {
    background: #282c34;
    color: #abb2bf;
    padding: 20px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.response-panel {
    margin-top: 30px;
}

.response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.response-header h2 {
    margin: 0;
    border: none;
    padding: 0;
}

/* JSON Syntax Highlighting */
.json-key {
    color: #61afef;
}

.json-string {
    color: #98c379;
}

.json-number {
    color: #d19a66;
}

.json-boolean {
    color: #c678dd;
}

.json-null {
    color: #e06c75;
}

/* Loading State */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Alert Messages */
.alert {
    padding: 15px;
    border-radius: 6px;
    margin: 15px 0;
    animation: slideIn 0.3s;
}

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

.alert-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .section-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    .tab-button {
        font-size: 0.9em;
        padding: 12px 15px;
    }
    
    .tab-content {
        padding: 15px;
    }
    
    .card {
        padding: 15px;
    }
    
    .search-controls {
        flex-direction: column;
    }
    
    .search-controls input,
    .search-controls select,
    .search-controls button {
        width: 100%;
    }
    
    .supply-rate-row,
    .recommendation-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Dashboard Controls */
.dashboard-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 150px;
}

.filter-group label {
    font-size: 0.85em;
    font-weight: 600;
    color: #495057;
}

.filter-group select,
.filter-group input {
    padding: 8px 12px;
}

/* Statistics Summary */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
}

.stat-card {
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 2em;
    font-weight: 700;
    color: #667eea;
    display: block;
}

.stat-label {
    font-size: 0.85em;
    color: #6c757d;
    margin-top: 5px;
    display: block;
}

.stat-card.status-DRAFT .stat-value { color: #6c757d; }
.stat-card.status-PENDING .stat-value { color: #ffc107; }
.stat-card.status-FULFILLED .stat-value { color: #28a745; }
.stat-card.status-REJECTED .stat-value { color: #dc3545; }
.stat-card.status-CANCELLED .stat-value { color: #6c757d; }

/* Recommendation Card Details */
.recommendation-card {
    margin-bottom: 20px;
}

.rec-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.detail-col p {
    margin: 5px 0;
}

.price-highlight {
    color: #667eea;
    font-weight: 700;
    font-size: 1.1em;
}

.items-summary {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    margin-top: 10px;
}

.item-entry {
    padding: 5px 0;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.9em;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 6px;
    margin: 20px 0;
}

.empty-state p {
    margin: 10px 0;
    color: #6c757d;
}

.empty-state ul {
    color: #495057;
    line-height: 1.8;
}

@media (max-width: 768px) {
    .rec-details-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-controls {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .empty-state input {
        width: 100% !important;
        margin-bottom: 10px;
    }
}

/* Price Summary */
.price-summary {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 6px;
    margin: 15px 0;
}

.price-summary h4 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.price-breakdown {
    margin: 10px 0;
}

.price-breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #ddd;
}

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

.price-value {
    font-weight: 600;
    color: #667eea;
}

.total-price {
    font-size: 1.2em;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #667eea;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.total-price strong {
    color: #495057;
}

.total-price #total-price {
    color: #667eea;
    font-weight: 700;
    font-size: 1.3em;
}

/* Utility Classes */
.mt-2 { margin-top: 20px; }
.mb-2 { margin-bottom: 20px; }
.text-center { text-align: center; }
.text-muted { color: #6c757d; }
.text-success { color: #28a745; }
.text-danger { color: #dc3545; }
.text-warning { color: #ffc107; }
.text-info { color: #17a2b8; }

.hidden { display: none; }
.visible { display: block; }

