/**
 * 360 IT Solution – Supplier Sourcing Portal
 * Stylesheet
 */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --blue-900: #0d1b3e;
    --blue-700: #1a3a6b;
    --blue-600: #1e4d8c;
    --blue-500: #2563eb;
    --blue-400: #3b82f6;
    --blue-100: #dbeafe;
    --blue-50:  #eff6ff;

    --orange-600: #ea580c;
    --orange-500: #f97316;
    --orange-400: #fb923c;
    --orange-100: #ffedd5;

    --red-600:   #dc2626;
    --red-500:   #ef4444;
    --red-100:   #fee2e2;

    --green-600: #16a34a;
    --green-500: #22c55e;
    --green-100: #dcfce7;

    --yellow-600: #ca8a04;
    --yellow-100: #fef9c3;

    --gray-900: #111827;
    --gray-700: #374151;
    --gray-600: #4b5563;
    --gray-500: #6b7280;
    --gray-400: #9ca3af;
    --gray-300: #d1d5db;
    --gray-200: #e5e7eb;
    --gray-100: #f3f4f6;
    --gray-50:  #f9fafb;

    --white: #ffffff;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --transition: 150ms ease;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--gray-900);
    background: var(--gray-100);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Container ────────────────────────────────────────────── */
.container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
    background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-700) 100%);
    padding: 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-inner {
    display: flex;
    align-items: center;
    min-height: 60px;
}

.navbar-brand {
    color: var(--white);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brand-360 {
    color: var(--orange-400);
    font-weight: 800;
    font-size: 1.35rem;
}

.brand-divider {
    color: var(--gray-400);
    margin: 0 0.4rem;
    font-weight: 300;
}

.brand-portal {
    font-weight: 400;
    color: var(--blue-100);
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 3rem;
}

/* ── Page Titles ──────────────────────────────────────────── */
.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--blue-900);
    margin-bottom: 1.5rem;
}

.page-title .request-no {
    font-size: 1.1rem;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--blue-900);
    margin: 0;
}

.card-body {
    padding: 1.5rem;
}

.card-body.p-0 {
    padding: 0;
}

/* ── Detail Grid (Request Details) ────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.detail-item label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.detail-item span {
    font-size: 0.95rem;
    color: var(--gray-900);
}

.detail-block {
    margin-top: 1.25rem;
}

.detail-block label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.4rem;
}

.specifications-box {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-size: 0.9rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
    padding: 0.9rem 1.2rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.alert-icon {
    flex-shrink: 0;
    font-size: 1.1rem;
}

.alert-success {
    background: var(--green-100);
    color: var(--green-600);
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: var(--red-100);
    color: var(--red-600);
    border: 1px solid #fecaca;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.2em 0.65em;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 999px;
    white-space: nowrap;
}

.badge-lg {
    font-size: 0.85rem;
    padding: 0.3em 0.9em;
}

/* Status badges */
.badge-draft       { background: var(--gray-200);   color: var(--gray-700); }
.badge-reviewed    { background: var(--blue-100);    color: var(--blue-600); }
.badge-sending     { background: var(--yellow-100);  color: var(--yellow-600); }
.badge-sent        { background: var(--green-100);   color: var(--green-600); }
.badge-partial_failed { background: var(--orange-100); color: var(--orange-600); }
.badge-failed      { background: var(--red-100);     color: var(--red-600); }

/* Source badges */
.badge-internal    { background: var(--blue-100);    color: var(--blue-600); }
.badge-tavily      { background: #f0e6ff;            color: #7c3aed; }
.badge-manual      { background: var(--gray-200);    color: var(--gray-600); }

/* Send status badges */
.badge-success, .badge-delivered { background: var(--green-100); color: var(--green-600); }
.badge-pending     { background: var(--yellow-100);  color: var(--yellow-600); }
.badge-error       { background: var(--red-100);     color: var(--red-600); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}

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

.btn-sm {
    padding: 0.35rem 0.8rem;
    font-size: 0.82rem;
}

.btn-primary {
    background: var(--blue-500);
    color: var(--white);
}
.btn-primary:hover:not(:disabled) {
    background: var(--blue-600);
}

.btn-secondary {
    background: var(--blue-700);
    color: var(--white);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--blue-900);
}

.btn-danger {
    background: linear-gradient(135deg, var(--orange-500), var(--red-500));
    color: var(--white);
}
.btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--orange-600), var(--red-600));
}

.btn-outline {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-outline:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

/* ── Tables ───────────────────────────────────────────────── */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table thead th {
    background: var(--blue-900);
    color: var(--white);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.75rem 0.6rem;
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--gray-200);
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: var(--blue-50);
}

.data-table td {
    padding: 0.6rem;
    vertical-align: middle;
}

.text-center { text-align: center; }
.text-nowrap { white-space: nowrap; }
.text-muted  { color: var(--gray-500); }
.text-bold   { font-weight: 600; }
.text-danger { color: var(--red-500); }
.text-warning { color: var(--orange-600); font-weight: 500; }

/* ── Supplier Table ───────────────────────────────────────── */
.supplier-table-header {
    flex-wrap: wrap;
}

.supplier-actions-info {
    display: flex;
    gap: 0.5rem;
}

.supplier-count {
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--gray-500);
}

.supplier-table .col-select   { width: 50px; }
.supplier-table .col-company  { min-width: 160px; }
.supplier-table .col-contact  { min-width: 140px; }
.supplier-table .col-email    { min-width: 200px; }
.supplier-table .col-phone    { min-width: 130px; }
.supplier-table .col-website  { min-width: 150px; }
.supplier-table .col-cost     { min-width: 100px; }
.supplier-table .col-currency { min-width: 70px; }
.supplier-table .col-source   { min-width: 90px; }
.supplier-table .col-status   { min-width: 100px; }

.row-invalid-email {
    background: #fff5f5 !important;
}

.row-invalid-email:hover {
    background: #fee2e2 !important;
}

/* ── Inline Form Controls ─────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.35rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--gray-900);
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--blue-400);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.rfq-body-textarea {
    min-height: 250px;
    resize: vertical;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    line-height: 1.6;
}

.form-control-inline {
    width: 100%;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--gray-900);
    transition: border-color var(--transition);
    font-family: inherit;
}

.form-control-inline:focus {
    outline: none;
    border-color: var(--blue-400);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}

.input-invalid {
    border-color: var(--red-500) !important;
    background: #fff5f5;
}

.validation-hint {
    display: block;
    font-size: 0.72rem;
    color: var(--red-500);
    margin-top: 0.15rem;
}

.cost-input {
    max-width: 110px;
}

.currency-input {
    max-width: 70px;
    text-transform: uppercase;
}

.supplier-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--blue-500);
}

.request-no {
    background: var(--blue-50);
    color: var(--blue-700);
    padding: 0.15em 0.5em;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9em;
}

/* ── Review Header ────────────────────────────────────────── */
.review-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.review-header-left {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.review-header-left .page-title {
    margin-bottom: 0;
}

.review-header-right {
    padding-top: 0.5rem;
}

/* ── Action Bar ───────────────────────────────────────────── */
.action-bar {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding: 1.5rem 0;
    position: sticky;
    bottom: 0;
    background: var(--gray-100);
    border-top: 1px solid var(--gray-200);
    z-index: 50;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 520px;
    width: 100%;
    overflow: hidden;
    animation: modalSlide 200ms ease-out;
}

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

.modal-header {
    padding: 1.2rem 1.5rem;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-header-warning {
    background: linear-gradient(135deg, var(--orange-500), var(--red-500));
    color: var(--white);
}

.modal-body {
    padding: 1.5rem;
    line-height: 1.7;
}

.modal-footer {
    padding: 1rem 1.5rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ── Error Pages ──────────────────────────────────────────── */
.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.error-code {
    font-size: 5rem;
    font-weight: 800;
    color: var(--blue-700);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.error-title {
    font-size: 1.4rem;
    color: var(--gray-700);
    margin-bottom: 1rem;
}

.error-message {
    color: var(--gray-500);
    font-size: 1rem;
    max-width: 480px;
    margin: 0 auto 2rem;
}

.debug-box {
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 1.5rem auto;
    max-width: 600px;
    text-align: left;
    font-size: 0.85rem;
}

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-500);
}

.empty-state.small {
    padding: 2rem 1rem;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.empty-state h2 {
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
    background: var(--blue-900);
    color: var(--gray-400);
    text-align: center;
    padding: 1.2rem 0;
    font-size: 0.82rem;
    margin-top: auto;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    html { font-size: 14px; }

    .container { padding: 0 1rem; }

    .navbar-inner { min-height: 50px; }

    .navbar-brand { font-size: 1rem; }
    .brand-360 { font-size: 1.1rem; }

    .page-title { font-size: 1.3rem; }

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

    .review-header {
        flex-direction: column;
    }

    .action-bar {
        flex-direction: column;
    }

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

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

    .modal-box {
        margin: 1rem;
    }
}

@media (max-width: 480px) {
    .brand-divider,
    .brand-portal {
        display: none;
    }
}

/* ── Loading State ────────────────────────────────────────── */
.btn.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.75;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    right: 10px;
    top: 50%;
    margin-top: -8px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 600ms linear infinite;
}

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

