/* ============================================================================
   Order Prediction Calculator - Stylesheet
   ============================================================================ */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
    flex-wrap: wrap;
    gap: 15px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 600;
}

.brand-icon {
    font-size: 1.5rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

.user-badge {
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.user-currency {
    padding: 2px 8px;
    background: var(--success-color);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.2);
}

.nav-link-logout {
    background: rgba(255, 255, 255, 0.1);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 20px;
}

.flash {
    padding: 15px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease;
}

.flash-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.flash-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.flash-info {
    background: #e0f2fe;
    color: #075985;
    border: 1px solid #7dd3fc;
}

.flash-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.7;
}

.flash-close:hover {
    opacity: 1;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 450px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.login-header h1 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
}

.key-input {
    width: 100%;
    padding: 15px;
    font-size: 1.2rem;
    letter-spacing: 3px;
    text-align: center;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: 'Monaco', 'Consolas', monospace;
    transition: var(--transition);
}

.key-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.key-counter {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
    transition: var(--transition);
}

.key-counter.complete {
    color: var(--success-color);
    font-weight: 600;
}

.btn-login {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.login-footer {
    margin-top: 25px;
    text-align: center;
}

.login-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.demo-keys {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px dashed var(--border-color);
}

.demo-keys h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    text-align: center;
}

.demo-key-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.demo-key {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
}

.demo-key:hover {
    background: #e2e8f0;
}

.demo-key code {
    font-family: 'Monaco', 'Consolas', monospace;
    background: var(--primary-color);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.demo-key span {
    color: var(--text-secondary);
}

/* Calculator Page */
.calculator-container {
    max-width: 1000px;
    margin: 0 auto;
}

/* User Info Card */
.user-info-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: var(--radius-lg);
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: var(--shadow-md);
}

.user-info-header h2 {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.user-info-header p {
    opacity: 0.9;
    font-size: 0.95rem;
}

.user-info-details {
    display: flex;
    gap: 30px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-label {
    font-size: 0.8rem;
    opacity: 0.8;
    text-transform: uppercase;
}

.info-value {
    font-weight: 600;
    font-size: 1rem;
}

.tier-badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
}

.tier-internal { background: rgba(16, 185, 129, 0.3); }
.tier-wholesale { background: rgba(59, 130, 246, 0.3); }
.tier-partner { background: rgba(139, 92, 246, 0.3); }
.tier-distributor { background: rgba(245, 158, 11, 0.3); }
.tier-retail { background: rgba(239, 68, 68, 0.3); }

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
}

.tab-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary-color);
}

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

.tab-icon {
    font-size: 1.2rem;
}

/* Form Container */
.form-container {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
}

.product-form {
    display: none;
}

.product-form.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

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

.product-form h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.form-description {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group .hint {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: #475569;
}

/* Results Section */
.results-section {
    margin-bottom: 30px;
}

.results-section.hidden {
    display: none;
}

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

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Result Card */
.result-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: slideIn 0.4s ease;
}

.result-card-header {
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.result-card-header h3 {
    font-size: 1.25rem;
    margin-bottom: 5px;
}

.result-card-header .product-code {
    display: block;
    opacity: 0.9;
    font-size: 0.9rem;
}

.result-card-header .pricing-info {
    display: block;
    margin-top: 8px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-size: 0.8rem;
    width: fit-content;
}

.result-card-body {
    padding: 20px;
}

.result-section {
    margin-bottom: 20px;
}

.result-section:last-child {
    margin-bottom: 0;
}

.result-section h4 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

/* Data List */
.data-list {
    list-style: none;
}

.data-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-color);
}

.data-list li:last-child {
    border-bottom: none;
}

.data-list .label {
    color: var(--text-secondary);
}

.data-list .value {
    font-weight: 600;
}

/* Orders Table */
.orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.orders-table th,
.orders-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.orders-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.orders-table td.number {
    text-align: right;
    font-family: 'Monaco', 'Consolas', monospace;
}

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

/* Shortfalls */
.shortfall-item {
    background: #fef3c7;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 0.9rem;
    border-left: 3px solid var(--warning-color);
}

.shortfall-item:last-child {
    margin-bottom: 0;
}

.no-shortfalls {
    color: var(--success-color);
    font-weight: 500;
}

/* Cost Summary */
.cost-summary {
    background: #f0fdf4;
    padding: 15px;
    border-radius: var(--radius-md);
    border: 1px solid #bbf7d0;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

.cost-item.total {
    border-top: 2px solid #86efac;
    margin-top: 8px;
    padding-top: 12px;
    font-size: 1.1rem;
}

.cost-item .amount {
    font-weight: 700;
    color: var(--success-color);
}

/* Combined Summary */
.combined-summary {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-md);
}

.combined-summary.hidden {
    display: none;
}

.combined-summary h3 {
    font-size: 1.25rem;
    margin-bottom: 20px;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}

.summary-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 20px;
    border-radius: var(--radius-md);
    text-align: center;
    border: 1px solid var(--border-color);
}

.summary-card .label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.summary-card .value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-color);
}

.summary-card.highlight {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
}

.summary-card.highlight .label,
.summary-card.highlight .value {
    color: white;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 30px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 15px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 15px 25px;
    background: var(--text-primary);
    color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    animation: toastIn 0.3s ease;
}

.toast.hidden {
    display: none;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .navbar {
        padding: 15px;
        flex-direction: column;
        text-align: center;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
    }

    .nav-user {
        flex-wrap: wrap;
        justify-content: center;
    }

    .login-card {
        padding: 25px;
    }

    .tabs {
        flex-direction: column;
    }

    .tab-btn {
        width: 100%;
        justify-content: center;
    }

    .form-container {
        padding: 20px;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .orders-table {
        font-size: 0.8rem;
    }

    .orders-table th,
    .orders-table td {
        padding: 8px 4px;
    }

    .user-info-details {
        flex-direction: column;
        gap: 15px;
    }

    .summary-cards {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .key-input {
        font-size: 1rem;
        letter-spacing: 2px;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .demo-key {
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }
}
