/**
 * Purchase Management App - Styles
 * Extracted from inline styles for maintainability
 */

/* ============================================
   BASE STYLES
   ============================================ */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    padding: 20px;
    margin: 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   HEADER
   ============================================ */

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 25px;
}

.header h1 {
    margin: 0 0 15px 0;
    font-size: 28px;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn-primary {
    background: white;
    color: #667eea;
}

.btn-primary:hover {
    background: #f8f9fa;
}

.btn-secondary {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.3);
}

/* ============================================
   MODALS
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 700px;
    margin: 40px auto;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
    border-radius: 12px 12px 0 0;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f9fafb;
    border-radius: 0 0 12px 12px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
}

/* ============================================
   FORMS
   ============================================ */

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 14px;
    color: #374151;
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

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

/* Remove scroll arrows from number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

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

/* ============================================
   ORDER CARDS
   ============================================ */

.order-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e5e7eb;
    transition: all 0.2s;
}

.order-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.order-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
}

.empty-state {
    background: white;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 2px dashed #d1d5db;
}

/* ============================================
   STATUS BADGES
   ============================================ */

.status-badge {
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: inline-block;
    margin-right: 6px;
}

.status-draft { background: #f3f4f6; color: #374151; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-sent { background: #dbeafe; color: #1e40af; }
.status-approved { background: #dcfce7; color: #166534; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-received { background: #e0e7ff; color: #3730a3; }

/* ============================================
   ITEM ROWS
   ============================================ */

.item-row {
    display: grid;
    grid-template-columns: 3fr 1fr 1fr 1.5fr 1fr 1.5fr auto;
    gap: 10px;
    margin-bottom: 10px;
    align-items: start;
}

.item-row input,
.item-row select {
    padding: 6px;
}

.item-total {
    padding: 6px;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    text-align: right;
    line-height: 1.5;
}

.delete-item-btn {
    padding: 6px 10px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
}

.delete-item-btn:hover {
    background: #b91c1c;
}

/* ============================================
   AUTOCOMPLETE
   ============================================ */

.autocomplete-suggestions {
    position: absolute;
    background: white;
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.autocomplete-suggestion {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
}

.autocomplete-suggestion:hover {
    background: #f3f4f6;
}

.autocomplete-container {
    position: relative;
}

/* ============================================
   RECEIPT BADGES & HISTORY
   ============================================ */

.receipt-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

.receipt-pending { background: #fef3c7; color: #92400e; }
.receipt-partial { background: #dbeafe; color: #1e40af; }
.receipt-complete { background: #dcfce7; color: #166534; }
.receipt-short-closed { background: #f3e8ff; color: #7c3aed; }

.receipt-item {
    background: #f9fafb;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.receipt-history {
    margin-top: 15px;
    padding: 15px;
    background: #f0f9ff;
    border-radius: 8px;
}

.receipt-history-item {
    padding: 8px;
    margin-bottom: 8px;
    background: white;
    border-radius: 4px;
    font-size: 13px;
}

/* ============================================
   MODIFICATION HISTORY (AUDIT TRAIL)
   ============================================ */

.modification-history {
    margin-top: 10px;
    padding: 10px;
    background: #fef2f2;
    border-left: 3px solid #dc2626;
    border-radius: 4px;
    font-size: 12px;
}

.modification-entry {
    margin-bottom: 6px;
    padding: 6px;
    background: white;
    border-radius: 3px;
}

.change-old {
    color: #dc2626;
    text-decoration: line-through;
}

.change-new {
    color: #16a34a;
    font-weight: 500;
}

/* ============================================
   INVOICE BADGES
   ============================================ */

.invoice-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

.invoice-none { background: #fef3c7; color: #92400e; }
.invoice-draft { background: #e5e7eb; color: #374151; }
.invoice-pending { background: #fef3c7; color: #92400e; }
.invoice-approved { background: #dcfce7; color: #166534; }
.invoice-rejected { background: #fee2e2; color: #991b1b; }

.discrepancy-alert {
    background: #fef2f2;
    border-left: 3px solid #dc2626;
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
    font-size: 13px;
}

/* ============================================
   PAYMENT BADGES & HISTORY
   ============================================ */

.payment-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

.payment-unpaid { background: #fee2e2; color: #991b1b; }
.payment-partial { background: #fef3c7; color: #92400e; }
.payment-paid { background: #dcfce7; color: #166534; }

.payment-history {
    margin-top: 15px;
    padding: 15px;
    background: #f0fdf4;
    border-radius: 8px;
}

.payment-history-item {
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border-radius: 4px;
    font-size: 13px;
    border-left: 3px solid #16a34a;
}

/* ============================================
   LOGIN & AUTHENTICATION
   ============================================ */

#login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
}

#login-container.hidden { display: none; }

.login-box {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.login-logo { font-size: 48px; margin-bottom: 20px; }
.login-title { font-size: 24px; color: #1f2937; margin-bottom: 10px; }
.login-subtitle { color: #6b7280; margin-bottom: 30px; }

.ms-login-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: #2f2f2f;
    color: white;
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.ms-login-btn:hover { background: #1f1f1f; }
.ms-login-btn svg { width: 20px; height: 20px; }

.login-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px;
    border-radius: 8px;
    margin-top: 20px;
}

.login-pending {
    background: #fef3c7;
    color: #92400e;
    padding: 12px;
    border-radius: 8px;
    margin-top: 20px;
}

#app-container.hidden { display: none; }

/* ============================================
   USER MENU
   ============================================ */

.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.user-info { text-align: right; }
.user-info .user-name { font-weight: 600; font-size: 14px; }
.user-info .user-role { font-size: 11px; opacity: 0.8; text-transform: uppercase; }

.logout-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.logout-btn:hover { background: rgba(255,255,255,0.3); }

.admin-btn {
    background: #dc2626;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.admin-btn:hover { background: #b91c1c; }

/* ============================================
   USER MANAGEMENT
   ============================================ */

.user-management-modal .modal-content { max-width: 800px; }

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.users-table th, .users-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.users-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.users-table tr:hover { background: #f9fafb; }

.role-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.role-admin { background: #fef2f2; color: #dc2626; }
.role-data_entry { background: #eff6ff; color: #2563eb; }
.role-verifier { background: #f0fdf4; color: #16a34a; }
.role-pending { background: #fefce8; color: #ca8a04; }

.status-active { background: #dcfce7; color: #16a34a; }
.status-inactive { background: #fee2e2; color: #dc2626; }

.role-select {
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 4px;
}

.action-btn.activate { background: #dcfce7; color: #16a34a; }
.action-btn.deactivate { background: #fee2e2; color: #dc2626; }

.no-users {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

/* ============================================
   LOADING OVERLAY
   ============================================ */

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

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

.loading-box {
    background: white;
    padding: 20px 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
