/* ========================================
   Shared Components CSS
   Aludecor Audit Portal
   ======================================== 
   
   This file contains shared component styles used across
   both CRM and R&D Lab applications.
   
   Structure:
   1. Search & Filter Components
   2. Pagination Components
   3. Table Components
   4. Status Badges
   5. Buttons & Actions
   6. Empty States
   7. Customer Info Cards
*/

/* ----------------------------------------
   1. Search & Filter Components
   ---------------------------------------- */

.search-filter-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.search-form {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    flex: 1;
    align-items: center;
}

.search-input-group {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 300px;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.clear-btn {
    white-space: nowrap;
}

.filter-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.status-filter {
    min-width: 150px;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

/* Results Info */
.results-info {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.results-count {
    font-size: 14px;
    color: var(--text-muted);
}

.results-count strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ----------------------------------------
   2. Pagination Components
   ---------------------------------------- */

.pagination-container {
    margin-top: 24px;
    display: flex;
    justify-content: center;
}

.pagination-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.page-link {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.page-link:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.page-link.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.page-info {
    padding: 8px 16px;
    font-size: 14px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.page-total {
    color: var(--text-muted);
    font-size: 12px;
}

/* ----------------------------------------
   3. Table Components
   ---------------------------------------- */

.table-container {
    overflow-x: auto;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.03);
}

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

.data-table code {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    padding: 3px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    color: var(--color-primary);
}

/* Row States */
.row-alert {
    background: rgba(239, 68, 68, 0.05) !important;
}

.row-warning {
    background: rgba(245, 158, 11, 0.05) !important;
}

.remarks-row {
    background: var(--bg-tertiary);
}

.remarks-row td {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
}

.remarks-content {
    font-size: 13px;
    color: var(--text-muted);
}

/* ----------------------------------------
   4. Status Badges
   ---------------------------------------- */

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-success,
.status-completed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
}

.status-warning,
.status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-warning);
}

.status-danger,
.status-error,
.status-rejected,
.status-overdue {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-danger);
}

.status-blue,
.status-testing {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.status-report {
    background: rgba(139, 92, 246, 0.15);
    color: #8b5cf6;
}

/* Exception Badges */
.exception-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.exception-damaged {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.exception-sample_missing {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.exception-invalid_sample {
    background: rgba(236, 72, 153, 0.15);
    color: #ec4899;
}

.exception-not_received {
    background: rgba(107, 114, 128, 0.15);
    color: #6b7280;
}

/* TAT Badges */
.tat-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.tat-overdue {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* ACP Type Badges */
.acp-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.acp-fr {
    background: rgba(139, 92, 246, 0.15);
    color: #8b5cf6;
}

.acp-non-fr {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

/* Test Type Badges */
.test-type-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.test-offline {
    background: rgba(107, 114, 128, 0.15);
    color: #6b7280;
}

.test-live {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

/* ----------------------------------------
   5. Buttons & Actions
   ---------------------------------------- */

.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    text-align: center;
}

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

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

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

.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-muted);
}

.btn-outline-warning {
    background: #e2a821a8;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-outline-warning:hover {
    background: #ffb100a8;
    border-color: var(--text-muted);
    color: var(--text-primary);
}

/* Button Loading Spinner */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s ease-in-out infinite;
    vertical-align: middle;
    margin-right: 6px;
}

.btn-outline .spinner,
.btn-danger .spinner {
    border-color: rgba(0, 0, 0, 0.2);
    border-top-color: currentColor;
}

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

/* ----------------------------------------
   6. Empty States
   ---------------------------------------- */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 2px dashed var(--border-color);
}

.empty-state svg {
    color: var(--text-muted);
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-muted);
}

/* ----------------------------------------
   7. Customer Info Cards
   ---------------------------------------- */

.customer-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.customer-name {
    font-weight: 500;
    color: var(--text-primary);
}

.customer-phone {
    font-size: 12px;
    color: var(--text-muted);
}

.phone-link {
    color: var(--color-primary);
    text-decoration: none;
}

.phone-link:hover {
    text-decoration: underline;
}

/* ----------------------------------------
   8. Form Components (Shared)
   ---------------------------------------- */

/* Form Card Container - Centers forms with max width */
.form-card {
    max-width: 600px;
    margin: 0 auto;
}

.form-card-wide {
    max-width: 700px;
    margin: 0 auto;
}

/* Sample/Slot Info Box */
.sample-info,
.current-slot-info {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.sample-info h4,
.current-slot-info h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.current-slot-info p {
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Grid - autofit column layout for home page */
.info-grid-home {
    display: grid;
    /* grid-template-columns: repeat(3, 1fr); */
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

/* Info Grid - 2 column layout for form info display */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.info-item label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.info-item span {
    font-weight: 600;
    color: var(--text-primary);
}

/* Form Group - Standard form field wrapper */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-group label.required::after {
    content: " *";
    color: #ef4444;
}

.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group .help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Button Group - Actions at bottom of forms */
.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Alert Cards - Danger/Warning message boxes */
.danger-card {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.danger-card h3 {
    color: #dc2626;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.danger-card p {
    color: #991b1b;
    font-size: 0.875rem;
    margin: 0;
}

.warning-card {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.warning-card h3 {
    color: #92400e;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.warning-card p {
    color: #78350f;
    font-size: 0.875rem;
    margin: 0;
}

.info-note {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 1px solid #6ee7b7;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.info-note p {
    margin: 0;
    color: #047857;
    font-size: 0.875rem;
}

/* Danger Button */
.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
}

/* Params Section - For test parameters input */
.params-section {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.params-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.params-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.param-field {
    display: flex;
    flex-direction: column;
}

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

.param-field label {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.param-field input,
.param-field select,
.param-field textarea {
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
}

.param-field input:focus,
.param-field select:focus,
.param-field textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

/* ----------------------------------------
   9. Responsive Design
   ---------------------------------------- */

@media (max-width: 768px) {
    .search-filter-bar {
        flex-direction: column;
    }

    .search-input-group {
        flex-wrap: wrap;
        min-width: 100%;
    }

    .search-input {
        width: 100%;
    }

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

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

/* ----------------------------------------
   8. Badge Components
   ---------------------------------------- */

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.badge-secondary {
    background: rgba(107, 114, 128, 0.15);
    color: #6b7280;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}