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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 11pt;
    background-color: #f0f0f0;
    color: #333;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: white;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #2b579a;
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-header h1 {
    font-size: 18pt;
    font-weight: 600;
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    background-color: #f4f4f4;
    border-bottom: 1px solid #c0c0c0;
    padding: 0 10px;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 11pt;
    color: #444;
    transition: all 0.2s;
}

.tab-btn:hover {
    background-color: #e8e8e8;
}

.tab-btn.active {
    border-bottom-color: #2b579a;
    color: #2b579a;
    font-weight: 600;
}

/* Tab Content */
.tab-content {
    flex: 1;
    overflow: hidden;
    padding: 20px;
}

.tab-pane {
    display: none;
    height: 100%;
}

.tab-pane.active {
    display: flex;
    flex-direction: column;
}

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

.tab-header h2 {
    font-size: 16pt;
    color: #2b579a;
}

.tab-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10pt;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background-color: #2b579a;
    color: white;
}

.btn-primary:hover {
    background-color: #1e3f6f;
}

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

.btn-secondary:hover {
    background-color: #545b62;
}

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

.btn-danger:hover {
    background-color: #c82333;
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
}

/* Form Elements */
.search-input, .form-input, .form-select {
    padding: 8px 12px;
    border: 1px solid #c0c0c0;
    border-radius: 4px;
    font-size: 10pt;
}

.search-input {
    min-width: 250px;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: #2b579a;
}

/* Grid Container */
.grid-container {
    flex: 1;
    overflow: auto;
    border: 1px solid #c0c0c0;
    background-color: white;
}

/* Excel-like Table */
.excel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
}

.excel-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.excel-table th {
    background-color: #e7e6e6;
    border: 1px solid #c0c0c0;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.excel-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.excel-table th.sortable:hover {
    background-color: #d8d7d7;
}

.excel-table td {
    border: 1px solid #d0d0d0;
    padding: 6px 12px;
    transition: background-color 0.15s ease;
}

.excel-table tbody tr:nth-child(odd) td {
    background-color: white;
}

.excel-table tbody tr:nth-child(even) td {
    background-color: #fafafa;
}

.excel-table tbody tr:hover td {
    background-color: #e7f3ff;
}

.excel-table tbody tr:hover {
    box-shadow: inset 0 0 0 2px #2b579a;
}

/* Table Actions */
.table-actions {
    display: flex;
    gap: 5px;
}

.action-btn {
    padding: 4px 8px;
    font-size: 9pt;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn-edit {
    background-color: #007bff;
    color: white;
}

.action-btn-edit:hover {
    background-color: #0056b3;
}

.action-btn-delete {
    background-color: #dc3545;
    color: white;
}

.action-btn-delete:hover {
    background-color: #c82333;
}

.action-btn-view {
    background-color: #28a745;
    color: white;
}

.action-btn-view:hover {
    background-color: #218838;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

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

.modal-content {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 500px;
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h3 {
    font-size: 14pt;
    color: #2b579a;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24pt;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

/* Form Styles */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #c0c0c0;
    border-radius: 4px;
    font-size: 10pt;
}

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

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

/* Loading Spinner */
.loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

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

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #2b579a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state-icon {
    font-size: 48pt;
    margin-bottom: 20px;
}

.empty-state-text {
    font-size: 12pt;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 9pt;
    font-weight: 500;
}

.badge-success {
    background-color: #d4edda;
    color: #155724;
}

.badge-warning {
    background-color: #fff3cd;
    color: #856404;
}

.badge-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.badge-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Quantity Indicators */
.quantity-low {
    color: #dc3545;
    font-weight: 600;
}

.quantity-medium {
    color: #ffc107;
    font-weight: 600;
}

.quantity-high {
    color: #28a745;
    font-weight: 600;
}

/* Help Button */
.help-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #6c757d;
    color: white;
    text-align: center;
    line-height: 18px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 5px;
}

.help-icon:hover {
    background-color: #545b62;
}

/* Responsive */
@media (max-width: 768px) {
    .tab-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .tab-actions {
        width: 100%;
        flex-wrap: wrap;
    }

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

    .modal-content {
        min-width: 90vw;
    }
}

/* Help Tooltips */
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #2b579a;
    color: white;
    font-size: 12px;
    font-weight: bold;
    cursor: help;
    margin-left: 5px;
    position: relative;
    vertical-align: middle;
}

.help-icon:hover {
    background-color: #1e3f73;
}

.help-icon .tooltip {
    visibility: hidden;
    opacity: 0;
    width: 280px;
    background-color: #333;
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 10000;
    top: 50%;
    left: calc(100% + 10px);
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: normal;
    line-height: 1.4;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: opacity 0.3s;
    pointer-events: none;
}

.help-icon .tooltip::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%;
    margin-top: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent #333 transparent transparent;
}

.help-icon:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

/* Help icon in form labels */
.form-label .help-icon {
    margin-left: 8px;
}

/* Autocomplete Component */
.autocomplete-wrapper {
    position: relative;
    width: 100%;
}

.autocomplete-input {
    width: 100%;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background-color: white;
    border: 1px solid #c0c0c0;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    margin-top: -1px;
}

.autocomplete-dropdown.hidden {
    display: none;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.15s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.focused {
    background-color: #e7f3ff;
}

.autocomplete-item-main {
    font-size: 10pt;
    color: #333;
}

.autocomplete-item-secondary {
    font-size: 9pt;
    color: #666;
    margin-top: 2px;
}

.autocomplete-create-new {
    background-color: #f8f9fa;
    color: #2b579a;
    font-weight: 500;
    border-bottom: 2px solid #2b579a;
}

.autocomplete-create-new:hover,
.autocomplete-create-new.focused {
    background-color: #e7f3ff;
}

.autocomplete-no-results {
    color: #999;
    font-style: italic;
    cursor: default;
}

.autocomplete-no-results:hover {
    background-color: white;
}
