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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 100%;
    margin: 0 auto;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.role-badge {
    background: rgba(255,255,255,0.2);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    text-transform: uppercase;
}

/* Main Content */
.main-content {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.toolbar h2 {
    font-size: 1.75rem;
    color: #333;
}

.toolbar-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.search-input {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 250px;
    font-size: 0.875rem;
}

/* Filters */
.filters {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.filters label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.filters select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 150px;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

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

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

.btn-primary:hover {
    background: #5568d3;
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-success:hover {
    background: #38a169;
}

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

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

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

.btn-secondary:hover {
    background: #4a5568;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-block {
    width: 100%;
    text-align: center;
}

/* Table */
#accountsTableContainer {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

.data-table thead {
    background: #f7fafc;
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: #4a5568;
    border-bottom: 2px solid #e2e8f0;
    cursor: pointer;
    user-select: none;
}

.data-table th:hover {
    background: #edf2f7;
}

.data-table td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid #e2e8f0;
}

.data-table tbody tr:hover {
    background: #f7fafc;
}

.data-table .actions {
    display: flex;
    gap: 0.5rem;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.status-badge.receive { background: #e6f7ff; color: #0050b3; }
.status-badge.submitted { background: #fff7e6; color: #d46b08; }
.status-badge.approved { background: #f6ffed; color: #389e0d; }
.status-badge.rejected { background: #fff1f0; color: #cf1322; }
.status-badge.live { background: #f6ffed; color: #52c41a; }
.status-badge.dead { background: #f5f5f5; color: #8c8c8c; }

.remarks-preview {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    color: #667eea;
}

.remarks-preview:hover {
    text-decoration: underline;
}

.text-center {
    text-align: center;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 2rem 0;
}

.pagination button {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.875rem;
}

.pagination button:hover:not(:disabled) {
    background: #f7fafc;
}

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

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

.pagination-info {
    font-size: 0.875rem;
    color: #718096;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.2s;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s;
}

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

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: #333;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #333;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: #4a5568;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
}

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

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Alert */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 2rem;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.alert-success {
    background: #f6ffed;
    color: #389e0d;
    border: 1px solid #b7eb8f;
}

.alert-error {
    background: #fff1f0;
    color: #cf1322;
    border: 1px solid #ffa39e;
}

.alert-info {
    background: #e6f7ff;
    color: #0050b3;
    border: 1px solid #91d5ff;
}

/* History Display */
.history-item {
    padding: 1rem;
    border-left: 3px solid #667eea;
    background: #f7fafc;
    margin-bottom: 1rem;
    border-radius: 4px;
}

.history-item .history-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: #718096;
}

.history-item .history-content {
    font-size: 0.875rem;
    color: #333;
}

.history-item .history-change {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.history-item .old-value {
    text-decoration: line-through;
    color: #e53e3e;
}

.history-item .new-value {
    color: #38a169;
    font-weight: 500;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.login-box {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.login-box h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 0.5rem;
}

.login-box h2 {
    text-align: center;
    color: #333;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.login-info {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #f7fafc;
    border-radius: 4px;
    font-size: 0.875rem;
    text-align: center;
}

.login-info p {
    margin: 0.25rem 0;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-actions {
        flex-direction: column;
    }

    .search-input {
        width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    #accountsTableContainer {
        overflow-x: auto;
    }

    .data-table {
        min-width: 1000px;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
}


/* Inline Editing Styles */
.editable-cell {
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s;
    padding: 0.5rem;
}

.editable-cell:hover {
    background-color: #f0f4ff;
}

.editable-cell.editing {
    padding: 0;
    background-color: #fff;
}

.inline-input {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid #667eea;
    border-radius: 4px;
    font-size: 0.875rem;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.inline-select {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid #667eea;
    border-radius: 4px;
    font-size: 0.875rem;
    outline: none;
    background-color: white;
    cursor: pointer;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.editable-status {
    display: inline-block;
    width: 100%;
}

.saving-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #667eea;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 0.5rem;
    vertical-align: middle;
}

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

.edit-hint {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 0.7rem;
    color: #999;
    pointer-events: none;
}

.editable-cell:hover .edit-hint {
    color: #667eea;
}

/* Modal Size Variants */
.modal-small .modal-content {
    max-width: 500px;
}

.modal-large .modal-content {
    max-width: 900px;
}

/* Audit Trail Styles */
.audit-item {
    border-left: 3px solid #e2e8f0;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #f8fafc;
    border-radius: 4px;
}

.audit-item.audit-status {
    border-left-color: #667eea;
}

.audit-item.audit-balance {
    border-left-color: #48bb78;
}

.audit-item.audit-b_mob,
.audit-item.audit-b_desk {
    border-left-color: #ed8936;
}

.audit-item.audit-remark {
    border-left-color: #9f7aea;
}

.audit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.audit-type {
    font-weight: 600;
    text-transform: uppercase;
    color: #4a5568;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.audit-time {
    color: #718096;
    font-size: 0.875rem;
}

.audit-change {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.audit-value {
    padding: 0.25rem 0.75rem;
    background: white;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

.audit-value.old {
    color: #e53e3e;
    text-decoration: line-through;
}

.audit-value.new {
    color: #38a169;
    font-weight: 500;
}

.audit-arrow {
    color: #a0aec0;
    font-weight: bold;
}

.audit-user {
    font-weight: 500;
    color: #2d3748;
}

.audit-remark-content {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: white;
    border-radius: 4px;
    color: #2d3748;
    line-height: 1.6;
}

/* Action Button Group */
.action-buttons {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.btn-icon {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
}

/* Enhanced Remarks Display */
.remarks-cell {
    max-width: 200px;
}

.remarks-preview {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    color: #4a5568;
}

.remarks-preview:hover {
    color: #667eea;
    text-decoration: underline;
}

.remarks-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Enhanced Remarks Modal */
.remarks-with-add {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.remarks-add-section {
    border-top: 2px solid #e2e8f0;
    padding-top: 1.5rem;
}

.remarks-history-section {
    max-height: 400px;
    overflow-y: auto;
}

/* Form Textarea */
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.875rem;
    resize: vertical;
    min-height: 80px;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #a0aec0;
}

.empty-state p {
    margin: 0;
    font-size: 1rem;
}
