/* Kontrahenci Module - Styles */

/* ============================================
   Page Layout
   ============================================ */

.page-container {
    padding: 30px;
}

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

.page-header h1 {
    font-size: 1.5rem;
    margin: 0;
    color: #2c3e50;
}

/* ============================================
   Contractor Tabs
   ============================================ */

.contractor-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: 2px solid #e8ecef;
    background: #fff;
    color: #5a6c7d;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    border-color: #2d5a27;
    color: #2d5a27;
}

.tab-btn.active {
    background: #2d5a27;
    border-color: #2d5a27;
    color: #fff;
}

.tab-btn i {
    font-size: 1rem;
}

/* ============================================
   Content Card
   ============================================ */

.content-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
}

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

.card-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.card-body {
    padding: 0;
}

/* ============================================
   Data Table
   ============================================ */

.table-wrapper {
    overflow-x: auto;
}

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

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

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #e8ecef;
    font-size: 0.85rem;
    white-space: nowrap;
}

.th-sortable {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}

.th-sortable:hover {
    color: #2d5a27;
}

.sort-icon {
    font-size: 0.85rem;
    color: #a0aec0;
    transition: color 0.2s ease;
}

.sort-icon.active {
    color: #2d5a27;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e8ecef;
    color: #5a6c7d;
    font-size: 0.9rem;
}

.data-table tbody tr {
    transition: background-color 0.15s ease;
}

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

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

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-badge.active {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-badge.inactive {
    background: #ffebee;
    color: #c62828;
}

/* Count badges */
.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    background: #e3f2fd;
    color: #1976d2;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.count-badge.empty {
    background: #f5f5f5;
    color: #9e9e9e;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 6px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.btn-icon.btn-view {
    background: #e3f2fd;
    color: #1976d2;
}

.btn-icon.btn-view:hover {
    background: #bbdefb;
}

.btn-icon.btn-edit {
    background: #fff3e0;
    color: #f57c00;
}

.btn-icon.btn-edit:hover {
    background: #ffe0b2;
}

.btn-icon.btn-delete {
    background: #ffebee;
    color: #c62828;
}

.btn-icon.btn-delete:hover {
    background: #ffcdd2;
}

/* Loading state */
.loading-row td {
    text-align: center;
    padding: 40px;
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #5a6c7d;
}

.loading-spinner i {
    font-size: 1.2rem;
    color: #2d5a27;
}

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

.empty-state i {
    font-size: 3rem;
    color: #ddd;
    margin-bottom: 15px;
}

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

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, #2d5a27 0%, #4a9142 100%);
    color: #fff;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1e3d1a 0%, #2d5a27 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45, 90, 39, 0.3);
}

.btn-secondary {
    background: #e8ecef;
    color: #5a6c7d;
}

.btn-secondary:hover {
    background: #dce1e5;
}

.btn-danger {
    background: #e74c3c;
    color: #fff;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* ============================================
   Modals
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

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

.modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.contractor-modal {
    max-width: 700px;
}

.contractor-details-modal {
    max-width: 900px;
}

.contact-modal,
.warehouse-modal {
    max-width: 600px;
}

.delete-modal {
    max-width: 450px;
}

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

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #e8ecef;
    color: #5a6c7d;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #dce1e5;
    color: #2c3e50;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #e8ecef;
    background: #f8faf8;
}

/* ============================================
   Form Styles
   ============================================ */

.form-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #e8ecef;
}

.form-section:last-of-type {
    margin-bottom: 16px;
    padding-bottom: 0;
    border-bottom: none;
}

.form-section h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #2d5a27;
    margin: 0 0 16px 0;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-group {
    flex: 1;
}

.form-group.full-width {
    flex: 100%;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: #5a6c7d;
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #dce1e5;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #2c3e50;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2d5a27;
    box-shadow: 0 0 0 3px rgba(45, 90, 39, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #a0aec0;
}

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

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #5a6c7d;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #2d5a27;
}

/* ============================================
   Contractor Details Modal
   ============================================ */

.contractor-info {
    background: #f8faf8;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.contractor-info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.contractor-info-header h4 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.contractor-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.contractor-type-badge.handlowy {
    background: #e3f2fd;
    color: #1976d2;
}

.contractor-type-badge.transportowy {
    background: #fff3e0;
    color: #f57c00;
}

.contractor-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-item label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #9e9e9e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item span {
    font-size: 0.9rem;
    color: #2c3e50;
}

/* Details Tabs */
.details-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e8ecef;
    padding-bottom: 0;
}

.details-tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: #5a6c7d;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.details-tab-btn:hover {
    color: #2d5a27;
}

.details-tab-btn.active {
    color: #2d5a27;
    border-bottom-color: #2d5a27;
}

.details-tab-content {
    display: none;
}

.details-tab-content.active {
    display: block;
}

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

.tab-header h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

/* Items List (Contacts & Warehouses) */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-card {
    background: #fff;
    border: 1px solid #e8ecef;
    border-radius: 10px;
    padding: 16px;
    transition: all 0.2s ease;
}

.item-card:hover {
    border-color: #2d5a27;
    box-shadow: 0 2px 8px rgba(45, 90, 39, 0.1);
}

.item-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.item-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.item-card-title h5 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.primary-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.default-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #e3f2fd;
    color: #1976d2;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.item-card-actions {
    display: flex;
    gap: 6px;
}

.item-card-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.item-card-body .info-item span {
    font-size: 0.85rem;
}

.items-empty {
    text-align: center;
    padding: 40px 20px;
    color: #9e9e9e;
}

.items-empty i {
    font-size: 2.5rem;
    margin-bottom: 10px;
    opacity: 0.5;
}

.items-empty p {
    font-size: 0.9rem;
    margin: 0;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .contractor-tabs {
        flex-direction: column;
    }
    
    .form-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .modal {
        max-height: 95vh;
        margin: 10px;
    }
    
    .contractor-info-grid {
        grid-template-columns: 1fr;
    }
    
    .item-card-body {
        grid-template-columns: 1fr;
    }
}
